2011-08-24 21:29:14 -04:00
|
|
|
require 'fog/ecloud/models/compute/public_ip'
|
2011-02-17 13:44:46 -05:00
|
|
|
|
|
|
|
module Fog
|
2011-06-16 19:28:54 -04:00
|
|
|
module Compute
|
|
|
|
class Ecloud
|
2011-02-17 13:44:46 -05:00
|
|
|
class PublicIps < Fog::Ecloud::Collection
|
|
|
|
|
2012-06-07 12:50:11 -04:00
|
|
|
identity :href
|
2011-02-17 13:44:46 -05:00
|
|
|
|
2011-06-20 18:00:48 -04:00
|
|
|
model Fog::Compute::Ecloud::PublicIp
|
2011-02-17 13:44:46 -05:00
|
|
|
|
|
|
|
def all
|
2012-12-22 18:27:38 -05:00
|
|
|
data = service.get_public_ips(href).body
|
2012-06-07 12:50:11 -04:00
|
|
|
data = data[:PublicIp] ? data[:PublicIp] : data
|
|
|
|
load(data)
|
2011-02-17 13:44:46 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def get(uri)
|
2012-12-22 18:27:38 -05:00
|
|
|
data = service.get_public_ip(uri).body
|
2012-11-27 19:57:16 -05:00
|
|
|
if data == ""
|
|
|
|
new({})
|
|
|
|
else
|
|
|
|
new(data)
|
2011-02-17 13:44:46 -05:00
|
|
|
end
|
|
|
|
rescue Fog::Errors::NotFound
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
2012-06-07 12:50:11 -04:00
|
|
|
def activate
|
2012-12-22 18:27:38 -05:00
|
|
|
data = service.public_ip_activate(href + "/action/activatePublicIp").body
|
|
|
|
ip = Fog::Compute::Ecloud::PublicIps.new(:service => service, :href => data[:href])[0]
|
2012-06-07 12:50:11 -04:00
|
|
|
end
|
2011-02-17 13:44:46 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|