1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[Glesys] Add public_ip_method to server model

This commit is contained in:
Simon Gate 2013-01-27 12:52:16 +01:00
parent 7c7d76abcc
commit f6575a9a4d

View file

@ -74,6 +74,23 @@ module Fog
data.status == 200 ? true : false
end
def public_ip_address(options = {})
type = options[:type] || nil
ips = case type
when :ipv4 then iplist.select { |ip| ip["version"] == 4 }
when :ipv6 then iplist.select { |ip| ip["version"] == 6 }
else iplist.sort_by { |ip| ip["version"] }
end
if ips.empty?
nil
else
ips.first["ipaddress"]
end
end
end
end
end