Sha256: 7d8414a4869ac78bfc45b6110c4a3247f45068077f77f18bf49608d0abf8c968

Contents?: true

Size: 1011 Bytes

Versions: 4

Compression:

Stored size: 1011 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(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

4 entries across 4 versions & 1 rubygems

Version Path
vagrant-openstack-provider-0.7.2 lib/vagrant-openstack-provider/action/wait_stop.rb
vagrant-openstack-provider-0.7.1 lib/vagrant-openstack-provider/action/wait_stop.rb
vagrant-openstack-provider-0.7.0 lib/vagrant-openstack-provider/action/wait_stop.rb
vagrant-openstack-provider-0.6.1 lib/vagrant-openstack-provider/action/wait_stop.rb