Sha256: b63baeaec3ee351bb91ef1cded8c202268cd40f4b7d6a2e42a283868e3f8b888

Contents?: true

Size: 996 Bytes

Versions: 1

Compression:

Stored size: 996 Bytes

Contents

require 'log4r'
require 'timeout'

require 'vagrant-openstack-provider/action/abstract_action'

module VagrantPlugins
  module Openstack
    module Action
      class WaitForServerToBeActive < AbstractAction
        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 execute(env)
          if env[:machine].id
            env[:ui].info(I18n.t('vagrant_openstack.waiting_start'))
            client = env[:openstack_client].nova
            timeout(@timeout, Errors::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

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-openstack-provider-0.6.0 lib/vagrant-openstack-provider/action/wait_active.rb