Class: VagrantPlugins::ProviderZone::Action::WaitTillUp

Inherits:
Object
  • Object
show all
Includes:
Vagrant::Util::Retryable
Defined in:
lib/vagrant-zone/action/wait_till_up.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ WaitTillUp

Returns a new instance of WaitTillUp.



11
12
13
14
# File 'lib/vagrant-zone/action/wait_till_up.rb', line 11

def initialize(app, env)
	@logger = Log4r::Logger.new("vagrant_zone::action::import")
	@app = app
end

Instance Method Details

#call(env) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/vagrant-zone/action/wait_till_up.rb', line 16

def call(env)
	@machine = env[:machine]
	@driver  = @machine.provider.driver

	# Initialize metrics if they haven't been
	env[:metrics] ||= {}

	env[:metrics]['instance_ssh_time'] = Util::Timer.time do
		retryable(on: Errors::TimeoutError, tries: 60) do
			# If we're interrupted don't worry about waiting
			next if env[:interrupted]
			loop do
				break if env[:interrupted]
				break if env[:machine].communicate.ready?
			end
		end
	end
	# if interrupted above, just terminate immediately
	return terminate(env) if env[:interrupted]
	@logger.info("Time for SSH ready: #{env[:metrics]['instance_ssh_time']}")

	@app.call(env)
end