Sha256: ab257052831645ce3f0b1e41699a86e39625ce6ae2bd59edef3177eca8e6a37b

Contents?: true

Size: 814 Bytes

Versions: 4

Compression:

Stored size: 814 Bytes

Contents

module VagrantPlugins
  module VCloudAir
    module Action
      class PowerOff
        def initialize(app, env)
          @app = app
          @logger = Log4r::Logger.new('vagrant_vcloudair::action::poweroff')
        end

        def call(env)
          cfg = env[:machine].provider_config
          cnx = cfg.vcloudair_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(I18n.t('vagrant_vcloudair.vm.poweroff_vm'))
          task_id = cnx.poweroff_vm(vm_id)
          cnx.wait_task_completion(task_id)

          @app.call env
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vagrant-vcloudair-0.5.3 lib/vagrant-vcloudair/action/power_off.rb
vagrant-vcloudair-0.5.2 lib/vagrant-vcloudair/action/power_off.rb
vagrant-vcloudair-0.5.1 lib/vagrant-vcloudair/action/power_off.rb
vagrant-vcloudair-0.5.0 lib/vagrant-vcloudair/action/power_off.rb