Class: Forger::Waiter::Ami
- Includes:
- AwsServices
- Defined in:
- lib/forger/waiter/ami.rb
Constant Summary
Constants inherited from Base
Base::BUILD_ROOT, Base::SCRIPTS_INFO_PATH
Instance Method Summary collapse
Methods included from AwsServices
Methods inherited from Base
#derandomize, #initialize, #randomize
Constructor Details
This class inherits a constructor from Forger::Base
Instance Method Details
#wait ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/forger/waiter/ami.rb', line 5 def wait delay = 30 timeout = @options[:timeout] max_attempts = timeout / delay current_time = 0 puts "Waiting for #{@options[:name]} to be available. Delay: #{delay}s. Timeout: #{timeout}s" puts "Current time: #{Time.now}" return if ENV['TEST'] # Using while loop because of issues with ruby's Timeout module # http://www.mikeperham.com/2015/05/08/timeout-rubys-most-dangerous-api/ detected = detect_ami until detected || current_time > timeout print '.' sleep delay current_time += 30 detected = detect_ami end puts if current_time > timeout puts "ERROR: Timeout. Unable to detect and available ami: #{@options[:name]}" exit 1 else puts "Found available AMI: #{@options[:name]}" end end |