Class: VagrantPlugins::OVirtProvider::Action::WaitTillDown
- Inherits:
-
Object
- Object
- VagrantPlugins::OVirtProvider::Action::WaitTillDown
- Includes:
- Vagrant::Util::Retryable
- Defined in:
- lib/vagrant-ovirt4/action/wait_till_down.rb
Overview
Wait till VM is stopped
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ WaitTillDown
constructor
A new instance of WaitTillDown.
Constructor Details
#initialize(app, env) ⇒ WaitTillDown
Returns a new instance of WaitTillDown.
13 14 15 16 |
# File 'lib/vagrant-ovirt4/action/wait_till_down.rb', line 13 def initialize(app, env) @logger = Log4r::Logger.new("vagrant_ovirt4::action::wait_till_down") @app = app end |
Instance Method Details
#call(env) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/vagrant-ovirt4/action/wait_till_down.rb', line 18 def call(env) vm_service = env[:vms_service].vm_service(env[:machine].id) env[:ui].info(I18n.t("vagrant_ovirt4.wait_till_down")) for i in 1..300 ready = true begin if vm_service.get == nil raise NoVMError, :error_message => '', :vm_id => env[:machine].id end rescue OvirtSDK4::Error => e = /Fault detail is \"\[?(.+?)\]?\".*/.match(e.)[1] rescue e. if config.debug raise e else raise Errors::NoVMError, :error_message => , :vm_id => env[:machine].id end end if vm_service.get.status.to_sym != :down ready = false end break if ready sleep 2 end if not ready raise Errors::WaitForShutdownVmTimeout end @app.call(env) end |