Class: VagrantPlugins::VCenter::Action::Resume

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-vcenter/action/resume.rb

Overview

This class resumes the VM when it’s suspended.

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ Resume

Returns a new instance of Resume.



8
9
10
11
# File 'lib/vagrant-vcenter/action/resume.rb', line 8

def initialize(app, env)
  @app = app
  @logger = Log4r::Logger.new('vagrant_vcenter::action::resume')
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/vagrant-vcenter/action/resume.rb', line 13

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