Class: VagrantPlugins::VCloud::Action::PowerOff
- Inherits:
-
Object
- Object
- VagrantPlugins::VCloud::Action::PowerOff
- Defined in:
- lib/vagrant-vcloud/action/power_off.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ PowerOff
constructor
A new instance of PowerOff.
Constructor Details
#initialize(app, env) ⇒ PowerOff
Returns a new instance of PowerOff.
5 6 7 8 |
# File 'lib/vagrant-vcloud/action/power_off.rb', line 5 def initialize(app, env) @app = app @logger = Log4r::Logger.new('vagrant_vcloud::action::poweroff') 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/power_off.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}" ) # Poweroff VM env[:ui].info('Powering off VM...') task_id = cnx.poweroff_vm(vm_id) cnx.wait_task_completion(task_id) @app.call env end |