module BuildCloud::Component::InstanceMethods
Public Instance Methods
[](key)
click to toggle source
# File lib/build-cloud/component.rb, line 13 def [](key) @options[key] end
exists?()
click to toggle source
# File lib/build-cloud/component.rb, line 21 def exists? !read.nil? end
has_key?(key)
click to toggle source
# File lib/build-cloud/component.rb, line 17 def has_key?(key) @options.has_key?(key) end
ready_timeout()
click to toggle source
# File lib/build-cloud/component.rb, line 25 def ready_timeout 30 end
require_one_of( *required )
click to toggle source
# File lib/build-cloud/component.rb, line 79 def require_one_of( *required ) cn = self.class.name.split('::').last intersection = @options.keys & required if intersection.length != 1 raise "#{cn} requires only one of #{required.join(', ')}" end end
required_options( *required )
click to toggle source
# File lib/build-cloud/component.rb, line 64 def required_options( *required ) cn = self.class.name.split('::').last missing = [] required.each do |o| missing << o unless @options.has_key?(o) end if missing.length > 0 raise "#{cn} requires missing #{missing.join(', ')} option#{missing.length > 1 ? 's' : ''}" end end
to_s()
click to toggle source
# File lib/build-cloud/component.rb, line 92 def to_s return @options.to_yaml end
wait_until_ready()
click to toggle source
# File lib/build-cloud/component.rb, line 29 def wait_until_ready unless read.class.method_defined?(:ready?) @log.debug("Can't wait for readiness on #{read.class.to_s}") return end timeout = ready_timeout # default from this superclass wait_timer = 1 start_time = Time.now.to_i begin if fog_object.ready? @log.info("Object ready") return true end @log.debug("Object not yet ready. Sleeping #{wait_timer}s") sleep( wait_timer ) if wait_timer < 60 wait_timer *= 2 end time_diff = Time.now.to_i - start_time end while time_diff < timeout @log.error("Timed out after #{timeout} waiting for #{read.class}") end