# File lib/blimpy/boxes/openstack.rb, line 98 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 108 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 131 def deallocate_ip fog.release_address(floating_ip.id) end
# File lib/blimpy/boxes/openstack.rb, line 127 def disassociate_ip fog.disassociate_address(@server.id, floating_ip.address) end
# File lib/blimpy/boxes/openstack.rb, line 55 def dns if floating_ip.nil? 'unavailable' else floating_ip.address end end
# File lib/blimpy/boxes/openstack.rb, line 87 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 83 def flavors @flavors ||= fog.flavors end
# File lib/blimpy/boxes/openstack.rb, line 77 def fog @fog ||= begin Fog::Compute.new(:provider => 'openstack', :openstack_tenant => @region) end end
# File lib/blimpy/boxes/openstack.rb, line 63 def internal_dns 'unavailable' end
# File lib/blimpy/boxes/openstack.rb, line 36 def ports=(new_pors) raise Blimpy::UnsupportedFeatureException, 'Opening arbitrary ports in OpenStack is currently not supported' end
# File lib/blimpy/boxes/openstack.rb, line 123 def postdestroy deallocate_ip unless floating_ip.nil? end
# File lib/blimpy/boxes/openstack.rb, line 119 def predestroy disassociate_ip unless floating_ip.nil? end
# File lib/blimpy/boxes/openstack.rb, line 94 def prestart allocate_ip end
# File lib/blimpy/boxes/openstack.rb, line 51 def serializable_attributes super + [:floating_ip] end
# File lib/blimpy/boxes/openstack.rb, line 67 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 40 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.