Sha256: 66ab0182f1023f664010f2a387a848120557625ebd0b5a4b7bd981f4299e4224

Contents?: true

Size: 822 Bytes

Versions: 8

Compression:

Stored size: 822 Bytes

Contents

require 'i18n'

module VagrantPlugins
  module VCenter
    module Action
      # This class resumes the VM when it's suspended.
      class Resume
        def initialize(app, env)
          @app = app
          @logger = Log4r::Logger.new('vagrant_vcenter::action::resume')
        end

        def call(env)
          config = env[:machine].provider_config
          # FIXME: Raise a correct exception
          dc = config.vcenter_cnx.serviceInstance.find_datacenter(
               config.datacenter_name) or abort 'datacenter not found'
          root_vm_folder = dc.vmFolder
          vm = root_vm_folder.findByUuid(env[:machine].id)

          # Poweroff VM
          env[:ui].info('Powering on VM...')
          vm.PowerOnVM_Task.wait_for_completion

          @app.call env
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
vagrant-vcenter-0.3.2 lib/vagrant-vcenter/action/resume.rb
vagrant-vcenter-0.3.1 lib/vagrant-vcenter/action/resume.rb
vagrant-vcenter-0.3.0 lib/vagrant-vcenter/action/resume.rb
vagrant-vcenter-0.2.1 lib/vagrant-vcenter/action/resume.rb
vagrant-vcenter-0.2.0 lib/vagrant-vcenter/action/resume.rb
vagrant-vcenter-0.1.1 lib/vagrant-vcenter/action/resume.rb
vagrant-vcenter-0.1.0 lib/vagrant-vcenter/action/resume.rb
vagrant-vcenter-0.0.2.pre.dev lib/vagrant-vcenter/action/resume.rb