Method: OpenStack::Compute::Connection#attach_floating_ip

Defined in:
lib/openstack/compute/connection.rb

#attach_floating_ip(opts = {:server_id=>"", :ip_id => ""}) ⇒ Object

add or attach a floating IP to a runnin g server



495
496
497
498
499
500
501
502
# File 'lib/openstack/compute/connection.rb', line 495

def attach_floating_ip(opts={:server_id=>"", :ip_id => ""})
  check_extension("os-floating-ips")
  #first get the address:
  addr = get_floating_ip(opts[:ip_id]).ip
  data = JSON.generate({:addFloatingIp=>{:address=>addr}})
  @connection.req("POST", "/servers/#{opts[:server_id]}/action", {:data=>data})
  true
end