mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
changes to make old ips work better and activate network for HP
This commit is contained in:
parent
c1e60efcbd
commit
9025db5df6
1 changed files with 27 additions and 15 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue