Sha256: cdad85f7c6157f13a97ed2b9275312d01b4c125598b325d478dc076d748c1180

Contents?: true

Size: 1008 Bytes

Versions: 7

Compression:

Stored size: 1008 Bytes

Contents

require 'log4r'
require 'timeout'

require 'vagrant-conoha/action/abstract_action'

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

        def execute(env)
          if env[:machine].id
            env[:ui].info(I18n.t('vagrant_openstack.waiting_start'))
            client = env[:openstack_client].nova
            config = env[:machine].provider_config
            timeout(config.server_active_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

7 entries across 7 versions & 1 rubygems

Version Path
vagrant-conoha-0.1.6 lib/vagrant-conoha/action/wait_active.rb
vagrant-conoha-0.1.5 lib/vagrant-conoha/action/wait_active.rb
vagrant-conoha-0.1.4 lib/vagrant-conoha/action/wait_active.rb
vagrant-conoha-0.1.3 lib/vagrant-conoha/action/wait_active.rb
vagrant-conoha-0.1.2 lib/vagrant-conoha/action/wait_active.rb
vagrant-conoha-0.1.1 lib/vagrant-conoha/action/wait_active.rb
vagrant-conoha-0.1.0 lib/vagrant-conoha/action/wait_active.rb