1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

add additional attributes to network

This commit is contained in:
Dan Peterson 2010-11-17 14:04:32 -04:00
parent 45f40f807f
commit f910a65341
4 changed files with 31 additions and 11 deletions

View file

@ -450,6 +450,18 @@ module Fog
def rnat
_parent.rnat
end
def type
self[:type] || "DMZ"
end
def vlan
object_id.to_s
end
def friendly_name
"#{name} (#{type}_#{object_id})"
end
end
class MockVirtualMachine < Base

View file

@ -18,6 +18,9 @@ module Fog
attribute :address, :aliases => :Address
attribute :rnat, :aliases => :RnatAddress
attribute :extension_href, :aliases => :Href
attribute :network_type, :aliases => :NetworkType
attribute :vlan, :aliases => :Vlan
attribute :friendly_name, :aliases => :FriendlyName
def ips
load_unless_loaded!

View file

@ -12,16 +12,18 @@ module Fog
def get_network_extensions(network_extension_uri)
if network_extension = mock_data.network_extension_from_href(ensure_unparsed(network_extension_uri))
xml = Builder::XmlMarkup.new
mock_it 200,
xml.Network(ecloud_xmlns) {
xml.Address network_extension.address
xml.RnatAddress network_extension.rnat
xml.Href network_extension.href
xml.Id network_extension.object_id
xml.Name network_extension.name
xml.GatewayAddress network_extension.gateway
xml.BroadcastAddress network_extension.broadcast
}, { 'Content-Type' => "application/vnd.tmrk.ecloud.network+xml" }
mock_it 200, xml.Network(ecloud_xmlns) {
xml.Address network_extension.address
xml.RnatAddress network_extension.rnat
xml.Href network_extension.href
xml.Id network_extension.object_id
xml.Name network_extension.name
xml.GatewayAddress network_extension.gateway
xml.BroadcastAddress network_extension.broadcast
xml.NetworkType network_extension.type
xml.Vlan network_extension.vlan
xml.FriendlyName network_extension.friendly_name
}, { 'Content-Type' => "application/vnd.tmrk.ecloud.network+xml" }
else
mock_error 200, "401 Unauthorized"
end

View file

@ -8,7 +8,7 @@ if Fog.mocking?
subject { Fog::Vcloud::Terremark::Ecloud::Network }
it { should have_identity :href }
it { should have_only_these_attributes [:href, :name, :features, :links, :type, :gateway, :broadcast, :address, :rnat, :extension_href] }
it { should have_only_these_attributes [:href, :name, :features, :links, :type, :gateway, :broadcast, :address, :rnat, :extension_href, :network_type, :vlan, :friendly_name] }
end
context "with no uri" do
@ -32,6 +32,9 @@ if Fog.mocking?
its(:address) { should == @mock_network.address }
its(:rnat) { should == @mock_network.rnat }
its(:extension_href) { should == @mock_network.extensions.href }
its(:network_type) { should == @mock_network.extensions.type }
its(:vlan) { should == @mock_network.extensions.vlan }
its(:friendly_name) { should == @mock_network.extensions.friendly_name }
it { should have(1).features }