Class: VagrantPlugins::Openstack::Action::WaitForServerToStop
- Inherits:
-
AbstractAction
- Object
- AbstractAction
- VagrantPlugins::Openstack::Action::WaitForServerToStop
- Defined in:
- lib/vagrant-openstack-illuin-provider/action/wait_stop.rb
Instance Method Summary collapse
- #execute(env) ⇒ Object
-
#initialize(app, _env, retry_interval = 3) ⇒ WaitForServerToStop
constructor
A new instance of WaitForServerToStop.
Methods inherited from AbstractAction
Constructor Details
#initialize(app, _env, retry_interval = 3) ⇒ WaitForServerToStop
Returns a new instance of WaitForServerToStop.
10 11 12 13 14 |
# File 'lib/vagrant-openstack-illuin-provider/action/wait_stop.rb', line 10 def initialize(app, _env, retry_interval = 3) @app = app @logger = Log4r::Logger.new('vagrant_openstack::action::stop_server') @retry_interval = retry_interval end |
Instance Method Details
#execute(env) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/vagrant-openstack-illuin-provider/action/wait_stop.rb', line 16 def execute(env) if env[:machine].id env[:ui].info(I18n.t('vagrant_openstack.waiting_stop')) client = env[:openstack_client].nova config = env[:machine].provider_config Timeout.timeout(config.server_stop_timeout, Errors::Timeout) do while client.get_server_details(env, env[:machine].id)['status'] != 'SHUTOFF' sleep @retry_interval @logger.info('Waiting for server to stop') end end end @app.call(env) end |