From 3bbc7997487c74cd9813c3d9a3e3ed56db1f0114 Mon Sep 17 00:00:00 2001 From: Rupak Ganguly Date: Thu, 30 May 2013 15:39:29 -0400 Subject: [PATCH] Add a helper method for network_names. Also, update network_name methdo to set itself to the first network with a public ip address by default. --- lib/fog/hp/models/compute_v2/server.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/fog/hp/models/compute_v2/server.rb b/lib/fog/hp/models/compute_v2/server.rb index f4e820986..253be1f6a 100644 --- a/lib/fog/hp/models/compute_v2/server.rb +++ b/lib/fog/hp/models/compute_v2/server.rb @@ -101,7 +101,12 @@ module Fog end def network_name - @network_name ||= 'hpcloud' + @network_name ||= get_first_network_with_public_ip + end + + # derive the network names from the addresses hash + def network_names + self.addresses.keys unless self.addresses.nil? end def private_ip_address @@ -290,6 +295,11 @@ module Fog @password = new_admin_pass end + def get_first_network_with_public_ip + net = self.addresses.select {|_,v| v.count > 1} + net.keys.first + end + end end