mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Add fence_mode to network model
fence_mode can be 'isolated' (disconnected from EdgeGateway) or 'natRouted' (connected to NatService on EdgeGateway). The network types differ significantly enough to have a separate set of tests, to be expanded later.
This commit is contained in:
parent
5007aac401
commit
cb9802b239
3 changed files with 25 additions and 11 deletions
|
@ -13,6 +13,7 @@ module Fog
|
|||
attribute :href
|
||||
attribute :description
|
||||
attribute :is_inherited
|
||||
attribute :fence_mode
|
||||
attribute :gateway
|
||||
attribute :netmask
|
||||
attribute :dns1
|
||||
|
|
|
@ -20,7 +20,9 @@ module Fog
|
|||
service.add_id_from_href!(data)
|
||||
data[:name] = raw_network[:name]
|
||||
data[:description] = raw_network[:Description]
|
||||
ip_scope = raw_network[:Configuration][:IpScopes][:IpScope]
|
||||
net_config = raw_network[:Configuration]
|
||||
data[:fence_mode] = net_config[:FenceMode]
|
||||
ip_scope = net_config[:IpScopes][:IpScope]
|
||||
data[:is_inherited] = ip_scope[:IsInherited]
|
||||
data[:gateway] = ip_scope[:Gateway]
|
||||
data[:netmask] = ip_scope[:Netmask]
|
||||
|
|
|
@ -10,19 +10,15 @@ Shindo.tests("Compute::VcloudDirector | networks", ['vclouddirector', 'all']) do
|
|||
networks = organization.networks
|
||||
network_raw = nil
|
||||
|
||||
# Find a network that at least has a gateway element, so
|
||||
# we can explicitly test lazy loading on it, and also so
|
||||
# we stand a greater chance of having other fields populated.
|
||||
# Run initial tests against a natRouted network, since these
|
||||
# are more likely to be created, and must be populated with
|
||||
# Gateway and EdgeGateway sections
|
||||
network = networks.detect do |net|
|
||||
network_raw = service.get_network_complete(net.id).body
|
||||
begin
|
||||
network_raw[:Configuration][:IpScopes][:IpScope][:Gateway].class == String
|
||||
rescue
|
||||
false
|
||||
end
|
||||
network_raw[:Configuration][:FenceMode] == 'natRouted'
|
||||
end
|
||||
|
||||
# We don't have a sufficiently populated network to test against
|
||||
# We don't have a sufficiently populated natRouted network to test against
|
||||
pending if network_raw.nil?
|
||||
|
||||
UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
|
||||
|
@ -35,7 +31,6 @@ Shindo.tests("Compute::VcloudDirector | networks", ['vclouddirector', 'all']) do
|
|||
tests("#type").returns("application/vnd.vmware.vcloud.orgNetwork+xml"){ network.type }
|
||||
end
|
||||
|
||||
|
||||
tests("Compute::VcloudDirector | network", ['lazy load attrs']) do
|
||||
network.lazy_load_attrs.each do |lazy_attr|
|
||||
tests("##{lazy_attr} is not loaded yet").returns(NonLoaded) { network.attributes[lazy_attr] }
|
||||
|
@ -71,4 +66,20 @@ Shindo.tests("Compute::VcloudDirector | networks", ['vclouddirector', 'all']) do
|
|||
tests("#get").returns(network.id) { networks.get(network.id).id }
|
||||
end
|
||||
|
||||
# Now let's also check against an isolated network, since these have some
|
||||
# additional features like DHCP ServiceConfigurations.
|
||||
isolated_network_raw = nil
|
||||
isolated_network = networks.detect do |net|
|
||||
isolated_network_raw = service.get_network_complete(net.id).body
|
||||
isolated_network_raw[:Configuration][:FenceMode] == 'isolated'
|
||||
end
|
||||
|
||||
pending if isolated_network_raw.nil?
|
||||
|
||||
tests("Compute::VcloudDirector | isolated network", ['load on demand']) do
|
||||
tests("#fence_mode is not loaded yet").returns(NonLoaded) { isolated_network.attributes[:fence_mode] }
|
||||
tests("#fence_mode is loaded on demand").returns('isolated') { isolated_network.fence_mode }
|
||||
tests("#fence_mode is now loaded").returns(true) { isolated_network.attributes[:fence_mode] != NonLoaded }
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue