1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/vcloud/terremark/ecloud/models/network.rb

78 lines
2.1 KiB
Ruby
Raw Normal View History

2010-06-10 07:20:14 +08:00
module Fog
class Vcloud
2010-06-10 07:20:14 +08:00
module Terremark
class Ecloud
2010-06-10 07:20:14 +08:00
class Network < Fog::Vcloud::Model
identity :href
ignore_attributes :xmlns, :xmlns_xsi, :xmlns_xsd, :xmlns_i, :Configuration, :Id
attribute :name, :aliases => :Name
#attribute :id, :aliases => :Id
attribute :features, :aliases => :Features, :type => :array
attribute :links, :aliases => :Link, :type => :array
2010-06-10 07:20:14 +08:00
attribute :type
attribute :gateway, :aliases => :GatewayAddress
attribute :broadcast, :aliases => :BroadcastAddress
attribute :address, :aliases => :Address
attribute :rnat, :aliases => :RnatAddress
attribute :extension_href, :aliases => :Href
2010-11-17 14:04:32 -04:00
attribute :network_type, :aliases => :NetworkType
attribute :vlan, :aliases => :Vlan
attribute :friendly_name, :aliases => :FriendlyName
2010-06-10 07:20:14 +08:00
def ips
load_unless_loaded!
2010-06-10 07:20:14 +08:00
@ips ||= Fog::Vcloud::Terremark::Ecloud::Ips.
new( :connection => connection,
:href => links.detect { |link| link[:name] == "IP Addresses" }[:href] )
end
def rnat=(new_rnat)
2010-11-29 13:24:44 -04:00
attributes[:rnat] = new_rnat
@changed = true
end
def save
if @changed
connection.configure_network( extension_href, _compose_network_data )
end
true
end
def reload
super
merge_attributes(extension_data.body)
self
end
private
def extension_data
connection.get_network_extensions( extensions_link[:href] )
end
def extensions_link
links.detect { |link| link[:name] == name }
end
def _compose_network_data
{
:id => id,
:href => extension_href,
:name => name,
:rnat => rnat,
:address => address,
:broadcast => broadcast,
:gateway => gateway
}
2010-06-10 07:20:14 +08:00
end
end
end
end
end
end