Sha256: 5570c72e7a9982f9d2f23247b69e594275bebabaa9611e7f0527d520f192cc86

Contents?: true

Size: 898 Bytes

Versions: 3

Compression:

Stored size: 898 Bytes

Contents

require 'log4r'
require 'timeout'

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

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