diff --git a/lib/fog/vcloud/models/compute/network.rb b/lib/fog/vcloud/models/compute/network.rb index 47706f9aa..d2e56bdc4 100644 --- a/lib/fog/vcloud/models/compute/network.rb +++ b/lib/fog/vcloud/models/compute/network.rb @@ -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 diff --git a/tests/vcloud/models/compute/network_tests.rb b/tests/vcloud/models/compute/network_tests.rb index 469a2ef02..ed1950a7d 100644 --- a/tests/vcloud/models/compute/network_tests.rb +++ b/tests/vcloud/models/compute/network_tests.rb @@ -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