Class: VagrantPlugins::VCloud::Action::PowerOn

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-vcloud/action/power_on.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ PowerOn

Returns a new instance of PowerOn.



5
6
7
8
# File 'lib/vagrant-vcloud/action/power_on.rb', line 5

def initialize(app, env)
  @app = app
  @logger = Log4r::Logger.new('vagrant_vcloud::action::power_on')
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/vagrant-vcloud/action/power_on.rb', line 10

def call(env)
  @env = env

  cfg = env[:machine].provider_config
  cnx = cfg.vcloud_cnx.driver

  env[:ui].info('Setting VM hardware...')

  set_vm_hardware = cnx.set_vm_hardware(env[:machine].id, cfg)
  if set_vm_hardware
    cnx.wait_task_completion(set_vm_hardware)
  end

  env[:ui].info('Powering on VM...')

  if ! cfg.nested_hypervisor.nil?
    set_vm_nested_hypervisor = cnx.set_vm_nested_hypervisor(env[:machine].id, cfg.nested_hypervisor)
    if set_vm_nested_hypervisor
      cnx.wait_task_completion(set_vm_nested_hypervisor)
    end
  end

  poweron_vm = cnx.poweron_vm(env[:machine].id)
  cnx.wait_task_completion(poweron_vm)

  @app.call(env)
end