Skip to content

Instantly share code, notes, and snippets.

@bodepd
Created August 9, 2013 02:34
Show Gist options
  • Select an option

  • Save bodepd/6190728 to your computer and use it in GitHub Desktop.

Select an option

Save bodepd/6190728 to your computer and use it in GitHub Desktop.
addresses = server.addresses
host = addresses[config.public_network_name].last['addr'] rescue nil
unless host
floating_ips = []
addresses.each do |net_name, addresses|
Array(addresses).each do |address|
# is OS-EXT-IPS:type part of the API?
floating_ips.push(address['addr']) if address['OS-EXT-IPS:type'] == 'floating'
end
#raise(Exception, 'Did not find any floating ip addresses, cannot login') if floating_ips.size == 0
#raise(Exception, 'Found more than one floating ip address, confused and failing') if floating_ips.size > 1
host = floating_ips.last
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment