From 640dbd4c71bc6fdc44edeb191e6d80aa2b1e80fe Mon Sep 17 00:00:00 2001 From: Erik Mackdanz Date: Mon, 24 Feb 2014 10:44:43 -0600 Subject: [PATCH] sort array to avoid extraneous arrays --- lib/fog/openstack/models/compute/server.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/fog/openstack/models/compute/server.rb b/lib/fog/openstack/models/compute/server.rb index 28b4d7c79..36fb98581 100644 --- a/lib/fog/openstack/models/compute/server.rb +++ b/lib/fog/openstack/models/compute/server.rb @@ -123,7 +123,18 @@ module Fog # Return them all, leading with manually assigned addresses manual = all_addresses.map{|addr| addr["ip"]} - manual + ( all_floating - manual ) + + all_floating.sort{ |a,b| + a_manual = manual.include? a + b_manual = manual.include? b + + if a_manual and !b_manual + -1 + elsif !a_manual and b_manual + 1 + else 0 end + } + end alias_method :public_ip_addresses, :floating_ip_addresses