2011-08-10 09:03:51 -04:00
|
|
|
require 'fog/core/collection'
|
2011-09-08 17:07:04 -04:00
|
|
|
require 'fog/glesys/models/compute/ip'
|
2011-08-10 09:03:51 -04:00
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class Glesys
|
|
|
|
|
|
|
|
class Ips < Fog::Collection
|
|
|
|
|
|
|
|
model Fog::Glesys::Compute::Ip
|
|
|
|
|
|
|
|
attribute :serverid
|
|
|
|
|
|
|
|
def all
|
2012-12-22 18:27:08 -05:00
|
|
|
data = service.ip_list_own.body['response']['iplist']
|
2011-08-10 09:03:51 -04:00
|
|
|
load(data)
|
|
|
|
end
|
|
|
|
|
|
|
|
def get(identifier)
|
|
|
|
return nil if identifier.nil? || identifier == ""
|
|
|
|
|
2012-12-22 18:27:08 -05:00
|
|
|
self.new( :serverid => identifier )
|
|
|
|
|
|
|
|
data = service.ip_list_own(:serverid => identifier).body['response']
|
2011-08-10 09:03:51 -04:00
|
|
|
if data['iplist'].empty?
|
2012-12-22 18:27:08 -05:00
|
|
|
nil
|
2011-08-10 09:03:51 -04:00
|
|
|
else
|
|
|
|
new(data['iplist'].first)
|
2012-12-22 18:27:08 -05:00
|
|
|
end
|
|
|
|
end
|
2011-08-10 09:03:51 -04:00
|
|
|
|
|
|
|
def new(attributes = {})
|
|
|
|
super({ :serverid => serverid }.merge!(attributes))
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|