[vcloud|compute] introduce link on a network to parent network

Get the parent network object or nil if no parent network is defined.
This commit is contained in:
Peter Meier 2011-10-19 10:05:14 +02:00
parent 734c94f9f9
commit d4a1fa3a1e
2 changed files with 13 additions and 1 deletions

View File

@ -15,6 +15,14 @@ module Fog
attribute :links, :aliases => :Link, :type => :array
def parent_network
return nil if configuration[:ParentNetwork].nil?
@parent_network ||= Fog::Vcloud::Compute::Network.new(
:connection => connection,
:collection => Fog::Vcloud::Compute::Networks.new(:connection => connection),
:href => configuration[:ParentNetwork][:href]
)
end
end
end
end

View File

@ -37,7 +37,9 @@ Shindo.tests("Vcloud::Compute | network", ['vcloud']) do
end
end
tests("features")
tests("#parent_network") do
tests("returned network name").returns("ParentNetwork1"){ p = instance.parent_network; p.reload; p.name }
end
end
tests("an external network") do
@ -56,5 +58,7 @@ Shindo.tests("Vcloud::Compute | network", ['vcloud']) do
tests("dns").returns("172.0.0.2") { instance.configuration[:IpScope][:Dns1]}
tests("allocated addresses").returns("172.0.0.144") { instance.configuration[:IpScope][:AllocatedIpAddresses][:IpAddress].first }
end
tests("#parent_network").returns(nil){ instance.parent_network }
end
end