Sha256: 3dcd5508131a34b3cea189d4cceb1af654308ea02594b98d48785bdf22afbaa3

Contents?: true

Size: 1019 Bytes

Versions: 7

Compression:

Stored size: 1019 Bytes

Contents

require 'log4r'
require 'timeout'

require 'vagrant-openstack-provider/action/abstract_action'

module VagrantPlugins
  module Openstack
    module Action
      class WaitForServerToStop < AbstractAction
        def initialize(app, _env, retry_interval = 3)
          @app    = app
          @logger = Log4r::Logger.new('vagrant_openstack::action::stop_server')
          @retry_interval = retry_interval
        end

        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
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
vagrant-openstack-provider-0.13.0 lib/vagrant-openstack-provider/action/wait_stop.rb
vagrant-openstack-provider-0.12.0 lib/vagrant-openstack-provider/action/wait_stop.rb
vagrant-openstack-provider-illuin-0.11.1 lib/vagrant-openstack-provider/action/wait_stop.rb
vagrant-openstack-provider-0.11.0 lib/vagrant-openstack-provider/action/wait_stop.rb
vagrant-openstack-provider-0.10.0 lib/vagrant-openstack-provider/action/wait_stop.rb
vagrant-openstack-provider-0.9.0 lib/vagrant-openstack-provider/action/wait_stop.rb
vagrant-openstack-provider-0.8.0 lib/vagrant-openstack-provider/action/wait_stop.rb