2012-06-07 12:50:11 -04:00
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class Ecloud
|
|
|
|
class IpAddress < Fog::Ecloud::Model
|
|
|
|
identity :href
|
|
|
|
|
|
|
|
attribute :name, :aliases => :Name
|
|
|
|
attribute :type, :aliases => :Type
|
2012-11-27 19:57:16 -05:00
|
|
|
attribute :other_links, :aliases => :Links, :squash => :Link
|
2012-06-07 12:50:11 -04:00
|
|
|
attribute :host, :aliases => :Host
|
|
|
|
attribute :detected_on, :aliases => :DetectedOn
|
|
|
|
attribute :rnat, :aliases => :RnatAddress
|
|
|
|
attribute :reserved, :aliases => :Reserved, :type => :boolean
|
|
|
|
|
|
|
|
def status
|
|
|
|
(detected_on || host) ? "Assigned" : "Available"
|
|
|
|
end
|
2012-11-27 19:57:16 -05:00
|
|
|
|
2012-06-07 12:50:11 -04:00
|
|
|
def id
|
2012-11-27 19:57:16 -05:00
|
|
|
href.match(/((\d+{1,3}\.){3}(\d+{1,3}))$/)[1]
|
|
|
|
end
|
|
|
|
|
|
|
|
def server
|
|
|
|
@server ||= begin
|
|
|
|
reload unless other_links
|
|
|
|
server_link = other_links.find{|l| l[:type] == "application/vnd.tmrk.cloud.virtualMachine"}
|
2013-01-11 16:06:58 -05:00
|
|
|
self.service.servers.get(server_link[:href])
|
2012-11-27 19:57:16 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def network
|
|
|
|
reload if other_links.nil?
|
|
|
|
network_href = other_links.detect { |l| l[:type] == "application/vnd.tmrk.cloud.network" }[:href]
|
2013-01-11 16:06:58 -05:00
|
|
|
network = self.service.networks.get(network_href)
|
2012-06-07 12:50:11 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|