Class: VagrantPlugins::XenServer::Action::SuspendVM
- Inherits:
-
Object
- Object
- VagrantPlugins::XenServer::Action::SuspendVM
- Defined in:
- lib/vagrant-xenserver/action/suspend_vm.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ SuspendVM
constructor
A new instance of SuspendVM.
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 |