mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Add (crap) Mock for get_network_config_section_vapp
To be improved soon, along with all vApp/Vm network Mocks
This commit is contained in:
parent
2e825d4228
commit
5c6df7ea5f
3 changed files with 69 additions and 40 deletions
|
@ -20,6 +20,71 @@ module Fog
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_network_config_section_vapp(id)
|
||||
|
||||
type = 'application/vnd.vmware.vcloud.networkConfigSection+xml'
|
||||
|
||||
unless vapp = data[:vapps][id]
|
||||
raise Fog::Compute::VcloudDirector::Forbidden.new(
|
||||
'This operation is denied.'
|
||||
)
|
||||
end
|
||||
|
||||
Excon::Response.new(
|
||||
:status => 200,
|
||||
:headers => {'Content-Type' => "#{type};version=#{api_version}"},
|
||||
:body => get_vapp_network_config_section_body(id, vapp)
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
def get_vapp_network_config_section_body(id, vapp)
|
||||
# TODO: This is effectively hardcoding a vAppNetwork configuration
|
||||
# into here, but this is sufficient for initial testing.
|
||||
# Soon we will update to allow for more realistic
|
||||
# configurations.
|
||||
{
|
||||
:type => "application/vnd.vmware.vcloud.networkConfigSection+xml",
|
||||
:href => make_href("vApp/#{id}/networkConfigSection/"),
|
||||
:ovf_required => "false",
|
||||
:"ovf:Info" => "The configuration parameters for logical networks",
|
||||
:NetworkConfig => {
|
||||
:networkName =>"mock-net-routed-1",
|
||||
:Description =>"",
|
||||
:Configuration => {
|
||||
:IpScopes => {
|
||||
:IpScope => {
|
||||
:IsInherited =>"true",
|
||||
:Gateway =>"10.10.10.1",
|
||||
:Netmask =>"255.255.255.0",
|
||||
:Dns1 =>"8.8.8.8",
|
||||
:Dns2 =>"8.8.4.4",
|
||||
:DnsSuffix => "testing.example.com",
|
||||
:IsEnabled => "true",
|
||||
:IpRanges => {
|
||||
:IpRange => [
|
||||
{:StartAddress=>"10.10.10.20", :EndAddress=>"10.10.10.49"},
|
||||
]
|
||||
},
|
||||
},
|
||||
},
|
||||
:ParentNetwork => {
|
||||
:name => "mock-net-routed-1",
|
||||
:id => vapp[:networks][0][:parent_id],
|
||||
:href => make_href("admin/network/#{vapp[:networks][0][:parent_id]}"),
|
||||
},
|
||||
:FenceMode => "bridged",
|
||||
:RetainNetInfoAcrossDeployments => "false",
|
||||
},
|
||||
:IsDeployed=>"true",
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -111,45 +111,6 @@ module Fog
|
|||
{}
|
||||
end
|
||||
|
||||
def get_vapp_network_config_section_body(id, vapp)
|
||||
{
|
||||
:type => "application/vnd.vmware.vcloud.networkConfigSection+xml",
|
||||
:href => make_href("vApp/#{id}/networkConfigSection/"),
|
||||
:ovf_required => "false",
|
||||
:"ovf:Info" => "The configuration parameters for logical networks",
|
||||
:NetworkConfig => {
|
||||
:networkName =>"mock-net-routed-1",
|
||||
:Description =>"",
|
||||
:Configuration => {
|
||||
:IpScopes => {
|
||||
:IpScope => {
|
||||
:IsInherited =>"true",
|
||||
:Gateway =>"10.10.10.1",
|
||||
:Netmask =>"255.255.255.0",
|
||||
:Dns1 =>"8.8.8.8",
|
||||
:Dns2 =>"8.8.4.4",
|
||||
:DnsSuffix => "testing.example.com",
|
||||
:IsEnabled => "true",
|
||||
:IpRanges => {
|
||||
:IpRange => [
|
||||
{:StartAddress=>"10.10.10.20", :EndAddress=>"10.10.10.49"},
|
||||
]
|
||||
},
|
||||
},
|
||||
},
|
||||
:ParentNetwork => {
|
||||
:name => "mock-net-routed-1",
|
||||
:id => vapp[:networks][0][:parent_id],
|
||||
:href => make_href("admin/network/#{vapp[:networks][0][:parent_id]}"),
|
||||
},
|
||||
:FenceMode => "bridged",
|
||||
:RetainNetInfoAcrossDeployments => "false",
|
||||
},
|
||||
:IsDeployed=>"true",
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
def get_vapp_children_vms_body(id)
|
||||
child_vms = data[:vms].select do |vm_id, vm_details|
|
||||
vm_details[:parent_vapp] == id
|
||||
|
|
|
@ -39,8 +39,11 @@ Shindo.tests('Compute::VcloudDirector | vapp requests', ['vclouddirector']) do
|
|||
Integer(@service.get_vapp(@vapp_id).body[:LeaseSettingsSection][:DeploymentLeaseInSeconds]) >= 0
|
||||
end
|
||||
|
||||
tests("#get_vapp(#{@vapp_id}).body[:NetworkConfigSection]").returns(Hash) do
|
||||
@service.get_vapp(@vapp_id).body[:NetworkConfigSection].class
|
||||
end
|
||||
|
||||
tests("#get_network_config_section_vapp(#{@vapp_id})").returns(Hash) do
|
||||
pending if Fog.mocking?
|
||||
@service.get_network_config_section_vapp(@vapp_id).body.class
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue