Sha256: 8bd4e0e075f41e99a9e214ccf63a4d17ee62e9bbcd830c140a2800cf98298dc0

Contents?: true

Size: 772 Bytes

Versions: 6

Compression:

Stored size: 772 Bytes

Contents

require 'log4r'
require 'timeout'

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

        def call(env)
          if env[:machine].id
            env[:ui].info(I18n.t('vagrant_openstack.waiting_start'))
            client = env[:openstack_client].nova
            timeout(200) do
              while client.get_server_details(env, env[:machine].id)['status'] != 'ACTIVE'
                sleep 3
                @logger.info('Waiting for server to be active')
              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_active.rb
vagrant-openstack-provider-0.4.0 lib/vagrant-openstack-provider/action/wait_active.rb
vagrant-openstack-provider-0.3.4.pre lib/vagrant-openstack-provider/action/wait_active.rb
vagrant-openstack-provider-0.3.3 lib/vagrant-openstack-provider/action/wait_active.rb
vagrant-openstack-provider-0.3.2 lib/vagrant-openstack-provider/action/wait_active.rb
vagrant-openstack-provider-0.3.0 lib/vagrant-openstack-provider/action/wait_active.rb