Class: VagrantPlugins::XenServer::Action::SuspendVM

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-xenserver/action/suspend_vm.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ SuspendVM

Returns a new instance of SuspendVM.



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

def initialize(app, env)
  @app = app
  @logger = Log4r::Logger.new("vagrant::xenserver::actions::suspend_vm")
end

Instance Method Details

#call(env) ⇒ Object



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

def call(env)
  myvm = env[:machine].id
  
  suspend_task = env[:xc].Async.VM.suspend(myvm)
  while env[:xc].task.get_status(suspend_task) == 'pending' do
      sleep 1
  end
  suspend_result = env[:xc].task.get_status(suspend_task)
  if suspend_result != "success"
    raise Errors::APIError
  end
  
  @app.call env
end