Class: Chef::Provisioning::VboxDriver::Driver

Inherits:
Driver
  • Object
show all
Defined in:
lib/chef/provisioning/vbox_driver/driver.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.canonicalize_url(driver_url, config) ⇒ Object

generated by script, required by API.



10
11
12
# File 'lib/chef/provisioning/vbox_driver/driver.rb', line 10

def self.canonicalize_url(driver_url, config)
  [ "vbox:#{driver_url} [vboxmanage]", config ]
end

.from_url(driver_url, config) ⇒ Object

generated by script, required by API.



15
16
17
# File 'lib/chef/provisioning/vbox_driver/driver.rb', line 15

def self.from_url(driver_url, config)
  Driver.new(driver_url, config)
end

Instance Method Details

#allocate_machine(action_handler, machine_spec, machine_options) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/chef/provisioning/vbox_driver/driver.rb', line 50

def allocate_machine(action_handler, machine_spec, machine_options)
  if machine_spec.reference
    if !vbox.server_exists?(machine_spec.reference['server_id'])
      action_handler.perform_action "Machine #{machine_spec.reference['server_id']} does not exist.  Recreating ..." do
         machine_spec.reference = nil
      end
    end
  end
  if !machine_spec.reference
    action_handler.perform_action "Creating server #{machine_spec.name} with options #{machine_options}" do
      private_key = get_private_key('bootstrapkey')
      server_id = vbox.create_server(machine_spec.name, machine_options)
      machine_spec.reference = {
        'driver_version' => Vbox::VERSION,
        'server_id' => server_id
      }
    end
  end
end