Class: VagrantPlugins::VCloud::Action::ShutDown

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

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ ShutDown

Returns a new instance of ShutDown.


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

def initialize(app, env)
  @app = app
  @logger = Log4r::Logger.new('vagrant_vcloud::action::shutdown')
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
# File 'lib/vagrant-vcloud/action/shut_down.rb', line 10

def call(env)
  cfg = env[:machine].provider_config
  cnx = cfg.vcloud_cnx.driver

  vapp_id = env[:machine].get_vapp_id
  vm_id = env[:machine].id

  test_vapp = cnx.get_vapp(vapp_id)

  @logger.debug(
    "Number of VMs in the vApp: #{test_vapp[:vms_hash].count}"
  )

  # Shutdown VM
  env[:ui].info('Shutting down VM...')
  task_id = cnx.shutdown_vm(vm_id)
  cnx.wait_task_completion(task_id)

  @app.call env
end