Sha256: 0d0d077d8de772fe04b3b65d7152dbf1ff70e79dd514db165557f4aa8782cc3d
Contents?: true
Size: 1.22 KB
Versions: 2
Compression:
Stored size: 1.22 KB
Contents
require "i18n" module VagrantPlugins module VCloud module Action class PowerOff def initialize(app, env) @app = app @logger = Log4r::Logger.new("vagrant_vcloud::action::poweroff") end def call(env) cfg = env[:machine].provider_config cnx = cfg.vcloud_cnx.driver vAppId = env[:machine].get_vapp_id vmId = env[:machine].id vmName = env[:machine].name testvApp = cnx.get_vapp(vAppId) @logger.debug("Number of VMs in the vApp: #{testvApp[:vms_hash].count}") if testvApp[:vms_hash].count == 1 # Poweroff vApp env[:ui].info("Powering off vApp...") vAppStopTask = cnx.poweroff_vapp(vAppId) vAppStopWait = cnx.wait_task_completion(vAppStopTask) if !vAppStopWait[:errormsg].nil? raise Errors::StopVAppError, :message => vAppStopWait[:errormsg] end else # Poweroff VM env[:ui].info("Powering off VM...") task_id = cnx.poweroff_vm(vmId) wait = cnx.wait_task_completion(task_id) end true @app.call env end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vagrant-vcloud-0.1.2 | lib/vagrant-vcloud/action/power_off.rb |
vagrant-vcloud-0.1.1 | lib/vagrant-vcloud/action/power_off.rb |