mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #2983 from alphagov/vapp_vm_mock
[vcloud_director] Mocks for most vApp and VM GET operations.
This commit is contained in:
commit
2518b56f40
20 changed files with 968 additions and 21 deletions
|
@ -489,6 +489,11 @@ module Fog
|
|||
uplink_network_uuid = uuid
|
||||
isolated_vdc1_network_uuid = uuid
|
||||
isolated_vdc2_network_uuid = uuid
|
||||
vapp1_id = "vapp-#{uuid}"
|
||||
vapp2_id = "vapp-#{uuid}"
|
||||
vapp1vm1_id = "vm-#{uuid}"
|
||||
vapp2vm1_id = "vm-#{uuid}"
|
||||
vapp2vm2_id = "vm-#{uuid}"
|
||||
|
||||
hash[key] = {
|
||||
:catalogs => {
|
||||
|
@ -645,6 +650,26 @@ module Fog
|
|||
:uuid => uuid
|
||||
},
|
||||
:tasks => {},
|
||||
|
||||
:vapps => {
|
||||
vapp1_id => {
|
||||
:name => 'mock-vapp-1',
|
||||
:vdc_id => vdc1_uuid,
|
||||
:description => "Mock vApp 1",
|
||||
:networks => [
|
||||
{ :parent_id => default_network_uuid, },
|
||||
],
|
||||
},
|
||||
vapp2_id => {
|
||||
:name => 'mock-vapp-2',
|
||||
:vdc_id => vdc2_uuid,
|
||||
:description => "Mock vApp 2",
|
||||
:networks => [
|
||||
{ :parent_id => default_network_uuid },
|
||||
]
|
||||
},
|
||||
},
|
||||
|
||||
:vdc_storage_classes => {
|
||||
uuid => {
|
||||
:default => true,
|
||||
|
@ -655,6 +680,7 @@ module Fog
|
|||
:vdc => vdc1_uuid,
|
||||
}
|
||||
},
|
||||
|
||||
:vdcs => {
|
||||
vdc1_uuid => {
|
||||
:description => 'vDC1 for mocking',
|
||||
|
@ -664,7 +690,44 @@ module Fog
|
|||
:description => 'vDC2 for mocking',
|
||||
:name => 'MockVDC 2'
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
:vms => {
|
||||
vapp1vm1_id => {
|
||||
:name => 'mock-vm-1-1',
|
||||
:parent_vapp => vapp1_id,
|
||||
:nics => [
|
||||
{
|
||||
:network_name => 'Default Network',
|
||||
:mac_address => "00:50:56:aa:bb:01",
|
||||
:ip_address => "192.168.1.33",
|
||||
},
|
||||
],
|
||||
},
|
||||
vapp2vm1_id => {
|
||||
:name => 'mock-vm-2-1',
|
||||
:parent_vapp => vapp2_id,
|
||||
:nics => [
|
||||
{
|
||||
:network_name => 'Default Network',
|
||||
:mac_address => "00:50:56:aa:bb:02",
|
||||
:ip_address => "192.168.1.34",
|
||||
},
|
||||
],
|
||||
},
|
||||
vapp2vm2_id => {
|
||||
:name => 'mock-vm-2-2',
|
||||
:parent_vapp => vapp2_id,
|
||||
:nics => [
|
||||
{
|
||||
:network_name => 'Default Network',
|
||||
:mac_address => "00:50:56:aa:bb:03",
|
||||
:ip_address => "192.168.1.35",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
|
||||
}
|
||||
end[@vcloud_director_username]
|
||||
end
|
||||
|
|
|
@ -22,7 +22,44 @@ module Fog
|
|||
:path => "vApp/#{id}/virtualHardwareSection/cpu"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_cpu_rasd_item(id)
|
||||
type = 'application/vnd.vmware.vcloud.rasdItem+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_cpu_rasd_item_body(id, vm)
|
||||
)
|
||||
end
|
||||
|
||||
def get_cpu_rasd_item_body(id, vm)
|
||||
{
|
||||
:ns12_href => make_href("vApp/#{id}/virtualHardwareSection/cpu"),
|
||||
:ns12_type => "application/vnd.vmware.vcloud.rasdItem+xml",
|
||||
:"rasd:AllocationUnits"=>"hertz * 10^6",
|
||||
:"rasd:Description"=>"Number of Virtual CPUs",
|
||||
:"rasd:ElementName"=>"#{vm[:cpu_count]} virtual CPU(s)",
|
||||
:"rasd:InstanceID"=>"4",
|
||||
:"rasd:Reservation"=>"0",
|
||||
:"rasd:ResourceType"=>"3",
|
||||
:"rasd:VirtualQuantity"=>"#{vm[:cpu_count]}",
|
||||
:"rasd:Weight"=>"0",
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,6 +21,70 @@ module Fog
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_disks_rasd_items_list(id)
|
||||
type = 'application/vnd.vmware.vcloud.rasdItemsList+xml'
|
||||
|
||||
unless vm = data[:vms][id]
|
||||
raise Fog::Compute::VcloudDirector::Forbidden.new(
|
||||
'This operation is denied.'
|
||||
)
|
||||
end
|
||||
|
||||
body = {
|
||||
:type => type,
|
||||
:href => make_href("vApp/#{id}/virtualHardwareSection/disks"),
|
||||
:Link => {
|
||||
:rel=>"edit",
|
||||
:type=>"application/vnd.vmware.vcloud.rasdItemsList+xml",
|
||||
:href=>make_href("vApp/#{id}/virtualHardwareSection/disks"),
|
||||
},
|
||||
:Item => [
|
||||
get_disks_rasd_items_list_body(id, vm),
|
||||
get_media_rasd_item_ide_controller_body(id, vm),
|
||||
].flatten
|
||||
}
|
||||
|
||||
Excon::Response.new(
|
||||
:status => 200,
|
||||
:headers => {'Content-Type' => "#{type};version=#{api_version}"},
|
||||
:body => body
|
||||
)
|
||||
end
|
||||
|
||||
def get_disks_rasd_items_list_body(id, vm)
|
||||
[
|
||||
{
|
||||
:"rasd:Address"=>"0",
|
||||
:"rasd:Description"=>"SCSI Controller",
|
||||
:"rasd:ElementName"=>"SCSI Controller 0",
|
||||
:"rasd:InstanceID"=>"2",
|
||||
:"rasd:ResourceSubType"=>"lsilogic",
|
||||
:"rasd:ResourceType"=>"6"
|
||||
},
|
||||
|
||||
# TODO: Add support for adding disks
|
||||
{
|
||||
:"rasd:AddressOnParent"=>"0",
|
||||
:"rasd:Description"=>"Hard disk",
|
||||
:"rasd:ElementName"=>"Hard disk 1",
|
||||
:"rasd:HostResource"=>{
|
||||
:ns12_capacity=>"51200",
|
||||
:ns12_busSubType=>"lsilogic",
|
||||
:ns12_busType=>"6"
|
||||
},
|
||||
:"rasd:InstanceID"=>"2000",
|
||||
:"rasd:Parent"=>"2",
|
||||
:"rasd:ResourceType"=>"17"
|
||||
},
|
||||
|
||||
]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,6 +20,50 @@ module Fog
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def get_guest_customization_system_section_vapp(id)
|
||||
|
||||
type = 'application/vnd.vmware.vcloud.guestCustomizationSection+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_guest_customization_section_body(id, vm)
|
||||
)
|
||||
end
|
||||
|
||||
def get_vm_guest_customization_section_body(id, vm)
|
||||
{
|
||||
:type => "application/vnd.vmware.vcloud.guestCustomizationSection+xml",
|
||||
:href => make_href("vApp/#{id}/guestCustomizationSection/"),
|
||||
:ovf_required => "false",
|
||||
:"ovf:Info" => "Specifies Guest OS Customization Settings",
|
||||
:Enabled => "true",
|
||||
:ChangeSid => "false",
|
||||
:VirtualMachineId => id.split('-').last, # strip the 'vm-' prefix
|
||||
:JoinDomainEnabled => "false",
|
||||
:UseOrgSettings => "false",
|
||||
:AdminPasswordEnabled => "false",
|
||||
:AdminPasswordAuto => "true",
|
||||
:ResetPasswordRequired => "false",
|
||||
:CustomizationScript => vm[:customization_script] || "",
|
||||
:ComputerName => vm[:computer_name] || vm[:name],
|
||||
:Link => {
|
||||
:rel=>"edit",
|
||||
:type=>"application/vnd.vmware.vcloud.guestCustomizationSection+xml",
|
||||
:href=>make_href("vApp/#{id}"),
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,6 +20,40 @@ module Fog
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_lease_settings_section_vapp(id)
|
||||
|
||||
type = 'application/vnd.vmware.vcloud.leaseSettingsSection+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_lease_settings_section_body(id)
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
def get_vapp_lease_settings_section_body(id)
|
||||
{
|
||||
:type => "application/vnd.vmware.vcloud.leaseSettingsSection+xml",
|
||||
:href => make_href("vApp/#{id}/leaseSettingsSection/"),
|
||||
:ovf_required=>"false",
|
||||
:"ovf:Info"=>"Lease settings section",
|
||||
:DeploymentLeaseInSeconds=>"0",
|
||||
:StorageLeaseInSeconds=>"0",
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,6 +21,72 @@ module Fog
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_media_drives_rasd_items_list(id)
|
||||
type = 'application/vnd.vmware.vcloud.rasdItemsList+xml'
|
||||
|
||||
unless vm = data[:vms][id]
|
||||
raise Fog::Compute::VcloudDirector::Forbidden.new(
|
||||
'This operation is denied.'
|
||||
)
|
||||
end
|
||||
|
||||
body = {
|
||||
:type => type,
|
||||
:href => make_href("vApp/#{id}/virtualHardwareSection/media"),
|
||||
:Item => [
|
||||
get_media_rasd_item_ide_controller_body(id, vm),
|
||||
get_media_rasd_item_cdrom_body(id, vm),
|
||||
get_media_rasd_item_floppy_body(id, vm),
|
||||
]
|
||||
}
|
||||
|
||||
Excon::Response.new(
|
||||
:status => 200,
|
||||
:headers => {'Content-Type' => "#{type};version=#{api_version}"},
|
||||
:body => body
|
||||
)
|
||||
end
|
||||
|
||||
def get_media_rasd_item_ide_controller_body(id, vm)
|
||||
{
|
||||
:"rasd:Address"=>"0",
|
||||
:"rasd:Description"=>"IDE Controller",
|
||||
:"rasd:ElementName"=>"IDE Controller 0",
|
||||
:"rasd:InstanceID"=>"3",
|
||||
:"rasd:ResourceType"=>"5"
|
||||
}
|
||||
end
|
||||
|
||||
def get_media_rasd_item_cdrom_body(id, vm)
|
||||
{
|
||||
:"rasd:AddressOnParent"=>"1",
|
||||
:"rasd:AutomaticAllocation"=>"true",
|
||||
:"rasd:Description"=>"CD/DVD Drive",
|
||||
:"rasd:ElementName"=>"CD/DVD Drive 1",
|
||||
:"rasd:HostResource"=>"",
|
||||
:"rasd:InstanceID"=>"3000",
|
||||
:"rasd:Parent"=>"3",
|
||||
:"rasd:ResourceType"=>"15"
|
||||
}
|
||||
end
|
||||
|
||||
def get_media_rasd_item_floppy_body(id, vm)
|
||||
{
|
||||
:"rasd:AddressOnParent"=>"0",
|
||||
:"rasd:AutomaticAllocation"=>"false",
|
||||
:"rasd:Description"=>"Floppy Drive",
|
||||
:"rasd:ElementName"=>"Floppy Drive 1",
|
||||
:"rasd:HostResource"=>"",
|
||||
:"rasd:InstanceID"=>"8000",
|
||||
:"rasd:ResourceType"=>"14"
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,6 +23,42 @@ module Fog
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_memory_rasd_item(id)
|
||||
type = 'application/vnd.vmware.vcloud.rasdItem+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_memory_rasd_item_body(id, vm)
|
||||
)
|
||||
end
|
||||
|
||||
def get_memory_rasd_item_body(id, vm)
|
||||
{
|
||||
:ns12_href => make_href("vApp/#{id}/virtualHardwareSection/memory"),
|
||||
:ns12_type=>"application/vnd.vmware.vcloud.rasdItem+xml",
|
||||
:"rasd:AllocationUnits"=>"byte * 2^20",
|
||||
:"rasd:Description"=>"Memory Size",
|
||||
:"rasd:ElementName"=>"#{vm[:memory_in_mb]} MB of memory",
|
||||
:"rasd:InstanceID"=>"5",
|
||||
:"rasd:Reservation"=>"0",
|
||||
:"rasd:ResourceType"=>"4",
|
||||
:"rasd:VirtualQuantity"=>"#{vm[:memory_in_mb]}",
|
||||
:"rasd:Weight"=>"0",
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,6 +20,51 @@ module Fog
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def get_network_cards_items_list(id)
|
||||
type = 'application/vnd.vmware.vcloud.rasdItemsList+xml'
|
||||
|
||||
unless vm = data[:vms][id]
|
||||
raise Fog::Compute::VcloudDirector::Forbidden.new(
|
||||
'This operation is denied.'
|
||||
)
|
||||
end
|
||||
|
||||
body = {
|
||||
:type => type,
|
||||
:href => make_href("vApp/#{id}/virtualHardwareSection/networkCards"),
|
||||
:Link => {
|
||||
:rel=>"edit",
|
||||
:type=>"application/vnd.vmware.vcloud.rasdItemsList+xml",
|
||||
:href=>make_href("vApp/#{id}/virtualHardwareSection/networkCards"),
|
||||
},
|
||||
:Item => get_network_cards_rasd_items_list_body(id, vm)
|
||||
}
|
||||
|
||||
Excon::Response.new(
|
||||
:status => 200,
|
||||
:headers => {'Content-Type' => "#{type};version=#{api_version}"},
|
||||
:body => body
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
def get_network_cards_rasd_items_list_body(id, vm)
|
||||
[{
|
||||
:"rasd:Address" => vm[:nics][0][:mac_address],
|
||||
:"rasd:AddressOnParent" => "0",
|
||||
:"rasd:AutomaticAllocation" => "true",
|
||||
:"rasd:Connection" => vm[:nics][0][:network_name],
|
||||
:"rasd:Description" => "E1000 ethernet adapter",
|
||||
:"rasd:ElementName" => "Network adapter 0",
|
||||
:"rasd:InstanceID" => "1",
|
||||
:"rasd:ResourceSubType" => "E1000",
|
||||
:"rasd:ResourceType" => "10"
|
||||
}]
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -20,6 +20,49 @@ module Fog
|
|||
)
|
||||
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
|
||||
|
|
|
@ -20,6 +20,40 @@ module Fog
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_operating_system_section(id)
|
||||
|
||||
type = 'application/vnd.vmware.vcloud.operatingSystemSection+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_operating_system_section_body(id, vm)
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
def get_vm_operating_system_section_body(id, vm)
|
||||
{
|
||||
:xmlns_ns12=>"http://www.vmware.com/vcloud/v1.5",
|
||||
:ovf_id => "94", # TODO: What is this?
|
||||
:ns12_href => make_href("vApp/#{id}/operatingSystemSection/"),
|
||||
:ns12_type => "application/vnd.vmware.vcloud.operatingSystemSection+xml",
|
||||
:vmw_osType => vm[:guest_os_type], # eg "ubuntu64Guest"
|
||||
:"ovf:Info"=>"Specifies the operating system installed",
|
||||
:"ovf:Description"=> vm[:guest_os_description], # eg "Ubuntu Linux (64-bit)",
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,6 +20,38 @@ module Fog
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def get_runtime_info_section_type(id)
|
||||
|
||||
type = 'application/vnd.vmware.vcloud.virtualHardwareSection+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_runtime_info_section_body(id, vm)
|
||||
)
|
||||
end
|
||||
|
||||
def get_vm_runtime_info_section_body(id, vm)
|
||||
{
|
||||
:xmlns_ns12 => "http://www.vmware.com/vcloud/v1.5",
|
||||
:ns12_href => make_href("vApp/#{id}/runtimeInfoSection"),
|
||||
:ns12_type => "application/vnd.vmware.vcloud.virtualHardwareSection+xml",
|
||||
:"ovf:Info" => "Specifies Runtime info",
|
||||
:VMWareTools => {
|
||||
:version => "9282",
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,6 +20,36 @@ module Fog
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_snapshot_section(id)
|
||||
type = 'application/vnd.vmware.vcloud.snapshotSection+xml'
|
||||
|
||||
unless data[:vms][id] || 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_snapshot_section_body(id)
|
||||
)
|
||||
end
|
||||
|
||||
def get_snapshot_section_body(id)
|
||||
{
|
||||
:type => "application/vnd.vmware.vcloud.snapshotSection+xml",
|
||||
:href => make_href("vApp/#{id}/snapshotSection"),
|
||||
:ovf_required => "false",
|
||||
:"ovf:Info" => "Snapshot information section"
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,6 +20,45 @@ module Fog
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_startup_section(id)
|
||||
|
||||
type = 'application/vnd.vmware.vcloud.startupSection+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_ovf_startup_section_body(id, vapp)
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
def get_vapp_ovf_startup_section_body(id, vapp)
|
||||
{
|
||||
:xmlns_ns12 => "http://www.vmware.com/vcloud/v1.5",
|
||||
:ns12_href => make_href("vApp/#{id}"),
|
||||
:ns12_type => "application/vnd.vmware.vcloud.startupSection+xml",
|
||||
:"ovf:Info" => "VApp startup section",
|
||||
:"ovf:Item" => {
|
||||
:ovf_stopDelay => "0",
|
||||
:ovf_stopAction => "powerOff",
|
||||
:ovf_startDelay => "0",
|
||||
:ovf_startAction => "powerOn",
|
||||
:ovf_order => "0",
|
||||
:ovf_id => vapp[:name],
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,6 +22,154 @@ module Fog
|
|||
response
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_vapp(id)
|
||||
|
||||
# Retrieve a vApp or VM.
|
||||
#
|
||||
|
||||
case id
|
||||
when /^vapp-/
|
||||
body = get_mock_vapp_body(id)
|
||||
when /^vm-/
|
||||
body = get_mock_vm_body(id)
|
||||
else
|
||||
raise Fog::Compute::VcloudDirector::Forbidden.new(
|
||||
'This operation is denied.'
|
||||
)
|
||||
end
|
||||
|
||||
Excon::Response.new(
|
||||
:status => 200,
|
||||
:headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
|
||||
:body => body
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
def get_mock_vm_body(id)
|
||||
unless vm = data[:vms][id]
|
||||
raise Fog::Compute::VcloudDirector::Forbidden.new(
|
||||
'This operation is denied.'
|
||||
)
|
||||
end
|
||||
|
||||
body = {
|
||||
:name => vm[:name],
|
||||
:href => make_href("vApp/#{id}"),
|
||||
:type => "application/application/vnd.vmware.vcloud.vm+xml",
|
||||
:status => vm[:status],
|
||||
:deployed => vm[:deployed],
|
||||
:needsCustomization => vm[:needs_customization],
|
||||
:"ovf:VirtualHardwareSection" => get_vm_virtual_hardware_section_body(id, vm),
|
||||
:"ovf:OperatingSystemSection" => get_vm_operating_system_section_body(id, vm),
|
||||
:NetworkConnectionSection => get_vm_network_connection_section_body(id, vm),
|
||||
:GuestCustomizationSection => get_vm_guest_customization_section_body(id, vm),
|
||||
:RuntimeInfoSection => get_vm_runtime_info_section_body(id, vm),
|
||||
:SnapshotSection => get_snapshot_section_body(id),
|
||||
:DateCreated => vm[:date_created], # eg "2014-03-16T10:52:31.874Z"
|
||||
:VAppScopedLocalId => vm[:parent_vapp].split('-').last, # strip the vapp- prefix
|
||||
:"ovfenv:Environment" => get_vm_ovfenv_environment_section_body(id, vm),
|
||||
:VmCapabilities => get_vm_capabilities_section_body(id, vm),
|
||||
:StorageProfile => get_vm_storage_profile_section_body(id, vm),
|
||||
}
|
||||
body
|
||||
end
|
||||
|
||||
def get_mock_vapp_body(id)
|
||||
|
||||
unless vapp = data[:vapps][id]
|
||||
raise Fog::Compute::VcloudDirector::Forbidden.new(
|
||||
'This operation is denied.'
|
||||
)
|
||||
end
|
||||
|
||||
body = {
|
||||
:deployed => "true",
|
||||
:status => vapp[:status],
|
||||
:name => vapp[:name],
|
||||
:type => "application/vnd.vmware.vcloud.vApp+xml",
|
||||
:href => make_href("vApp/#{id}"),
|
||||
:LeaseSettingsSection => get_vapp_lease_settings_section_body(id),
|
||||
:"ovf:StartupSection" => get_vapp_ovf_startup_section_body(id, vapp),
|
||||
:"ovf:NetworkSection" => get_vapp_ovf_network_section_body(id, vapp),
|
||||
:NetworkConfigSection => get_vapp_network_config_section_body(id, vapp),
|
||||
:SnapshotSection => get_snapshot_section_body(id),
|
||||
:DateCreated => vapp[:date_created], # eg "2014-03-16T10:52:31.874Z"
|
||||
:Owner => get_owner_section_body(id),
|
||||
:InMaintenanceMode => "false",
|
||||
:Children => {
|
||||
:Vm => get_vapp_children_vms_body(id)
|
||||
},
|
||||
}
|
||||
body
|
||||
end
|
||||
|
||||
def get_vapp_ovf_network_section_body(id, vapp)
|
||||
{}
|
||||
end
|
||||
|
||||
def get_vapp_children_vms_body(id)
|
||||
child_vms = data[:vms].select do |vm_id, vm_details|
|
||||
vm_details[:parent_vapp] == id
|
||||
end
|
||||
if RUBY_VERSION.to_f < 1.9
|
||||
# 1.8 Hash.select returns an Array of [k,v] pairs.
|
||||
child_vms = Hash[child_vms]
|
||||
end
|
||||
child_vms.keys.collect do |vm_id|
|
||||
get_mock_vm_body(vm_id)
|
||||
end
|
||||
end
|
||||
|
||||
def get_vm_ovfenv_environment_section_body(id, vm)
|
||||
# TODO: I'm pretty sure this is just repeating info in other
|
||||
# sections, and the OVF part of VMs is extremely verbose. It's
|
||||
# likely to not be needed in Mock mode
|
||||
{}
|
||||
end
|
||||
|
||||
def get_vm_storage_profile_section_body(id, vm)
|
||||
{
|
||||
:type => "application/vnd.vmware.vcloud.vdcStorageProfile+xml",
|
||||
:name => "Mock Storage Profile",
|
||||
:href => make_href("vdcStorageProfile/12345678-1234-1234-1234-1234500e49a8"),
|
||||
}
|
||||
end
|
||||
|
||||
def get_vm_virtual_hardware_section_body(id, vm)
|
||||
|
||||
{:xmlns_ns12=>"http://www.vmware.com/vcloud/v1.5",
|
||||
:ovf_transport=>"",
|
||||
:ns12_href => make_href("vApp/#{id}/virtualHardwareSection/"),
|
||||
:ns12_type=>"application/vnd.vmware.vcloud.virtualHardwareSection+xml",
|
||||
:"ovf:Info"=>"Virtual hardware requirements",
|
||||
:"ovf:System"=>{
|
||||
:"vssd:ElementName"=>"Virtual Hardware Family",
|
||||
:"vssd:InstanceID"=>"0",
|
||||
:"vssd:VirtualSystemIdentifier" => vm[:name],
|
||||
:"vssd:VirtualSystemType"=>"vmx-08"
|
||||
},
|
||||
:"ovf:Item" => get_vm_ovf_item_list(id, vm),
|
||||
}
|
||||
end
|
||||
|
||||
def get_vm_ovf_item_list(id, vm)
|
||||
[
|
||||
get_network_cards_rasd_items_list_body(id, vm),
|
||||
get_disks_rasd_items_list_body(id, vm),
|
||||
get_media_rasd_item_cdrom_body(id, vm),
|
||||
get_media_rasd_item_floppy_body(id, vm),
|
||||
get_cpu_rasd_item_body(id, vm),
|
||||
get_memory_rasd_item_body(id, vm),
|
||||
].compact.flatten
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,6 +20,39 @@ module Fog
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def get_vapp_owner(id)
|
||||
|
||||
type = 'application/vnd.vmware.vcloud.owner+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_owner_section_body(id)
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
def get_owner_section_body(id)
|
||||
{
|
||||
:type => 'application/vnd.vmware.vcloud.owner+xml',
|
||||
:User => {
|
||||
:type => "application/vnd.vmware.admin.user+xml",
|
||||
:name => "mockuser",
|
||||
:href => make_href("user/12345678-1234-1234-1234-12345678df2b"),
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -110,7 +110,9 @@ module Fog
|
|||
:Reserved=>"0",
|
||||
:Used=>"0",
|
||||
:Overhead=>"0"}},
|
||||
:ResourceEntities => {},
|
||||
:ResourceEntities => {
|
||||
:ResourceEntity => []
|
||||
},
|
||||
:AvailableNetworks => {},
|
||||
:Capabilities=>
|
||||
{:SupportedHardwareVersions=>
|
||||
|
@ -128,6 +130,13 @@ module Fog
|
|||
:href=>make_href("#{item[:type]}/#{item[:type]}-#{id}")}
|
||||
end
|
||||
|
||||
body[:ResourceEntities][:ResourceEntity] +=
|
||||
get_vapps_in_this_vdc(vdc_id).map do |vapp_id, vapp|
|
||||
{:type => "application/vnd.vmware.vcloud.vApp+xml",
|
||||
:name => vapp[:name],
|
||||
:href => make_href("vApp/#{vapp_id}")}
|
||||
end
|
||||
|
||||
body[:AvailableNetworks][:Network] =
|
||||
data[:networks].map do |id, network|
|
||||
{:type=>"application/vnd.vmware.vcloud.network+xml",
|
||||
|
@ -152,6 +161,13 @@ module Fog
|
|||
response.body = body
|
||||
response
|
||||
end
|
||||
|
||||
def get_vapps_in_this_vdc(vdc_id)
|
||||
data[:vapps].select do |vapp_id, vapp|
|
||||
vapp[:vdc_id] == vdc_id
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,6 +25,37 @@ module Fog
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_vm_capabilities(id)
|
||||
|
||||
type = 'application/vnd.vmware.vcloud.vmCapabilitiesSection+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_capabilities_section_body(id, vm)
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
def get_vm_capabilities_section_body(id, vm)
|
||||
{
|
||||
:type => "application/vnd.vmware.vcloud.vmCapabilitiesSection+xml",
|
||||
:href => make_href("vApp/#{id}/vmCapabilities/"),
|
||||
:MemoryHotAddEnabled => "false",
|
||||
:CpuHotAddEnabled => "false",
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,29 +15,53 @@ Shindo.tests('Compute::VcloudDirector | vapp requests', ['vclouddirector']) do
|
|||
@vapp_id = v[:href].split('/').last
|
||||
|
||||
#tests("#get_vapp(#{@vapp_id})").data_matches_schema(VcloudDirector::Compute::Schema::VAPP_TYPE) do
|
||||
tests("#get_vapp(#{@vapp_id})").returns(Hash) do
|
||||
pending if Fog.mocking?
|
||||
tests("#get_vapp(#{@vapp_id}).body").returns(Hash) do
|
||||
@service.get_vapp(@vapp_id).body.class
|
||||
end
|
||||
|
||||
tests("#get_vapp(#{@vapp_id}).body[:name]").returns(String) do
|
||||
@service.get_vapp(@vapp_id).body[:name].class
|
||||
end
|
||||
|
||||
tests("#get_vapp(#{@vapp_id}).body[:href]").returns(v[:href]) do
|
||||
@service.get_vapp(@vapp_id).body[:href]
|
||||
end
|
||||
|
||||
tests("#get_lease_settings_section_vapp(#{@vapp_id})").returns(Hash) do
|
||||
pending if Fog.mocking?
|
||||
@service.get_lease_settings_section_vapp(@vapp_id).body.class
|
||||
end
|
||||
|
||||
tests("#get_lease_settings_section_vapp(#{@vapp_id}).body[:DeploymentLeaseInSeconds] is >= 0").returns(true) do
|
||||
Integer(@service.get_lease_settings_section_vapp(@vapp_id).body[:DeploymentLeaseInSeconds]) >= 0
|
||||
end
|
||||
|
||||
tests("#get_vapp(#{@vapp_id}).body[:LeaseSettingsSection[:DeploymentLeaseInSeconds] is >= 0").returns(true) 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
|
||||
|
||||
tests("#get_network_section_vapp(#{@vapp_id})").returns(Hash) do
|
||||
pending if Fog.mocking?
|
||||
@service.get_network_section_vapp(@vapp_id).body.class
|
||||
end
|
||||
|
||||
tests("#get_product_sections_vapp(#{@vapp_id})").returns(Hash) do
|
||||
pending if Fog.mocking?
|
||||
@service.get_product_sections_vapp(@vapp_id).body.class
|
||||
end
|
||||
|
||||
tests("#get_vapp(#{@vapp_id}).body[:'ovf:StartupSection']").returns(Hash) do
|
||||
@service.get_vapp(@vapp_id).body[:"ovf:StartupSection"].class
|
||||
end
|
||||
|
||||
tests("#get_startup_section(#{@vapp_id})").returns(Hash) do
|
||||
pending if Fog.mocking?
|
||||
@service.get_startup_section(@vapp_id).body.class
|
||||
end
|
||||
|
||||
|
@ -47,14 +71,18 @@ Shindo.tests('Compute::VcloudDirector | vapp requests', ['vclouddirector']) do
|
|||
end
|
||||
|
||||
tests("#get_vapp_owner(#{@vapp_id})").data_matches_schema(VcloudDirector::Compute::Schema::OWNER_TYPE) do
|
||||
pending if Fog.mocking?
|
||||
@service.get_vapp_owner(@vapp_id).body
|
||||
end
|
||||
|
||||
tests("#get_vapp(#{@vapp_id}).body[:Owner]").data_matches_schema(VcloudDirector::Compute::Schema::OWNER_TYPE) do
|
||||
@service.get_vapp(@vapp_id).body[:Owner]
|
||||
end
|
||||
|
||||
tests("#get_control_access_params_vapp(#{@vapp_id})").data_matches_schema(VcloudDirector::Compute::Schema::CONTROL_ACCESS_PARAMS_TYPE) do
|
||||
pending if Fog.mocking?
|
||||
@service.get_control_access_params_vapp(@vapp_id).body
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -79,7 +107,6 @@ Shindo.tests('Compute::VcloudDirector | vapp requests', ['vclouddirector']) do
|
|||
end
|
||||
|
||||
tests('Retrieve owner of non-existent vApp').raises(Fog::Compute::VcloudDirector::Forbidden) do
|
||||
pending if Fog.mocking?
|
||||
@service.get_vapp_owner('00000000-0000-0000-0000-000000000000')
|
||||
end
|
||||
|
||||
|
|
|
@ -16,63 +16,122 @@ Shindo.tests('Compute::VcloudDirector | vm requests', ['vclouddirector']) do
|
|||
vapp = @service.get_vapp(vapp_id).body
|
||||
|
||||
tests('Each VM') do
|
||||
|
||||
vapp[:Children][:Vm].each do |vm|
|
||||
vm_id = vm[:href].split('/').last
|
||||
|
||||
tests("#get_vapp(#{vm_id}).body").returns(Hash) do
|
||||
@service.get_vapp(vm_id).body.class
|
||||
end
|
||||
|
||||
tests("#get_vapp(#{vm_id}).body[:name]").returns(String) do
|
||||
@service.get_vapp(vm_id).body[:name].class
|
||||
end
|
||||
|
||||
tests("#get_vapp(#{vm_id}).body[:href]").returns(vm[:href]) do
|
||||
@service.get_vapp(vm_id).body[:href]
|
||||
end
|
||||
|
||||
tests("#get_vapp(#{vm_id}).body[:GuestCustomizationSection]").returns(Hash) do
|
||||
@service.get_vapp(vm_id).body[:GuestCustomizationSection].class
|
||||
end
|
||||
|
||||
tests("#get_vapp(#{vm_id}).body[:GuestCustomizationSection]").data_matches_schema(VcloudDirector::Compute::Schema::GUEST_CUSTOMIZATION_SECTION_TYPE) do
|
||||
@service.get_vapp(vm_id).body[:GuestCustomizationSection]
|
||||
end
|
||||
|
||||
tests("#get_guest_customization_system_section_vapp(#{vm_id})").returns(Hash) do
|
||||
@service.get_guest_customization_system_section_vapp(vm_id).body.class
|
||||
end
|
||||
|
||||
tests("#get_guest_customization_system_section_vapp(#{vm_id})").data_matches_schema(VcloudDirector::Compute::Schema::GUEST_CUSTOMIZATION_SECTION_TYPE) do
|
||||
pending if Fog.mocking?
|
||||
@service.get_guest_customization_system_section_vapp(vm_id).body
|
||||
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
|
||||
pending if Fog.mocking?
|
||||
@service.get_network_connection_system_section_vapp(vm_id).body.class
|
||||
end
|
||||
|
||||
tests("#get_vapp(#{vm_id}).body[:'ovf:OperatingSystemSection']").returns(Hash) do
|
||||
@service.get_vapp(vm_id).body[:'ovf:OperatingSystemSection'].class
|
||||
end
|
||||
|
||||
tests("#get_operating_system_section(#{vm_id})").returns(Hash) do
|
||||
pending if Fog.mocking?
|
||||
@service.get_operating_system_section(vm_id).body.class
|
||||
end
|
||||
|
||||
tests("#get_product_sections_vapp(#{vm_id})").returns(Hash) do
|
||||
pending if Fog.mocking?
|
||||
@service.get_product_sections_vapp(vm_id).body.class
|
||||
end
|
||||
|
||||
tests("#get_vapp(#{vm_id}).body[:RuntimeInfoSection]").data_matches_schema(VcloudDirector::Compute::Schema::RUNTIME_INFO_SECTION_TYPE) do
|
||||
@service.get_vapp(vm_id).body[:RuntimeInfoSection]
|
||||
end
|
||||
|
||||
tests("#get_runtime_info_section_type(#{vm_id})").data_matches_schema(VcloudDirector::Compute::Schema::RUNTIME_INFO_SECTION_TYPE) do
|
||||
pending if Fog.mocking?
|
||||
pending # fails if WMware Tools not installed
|
||||
@service.get_runtime_info_section_type(vm_id).body
|
||||
end
|
||||
|
||||
tests("#get_snapshot_section(#{vm_id})").returns(Hash) do
|
||||
pending if Fog.mocking?
|
||||
@service.get_snapshot_section(vm_id).body.class
|
||||
end
|
||||
|
||||
tests("#get_vapp(#{vm_id}).body[:VmCapabilities]").data_matches_schema(VcloudDirector::Compute::Schema::VM_CAPABILITIES_TYPE) do
|
||||
@service.get_vapp(vm_id).body[:VmCapabilities]
|
||||
end
|
||||
|
||||
tests("#get_vm_capabilities(#{vm_id})").data_matches_schema(VcloudDirector::Compute::Schema::VM_CAPABILITIES_TYPE) do
|
||||
pending if Fog.mocking?
|
||||
@service.get_vm_capabilities(vm_id).body
|
||||
end
|
||||
|
||||
tests("#get_vapp(#{vm_id}).body[:'ovf:VirtualHardwareSection']").returns(Hash) do
|
||||
@section = @service.get_vapp(vm_id).body[:'ovf:VirtualHardwareSection'].class
|
||||
end
|
||||
|
||||
tests("#get_virtual_hardware_section(#{vm_id})").returns(Hash) do
|
||||
pending if Fog.mocking?
|
||||
@section = @service.get_virtual_hardware_section(vm_id).body.class
|
||||
end
|
||||
|
||||
tests("#get_cpu_rasd_item(#{vm_id})").returns(Hash) do
|
||||
pending if Fog.mocking?
|
||||
@service.get_cpu_rasd_item(vm_id).body.class
|
||||
end
|
||||
|
||||
tests("#get_disks_rasd_items_list(#{vm_id})").returns(Hash) do
|
||||
pending if Fog.mocking?
|
||||
@service.get_disks_rasd_items_list(vm_id).body.class
|
||||
end
|
||||
|
||||
tests("#get_disks_rasd_items_list(#{vm_id}).body[:Item]").returns(Array) do
|
||||
@service.get_disks_rasd_items_list(vm_id).body[:Item].class
|
||||
end
|
||||
|
||||
tests("#get_media_drives_rasd_items_list(#{vm_id})").returns(Hash) do
|
||||
pending if Fog.mocking?
|
||||
@service.get_media_drives_rasd_items_list(vm_id).body.class
|
||||
end
|
||||
|
||||
tests("#get_media_drives_rasd_items_list(#{vm_id}).body[:Item]").returns(Array) do
|
||||
@service.get_media_drives_rasd_items_list(vm_id).body[:Item].class
|
||||
end
|
||||
|
||||
tests("#get_memory_rasd_item(#{vm_id})").returns(Hash) do
|
||||
pending if Fog.mocking?
|
||||
@service.get_memory_rasd_item(vm_id).body.class
|
||||
end
|
||||
|
||||
tests("#get_vapp(#{vm_id}) ovf:VirtualHardwareSection has a Network adapter listed").returns(Hash) do
|
||||
@service.get_vapp(vm_id).body[:'ovf:VirtualHardwareSection'][:'ovf:Item'].detect do |rasd_item|
|
||||
rasd_item[:'rasd:ElementName'] =~ /^Network adapter/
|
||||
end.class
|
||||
end
|
||||
|
||||
tests("#get_network_cards_items_list(#{vm_id})").returns(Hash) do
|
||||
pending if Fog.mocking?
|
||||
@service.get_network_cards_items_list(vm_id).body.class
|
||||
end
|
||||
|
||||
tests("#get_serial_ports_items_list(#{vm_id})").returns(Hash) do
|
||||
pending if Fog.mocking?
|
||||
@service.get_serial_ports_items_list(vm_id).body.class
|
||||
|
@ -87,6 +146,7 @@ Shindo.tests('Compute::VcloudDirector | vm requests', ['vclouddirector']) do
|
|||
pending # result depends on power state
|
||||
@service.post_acquire_ticket(vm_id).body
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue