From 9025db5df67457990863471863be5f036e749be2 Mon Sep 17 00:00:00 2001 From: Terry Howe Date: Mon, 7 Oct 2013 14:42:30 -0600 Subject: [PATCH] changes to make old ips work better and activate network for HP --- lib/fog/hp/models/compute/server.rb | 42 ++++++++++++++++++----------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/lib/fog/hp/models/compute/server.rb b/lib/fog/hp/models/compute/server.rb index 42d6ac89c..c7bdb29d3 100644 --- a/lib/fog/hp/models/compute/server.rb +++ b/lib/fog/hp/models/compute/server.rb @@ -100,9 +100,18 @@ module Fog @network_name ||= "private" end + def private_ip_addresses + return nil if addresses.nil? + addr = [] + addresses.each { |key, value| + ipaddr = value.first + addr << ipaddr["addr"] unless ipaddr.nil? + } + addr + end + def private_ip_address - addr = addresses.nil? ? nil : addresses.fetch(network_name, []).first - addr["addr"] if addr + private_ip_addresses.first end def private_key_path @@ -114,20 +123,23 @@ module Fog @private_key ||= private_key_path && File.read(private_key_path) end - def public_ip_address - # FIX: Both the private and public ips are bundled under "private" network name - # So hack to get to the public ip address - if !addresses.nil? - addr = addresses.fetch(network_name, []) - # if we have more than 1 address, then the return the second address which is public - if addr.count > 1 - addr[1]["addr"] - else - nil + def public_ip_addresses + return nil if addresses.nil? + addr = [] + addresses.each { |key, value| + if value.count > 1 + value = value.dup + value.delete_at(0) + value.each { |ipaddr| + addr << ipaddr["addr"] + } end - else - nil - end + } + addr + end + + def public_ip_address + public_ip_addresses.first end def public_key_path