Class: Vagrant::Actions::VM::Up

Inherits:
Base
  • Object
show all
Defined in:
lib/vagrant/actions/vm/up.rb

Instance Attribute Summary

Attributes inherited from Base

#runner

Instance Method Summary collapse

Methods inherited from Base

#cleanup, #execute!, #follows, #initialize, #precedes, #rescue

Methods included from Util

#error_and_exit, included, #logger, #wrap_output

Constructor Details

This class inherits a constructor from Vagrant::Actions::Base

Instance Method Details

#after_importObject



32
33
34
35
# File 'lib/vagrant/actions/vm/up.rb', line 32

def after_import
  persist
  setup_mac_address
end

#persistObject



37
38
39
40
# File 'lib/vagrant/actions/vm/up.rb', line 37

def persist
  logger.info "Persisting the VM UUID (#{@runner.uuid})..."
  Env.persist_vm(@runner)
end

#prepareObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/vagrant/actions/vm/up.rb', line 5

def prepare
  # If the dotfile is not a file, raise error
  if File.exist?(Env.dotfile_path) && !File.file?(Env.dotfile_path)
    raise ActionException.new(<<-msg)
The dotfile which Vagrant uses to store the UUID of the project's
virtual machine already exists and is not a file! The dotfile is
currently configured to be `#{Env.dotfile_path}`

To change this value, please see `config.vagrant.dotfile_name`

This often exists if you're trying to create a Vagrant virtual
environment from your home directory. To resolve this, you can either
modify the configuration a bit, or simply use a different directory.
msg
  end

  # Up is a "meta-action" so it really just queues up a bunch
  # of other actions in its place:
  steps = [Import, Customize, ForwardPorts, SharedFolders, Boot]
  steps << Provision if !Vagrant.config.vm.provisioner.nil?
  steps.insert(0, MoveHardDrive) if Vagrant.config.vm.hd_location

  steps.each do |action_klass|
    @runner.add_action(action_klass)
  end
end

#setup_mac_addressObject



42
43
44
45
46
# File 'lib/vagrant/actions/vm/up.rb', line 42

def setup_mac_address
  logger.info "Matching MAC addresses..."
  @runner.vm.nics.first.macaddress = Vagrant.config[:vm][:base_mac]
  @runner.vm.save(true)
end