Sha256: fefa23c8b76966c9fdd7993aed64379d8b3b01688288e274a5526ec78f427ca3

Contents?: true

Size: 1016 Bytes

Versions: 4

Compression:

Stored size: 1016 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.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

4 entries across 4 versions & 1 rubygems

Version Path
vagrant-conoha-0.1.10 lib/vagrant-conoha/action/wait_active.rb
vagrant-conoha-0.1.9 lib/vagrant-conoha/action/wait_active.rb
vagrant-conoha-0.1.8 lib/vagrant-conoha/action/wait_active.rb
vagrant-conoha-0.1.7 lib/vagrant-conoha/action/wait_active.rb