Sha256: f4ac0baac0e491222d4cd0fe72ac3c3704ea31930cf21f997ee0bfcb4490b59e

Contents?: true

Size: 888 Bytes

Versions: 3

Compression:

Stored size: 888 Bytes

Contents

require 'log4r'
require 'timeout'

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

        def call(env)
          if env[:machine].id
            env[:ui].info(I18n.t('vagrant_openstack.waiting_stop'))
            client = env[:openstack_client].nova
            timeout(@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

3 entries across 3 versions & 1 rubygems

Version Path
vagrant-openstack-provider-0.5.2 lib/vagrant-openstack-provider/action/wait_stop.rb
vagrant-openstack-provider-0.5.1 lib/vagrant-openstack-provider/action/wait_stop.rb
vagrant-openstack-provider-0.5.0 lib/vagrant-openstack-provider/action/wait_stop.rb