mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Mock for get_network_connection_system_section_vapp
This commit is contained in:
parent
5a956749df
commit
a5eaa8ebf5
3 changed files with 47 additions and 19 deletions
|
@ -20,6 +20,49 @@ module Fog
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
|
||||||
|
def get_network_connection_system_section_vapp(id)
|
||||||
|
type = 'application/vnd.vmware.vcloud.networkConnectionSection+xml'
|
||||||
|
|
||||||
|
unless vm = data[:vms][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_vm_network_connection_section_body(id, vm)
|
||||||
|
)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_vm_network_connection_section_body(id, vm)
|
||||||
|
# TODO: Needs work - does not handle multiple NIC case yet, or
|
||||||
|
# DHCP/POOL allocations
|
||||||
|
{
|
||||||
|
:type => "application/vnd.vmware.vcloud.networkConnectionSection+xml",
|
||||||
|
:href => make_href("vApp/#{id}/networkConnectionSection/"),
|
||||||
|
:ovf_required => "false",
|
||||||
|
:"ovf:Info" => "Specifies the available VM network connections",
|
||||||
|
:PrimaryNetworkConnectionIndex => "0",
|
||||||
|
:NetworkConnection => {
|
||||||
|
:network => vm[:nics][0][:network_name],
|
||||||
|
:needsCustomization => "false",
|
||||||
|
:NetworkConnectionIndex => "0",
|
||||||
|
:IpAddress => vm[:nics][0][:ip_address],
|
||||||
|
:IsConnected => "true",
|
||||||
|
:MACAddress => vm[:nics][0][:mac_address],
|
||||||
|
:IpAddressAllocationMode => "MANUAL"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -200,24 +200,6 @@ module Fog
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_vm_network_connection_section_body(id, vm)
|
|
||||||
{
|
|
||||||
:type => "application/vnd.vmware.vcloud.networkConnectionSection+xml",
|
|
||||||
:href => make_href("vApp/#{id}/networkConnectionSection/"),
|
|
||||||
:ovf_required => "false",
|
|
||||||
:"ovf:Info" => "Specifies the available VM network connections",
|
|
||||||
:PrimaryNetworkConnectionIndex => "0",
|
|
||||||
:NetworkConnection => {
|
|
||||||
:network => vm[:nics][0][:network_name],
|
|
||||||
:needsCustomization => "false",
|
|
||||||
:NetworkConnectionIndex => "0",
|
|
||||||
:IpAddress => vm[:nics][0][:ip_address],
|
|
||||||
:IsConnected => "true",
|
|
||||||
:MACAddress => vm[:nics][0][:mac_address],
|
|
||||||
:IpAddressAllocationMode => "MANUAL"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
def get_vm_runtime_info_section_body(id, vm)
|
def get_vm_runtime_info_section_body(id, vm)
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,8 +48,11 @@ Shindo.tests('Compute::VcloudDirector | vm requests', ['vclouddirector']) do
|
||||||
@service.get_guest_customization_system_section_vapp(vm_id).body
|
@service.get_guest_customization_system_section_vapp(vm_id).body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
tests("#get_vapp(#{vm_id}).body[:NetworkConnectionSection]").returns(Hash) do
|
||||||
|
@service.get_vapp(vm_id).body[:NetworkConnectionSection].class
|
||||||
|
end
|
||||||
|
|
||||||
tests("#get_network_connection_system_section_vapp(#{vm_id})").returns(Hash) do
|
tests("#get_network_connection_system_section_vapp(#{vm_id})").returns(Hash) do
|
||||||
pending if Fog.mocking?
|
|
||||||
@service.get_network_connection_system_section_vapp(vm_id).body.class
|
@service.get_network_connection_system_section_vapp(vm_id).body.class
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue