Class: VagrantPlugins::SoftLayer::Action::WaitForProvision
- Inherits:
-
Object
- Object
- VagrantPlugins::SoftLayer::Action::WaitForProvision
- Includes:
- Util::Warden
- Defined in:
- lib/vagrant-softlayer/action/wait_for_provision.rb
Overview
Waits until the new machine has been provisioned.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ WaitForProvision
constructor
A new instance of WaitForProvision.
Methods included from Util::Warden
Constructor Details
#initialize(app, env) ⇒ WaitForProvision
Returns a new instance of WaitForProvision.
10 11 12 13 |
# File 'lib/vagrant-softlayer/action/wait_for_provision.rb', line 10 def initialize(app, env) @app = app @logger = Log4r::Logger.new("vagrant_softlayer::action::wait_for_provision") end |
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/vagrant-softlayer/action/wait_for_provision.rb', line 15 def call(env) env[:ui].info I18n.t("vagrant_softlayer.vm.wait_for_provision") env[:sl_machine] = env[:sl_virtual_guest].object_with_id(env[:machine].id.to_i) retry_msg = lambda { @logger.debug("Object not found, retrying in 10 seconds.") } # 20 minutes timeout Timeout::timeout(1200) do @logger.debug("Checking if the newly ordered machine has been provisioned.") sl_warden(retry_msg, 10) do while env[:sl_machine].getPowerState["name"] != "Running" || env[:sl_machine].object_mask( { "provisionDate" => "" } ).getObject == {} @logger.debug("The machine is still provisioning. Retrying in 10 seconds.") sleep 10 end end end env[:ui].info I18n.t("vagrant_softlayer.vm.provisioned") @app.call(env) end |