Skip to content
This repository was archived by the owner on Nov 12, 2021. It is now read-only.

Floating IPs

marmeladze edited this page Apr 13, 2018 · 2 revisions

List all floating IPs

irb(main):003:0> nova.get_floating_ips
=> [#<OpenStack::Compute::FloatingIPAddress:0x000000031d07b0 @fixed_ip=nil, @id=3714, @instance_id=nil, @ip="15.185.110.129", @pool=nil>, #<OpenStack::Compute::FloatingIPAddress:0x00000003210478 @fixed_ip=nil, @id=4034, @instance_id=nil, @ip="15.185.111.193", @pool=nil>]

Get a specific floating IP:

irb(main):004:0> nova.get_floating_ip(4034)
=> #<OpenStack::Compute::FloatingIPAddress:0x00000002349958 @fixed_ip=nil, @id=4034, @instance_id=nil, @ip="15.185.111.193", @pool=nil>

Create floating IP - optionally specifying 'pool' as {:pool=>"foo"}

irb(main):003:0> addr = nova.create_floating_ip
=> #<OpenStack::Compute::FloatingIPAddress:0x00000001882c68 @fixed_ip=nil, @id=3932, @instance_id=nil, @ip="15.185.111.91", @pool=nil>

Delete a floating IP by ID:

irb(main):004:0> nova.delete_floating_ip(addr.id)
=> true

Attach floating IP to running server - hash param speciried :server_id and :ip_id

irb(main):014:0> nova.attach_floating_ip({:server_id=>"73c12492-e966-4af0-a5e9-b5d1e436fe61", :ip_id=>"3932"})
=> true

Detach floating IP from server - hash param as above for attach

irb(main):014:0> nova.detach_floating_ip({:server_id=>"73c12492-e966-4af0-a5e9-b5d1e436fe61", :ip_id=>"3932"})
  => true
Clone this wiki locally