Sha256: ed51c23eb694debb65f6fc1314a001aaa464606bd0fcc232cf16c523ba6ebc64

Contents?: true

Size: 762 Bytes

Versions: 6

Compression:

Stored size: 762 Bytes

Contents

require 'log4r'
require 'timeout'

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

        def call(env)
          if env[:machine].id
            env[:ui].info(I18n.t('vagrant_openstack.waiting_stop'))
            client = env[:openstack_client].nova
            timeout(200) do
              while client.get_server_details(env, env[:machine].id)['status'] != 'SHUTOFF'
                sleep 3
                @logger.info('Waiting for server to stop')
              end
            end
          end
          @app.call(env)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
vagrant-openstack-provider-0.4.1 lib/vagrant-openstack-provider/action/wait_stop.rb
vagrant-openstack-provider-0.4.0 lib/vagrant-openstack-provider/action/wait_stop.rb
vagrant-openstack-provider-0.3.4.pre lib/vagrant-openstack-provider/action/wait_stop.rb
vagrant-openstack-provider-0.3.3 lib/vagrant-openstack-provider/action/wait_stop.rb
vagrant-openstack-provider-0.3.2 lib/vagrant-openstack-provider/action/wait_stop.rb
vagrant-openstack-provider-0.3.0 lib/vagrant-openstack-provider/action/wait_stop.rb