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:
parent
7c7d76abcc
commit
f6575a9a4d
1 changed files with 17 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue