# File lib/blimpy/boxes/openstack.rb, line 99 def allocate_ip response = fog.allocate_address unless response.status == 200 raise Blimpy::UnknownError, "Blimpy was unable to allocate a floating IP address; #{response.inspect}" end details = response.body['floating_ip'] @floating_ip = FloatingIp.new(details['ip'], details['id']) end
# File lib/blimpy/boxes/openstack.rb, line 109 def associate_ip if floating_ip.nil? raise Blimpy::UnknownError, "Blimpy cannot associate a floating IP until it's been allocated properly!" end response = fog.associate_address(@server.id, floating_ip.address) unless response.status == 202 raise Blimpy::UnknownError, "Blimpy failed to associate the IP somehow #{response.inspect}" end end
# File lib/blimpy/boxes/openstack.rb, line 132 def deallocate_ip fog.release_address(floating_ip.id) end
# File lib/blimpy/boxes/openstack.rb, line 128 def disassociate_ip fog.disassociate_address(@server.id, floating_ip.address) end
# File lib/blimpy/boxes/openstack.rb, line 56 def dns if floating_ip.nil? 'unavailable' else floating_ip.address end end
# File lib/blimpy/boxes/openstack.rb, line 88 def flavor_id(name) flavors.each do |flavor| return flavor.id if flavor.name == name end nil end
# File lib/blimpy/boxes/openstack.rb, line 84 def flavors @flavors ||= fog.flavors end
# File lib/blimpy/boxes/openstack.rb, line 78 def fog @fog ||= begin Fog::Compute.new(:provider => 'openstack', :openstack_tenant => @region) end end
# File lib/blimpy/boxes/openstack.rb, line 64 def internal_dns 'unavailable' end
# File lib/blimpy/boxes/openstack.rb, line 37 def ports=(new_pors) raise Blimpy::UnsupportedFeatureException, 'Opening arbitrary ports in OpenStack is currently not supported' end
# File lib/blimpy/boxes/openstack.rb, line 124 def postdestroy deallocate_ip unless floating_ip.nil? end
# File lib/blimpy/boxes/openstack.rb, line 120 def predestroy disassociate_ip unless floating_ip.nil? end
# File lib/blimpy/boxes/openstack.rb, line 95 def prestart allocate_ip end
# File lib/blimpy/boxes/openstack.rb, line 52 def serializable_attributes super + [:floating_ip] end
# File lib/blimpy/boxes/openstack.rb, line 68 def validate! if @region.nil? raise Blimpy::BoxValidationError, "Cannot spin up machine without a set region" end if flavor_id(@flavor).nil? raise Blimpy::BoxValidationError, "'#{@flavor}' is not a valid OpenStack tenant name" end end
# File lib/blimpy/boxes/openstack.rb, line 41 def wait_for_state(until_state, &block) until @server.ready? sleep 1 @server.reload end # OpenStack doesn't seem to like it if you try to associate the IP # address too early, but will properly associate it after the machine is # ready associate_ip end
Generated with the Darkfish Rdoc Generator 2.