Class: Tenderloin::Actions::VM::Up

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

Instance Attribute Summary

Attributes inherited from Base

#runner

Instance Method Summary collapse

Methods inherited from Base

#cleanup, #execute!, #initialize, #rescue

Methods included from Util

#error_and_exit, included, #logger, #wrap_output

Constructor Details

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

Instance Method Details

#after_importObject



29
30
31
32
# File 'lib/tenderloin/actions/vm/up.rb', line 29

def after_import
  persist
  setup_uuid_mac
end

#persistObject



34
35
36
37
# File 'lib/tenderloin/actions/vm/up.rb', line 34

def persist
  logger.info "Persisting the VM UUID (#{@runner.vm_id})..."
  Env.persist_vm(@runner.vm_id)
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
# File 'lib/tenderloin/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 Tenderloin 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.tenderloin.dotfile_name`
msg
  end

  # Up is a "meta-action" so it really just queues up a bunch
  # of other actions in its place:
  Tenderloin::Box.add(Tenderloin.config.vm.box, Tenderloin.config.vm.box_url) unless Tenderloin::Env.box
  steps = [Import, SharedFolders, Boot]
  steps << Provision if Tenderloin.config.provisioning.enabled
  steps.insert(0, MoveHardDrive) if Tenderloin.config.vm.hd_location

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

#setup_uuid_macObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/tenderloin/actions/vm/up.rb', line 39

def setup_uuid_mac
  logger.info "Resetting VMX UUID, MAC and Display Name..."

  VMXFile.with_vmx_data(@runner.vmx_path) do |data|
    data.delete "ethernet0.addressType"
    data.delete "uuid.location"
    data.delete "uuid.bios"
    data.delete "ethernet0.generatedAddress"
    data.delete "ethernet1.generatedAddress"
    data.delete "ethernet0.generatedAddressOffset"
    data.delete "ethernet1.generatedAddressOffset"
    data.delete 'displayname'
    data['displayName'] = "tenderloin-" + @runner.vm_id
  end
end