mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[vcloud_director] More mocking (1.8.7 compliant)
This commit is contained in:
parent
1b7120d269
commit
62ba706273
12 changed files with 264 additions and 114 deletions
|
@ -307,30 +307,46 @@ module Fog
|
|||
def data
|
||||
@@data ||= Hash.new do |hash, key|
|
||||
hash[key] = {
|
||||
:catalog => {
|
||||
:name => 'Default Catalog',
|
||||
:uuid => uuid
|
||||
:catalogs => {
|
||||
uuid => {
|
||||
:name => 'Default Catalog'
|
||||
}
|
||||
},
|
||||
:catalog_items => {
|
||||
uuid => {
|
||||
:type => 'vAppTemplate',
|
||||
:name => 'vAppTemplate 1'
|
||||
}
|
||||
},
|
||||
:medias => {},
|
||||
:networks => {
|
||||
uuid => {
|
||||
:Description => 'Network for mocking',
|
||||
:Dns1 => '8.8.8.8',
|
||||
:Dns2 => '8.8.4.4',
|
||||
:DnsSuffix => 'example.com',
|
||||
:Gateway => '192.168.1.1',
|
||||
:IpRanges => [{
|
||||
:StartAddress=>'192.168.1.2',
|
||||
:EndAddress=>'192.168.1.254'
|
||||
}],
|
||||
:IsInherited => false,
|
||||
:Netmask => '255.255.255.0',
|
||||
:name => 'Default Network'
|
||||
}
|
||||
},
|
||||
:catalog_items => [{
|
||||
:type => 'vAppTemplate',
|
||||
:name => 'vAppTemplate 1',
|
||||
:uuid => uuid
|
||||
}],
|
||||
:networks => [{
|
||||
:name => 'Default Network',
|
||||
:uuid => uuid
|
||||
}],
|
||||
:org => {
|
||||
:description => 'Organization for mocking',
|
||||
:full_name => 'Mock Organization',
|
||||
:name => org_name,
|
||||
:uuid => uuid
|
||||
},
|
||||
:tasks => [],
|
||||
:vdc => {
|
||||
:description => 'vDC for mocking',
|
||||
:name => 'MockVDC',
|
||||
:uuid => uuid
|
||||
:tasks => {},
|
||||
:vdcs => {
|
||||
uuid => {
|
||||
:description => 'vDC for mocking',
|
||||
:name => 'MockVDC'
|
||||
}
|
||||
}
|
||||
}
|
||||
end[@vcloud_director_username]
|
||||
|
@ -383,6 +399,10 @@ module Fog
|
|||
"#{@end_point}#{path}"
|
||||
end
|
||||
|
||||
def valid_uuid?(uuid)
|
||||
/^[\da-f]{8}(?:-[\da-f]{4}){3}-[\da-f]{12}$/.match(uuid.downcase)
|
||||
end
|
||||
|
||||
def xmlns
|
||||
'http://www.vmware.com/vcloud/v1.5'
|
||||
end
|
||||
|
|
|
@ -20,6 +20,23 @@ module Fog
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def get_catalog(catalog_id)
|
||||
response = Excon::Response.new
|
||||
|
||||
unless valid_uuid?(catalog_id)
|
||||
response.status = 400
|
||||
raise Excon::Error.status_error({:expects => 200}, response)
|
||||
end
|
||||
unless catalog = data[:catalogs][catalog_id]
|
||||
response.status = 403
|
||||
raise Excon::Error.status_error({:expects => 200}, response)
|
||||
end
|
||||
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -54,6 +54,7 @@ module Fog
|
|||
{:rel => 'entityResolver',
|
||||
:type => 'application/vnd.vmware.vcloud.entity+xml',
|
||||
:href => make_href('entity/')}]}
|
||||
|
||||
if @api_version.to_f >= 5.1
|
||||
body[:Link] << {
|
||||
:rel => 'down:extensibility',
|
||||
|
|
|
@ -22,7 +22,44 @@ module Fog
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def get_network(network_id)
|
||||
response = Excon::Response.new
|
||||
|
||||
unless valid_uuid?(network_id)
|
||||
response.status = 400
|
||||
raise Excon::Errors.status_error({:expect => 200}, response)
|
||||
end
|
||||
unless network = data[:networks][network_id]
|
||||
response.status = 403
|
||||
raise Excon::Errors.status_error({:expect => 200}, response)
|
||||
end
|
||||
|
||||
body =
|
||||
{:name=>network[:name],
|
||||
:href=>make_href("network/#{network_id}"),
|
||||
:type=>"application/vnd.vmware.vcloud.orgNetwork+xml",
|
||||
:id=>network_id,
|
||||
:description=>nil,
|
||||
:is_inherited=>network[:IsInherited],
|
||||
:gateway=>network[:Gateway],
|
||||
:netmask=>network[:Netmask],
|
||||
:dns1=>network[:Dns1],
|
||||
:dns2=>network[:Dns2],
|
||||
:dns_suffix=>network[:DnsSuffix]}
|
||||
|
||||
body[:ip_ranges] = network[:IpRanges].map do |ip_range|
|
||||
{:start_address=>ip_range[:StartAddress],
|
||||
:end_address=>ip_range[:EndAddress]}
|
||||
end
|
||||
|
||||
response.status = 200
|
||||
response.headers = {'Content-Type' => "#{body[:type]};version=#{api_version}"}
|
||||
response.body = body
|
||||
response
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -25,54 +25,70 @@ module Fog
|
|||
def get_organization(org_id)
|
||||
response = Excon::Response.new
|
||||
|
||||
org = data[:org]
|
||||
unless org_id == org[:uuid]
|
||||
unless valid_uuid?(org_id)
|
||||
response.status = 400
|
||||
raise Excon::Errors.status_error({:expects => 200}, response)
|
||||
end
|
||||
unless org_id == data[:org][:uuid]
|
||||
response.status = 403
|
||||
raise(Excon::Errors.status_error({:expects => 200}, response))
|
||||
end
|
||||
org = data[:org]
|
||||
|
||||
body =
|
||||
{:xmlns=>xmlns,
|
||||
:xmlns_xsi=>xmlns_xsi,
|
||||
:name=>org[:name],
|
||||
:id=>"urn:vcloud:org:#{org[:uuid]}",
|
||||
:id=>"urn:vcloud:org:#{org_id}",
|
||||
:type=>"application/vnd.vmware.vcloud.org+xml",
|
||||
:href=>make_href("org/#{org[:uuid]}"),
|
||||
:href=>make_href("org/#{org_id}"),
|
||||
:xsi_schemaLocation=>xsi_schema_location,
|
||||
:Link=>
|
||||
[{:rel=>"down",
|
||||
:type=>"application/vnd.vmware.vcloud.vdc+xml",
|
||||
:name=>data[:vdc][:name],
|
||||
:href=>make_href("vdc/#{data[:vdc][:uuid]}")},
|
||||
{:rel=>"down",
|
||||
:type=>"application/vnd.vmware.vcloud.tasksList+xml",
|
||||
:href=>make_href("tasksList/#{org[:uuid]}")},
|
||||
{:rel=>"down",
|
||||
:type=>"application/vnd.vmware.vcloud.catalog+xml",
|
||||
:name=>data[:catalog][:name],
|
||||
:href=>make_href("catalog/#{data[:catalog][:uuid]}")},
|
||||
{:rel=>"down",
|
||||
:type=>"application/vnd.vmware.vcloud.controlAccess+xml",
|
||||
:href=>
|
||||
make_href("org/#{org[:uuid]}/catalog/#{data[:catalog][:uuid]}/controlAccess/")},
|
||||
{:rel=>"controlAccess",
|
||||
:type=>"application/vnd.vmware.vcloud.controlAccess+xml",
|
||||
:href=>
|
||||
make_href("org/#{org[:uuid]}/catalog/#{data[:catalog][:uuid]}/action/controlAccess")},
|
||||
:href=>make_href("tasksList/#{org_id}")},
|
||||
{:rel=>"add",
|
||||
:type=>"application/vnd.vmware.admin.catalog+xml",
|
||||
:href=>make_href("admin/org/#{org[:uuid]}/catalogs")},
|
||||
:href=>make_href("admin/org/#{org_id}/catalogs")},
|
||||
{:rel=>"down",
|
||||
:type=>"application/vnd.vmware.vcloud.metadata+xml",
|
||||
:href=>make_href("org/#{org[:uuid]}/metadata")}],
|
||||
:href=>make_href("org/#{org_id}/metadata")}],
|
||||
:Description=>org[:description]||'',
|
||||
:FullName=>org[:full_name]}
|
||||
|
||||
body[:Link] += data[:networks].map do |network|
|
||||
body[:Link] += data[:catalogs].map do |id, catalog|
|
||||
[{:rel=>"down",
|
||||
:type=>"application/vnd.vmware.vcloud.catalog+xml",
|
||||
:name=>catalog[:name],
|
||||
:href=>make_href("catalog/#{id}")},
|
||||
{:rel=>"down",
|
||||
:type=>"application/vnd.vmware.vcloud.controlAccess+xml",
|
||||
:href=>make_href("org/#{org_id}/catalog/#{id}/controlAccess/")},
|
||||
{:rel=>"controlAccess",
|
||||
:type=>"application/vnd.vmware.vcloud.controlAccess+xml",
|
||||
:href=>
|
||||
make_href("org/#{org_id}/catalog/#{id}/action/controlAccess")}]
|
||||
end.flatten
|
||||
|
||||
body[:Link] += data[:networks].map do |id, network|
|
||||
{:rel=>"down",
|
||||
:type=>"application/vnd.vmware.vcloud.orgNetwork+xml",
|
||||
:name=>network[:name],
|
||||
:href=>make_href("network/#{network[:uuid]}")}
|
||||
:href=>make_href("network/#{id}")}
|
||||
end
|
||||
|
||||
body[:Link] += data[:vdcs].map do |id, vdc|
|
||||
{:rel=>"down",
|
||||
:type=>"application/vnd.vmware.vcloud.vdc+xml",
|
||||
:name=>vdc[:name],
|
||||
:href=>make_href("vdc/#{id}")}
|
||||
end
|
||||
|
||||
if api_version.to_f >= 5.1
|
||||
body[:Link] <<
|
||||
{:rel=>"down",
|
||||
:type=>"application/vnd.vmware.vcloud.supportedSystemsInfo+xml",
|
||||
:href=>make_href('supportedSystemsInfo/')}
|
||||
end
|
||||
|
||||
response.status = 200
|
||||
|
|
|
@ -20,6 +20,23 @@ module Fog
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def get_task(task_id)
|
||||
response = Excon::Response.new
|
||||
|
||||
unless valid_uuid?(task_id)
|
||||
response.status = 400
|
||||
raise Excon::Error.status_error({:expects => 200}, response)
|
||||
end
|
||||
unless task = data[:tasks][task_id]
|
||||
response.status = 403
|
||||
raise Excon::Error.status_error({:expects => 200}, response)
|
||||
end
|
||||
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,6 +26,10 @@ module Fog
|
|||
def get_tasks_list(org_id)
|
||||
response = Excon::Response.new
|
||||
|
||||
unless valid_uuid?(org_id)
|
||||
response.status = 400
|
||||
raise(Excon::Errors.status_error({:expects => 200}, response))
|
||||
end
|
||||
unless org_id == data[:org][:uuid]
|
||||
response.status = 403
|
||||
raise(Excon::Errors.status_error({:expects => 200}, response))
|
||||
|
@ -39,7 +43,7 @@ module Fog
|
|||
:href=>make_href("tasksList/#{org_id}"),
|
||||
:xsi_schemaLocation=>xsi_schema_location}
|
||||
|
||||
body[:Tasks] = data[:tasks].map do |task|
|
||||
tasks = data[:tasks].map do |id, task|
|
||||
{:status => task[:status],
|
||||
:startTime => task[:startTime].iso8601,
|
||||
:operationName => task[:operationName],
|
||||
|
@ -48,9 +52,9 @@ module Fog
|
|||
:endTime => task[:endTime].iso8601,
|
||||
:cancelRequested => task[:cancelRequested].to_s,
|
||||
:name => task[:name],
|
||||
:id => "urn:vcloud:task:#{task[:uuid]}",
|
||||
:id => "urn:vcloud:task:#{id}",
|
||||
:type => 'application/vnd.vmware.vcloud.task+xml',
|
||||
:href => make_href("task/#{task[:uuid]}"),
|
||||
:href => make_href("task/#{id}"),
|
||||
:Owner =>
|
||||
{:type => "application/vnd.vmware.vcloud.vApp+xml",
|
||||
:name => "vApp_#{user_name}_0",
|
||||
|
@ -66,6 +70,8 @@ module Fog
|
|||
:Progress => task[:Progress].to_s,
|
||||
:Details => task[:Details] || ''}
|
||||
end
|
||||
tasks = tasks.first if tasks.size == 1
|
||||
body[:Task] = tasks
|
||||
|
||||
response.status = 200
|
||||
response.headers = {'Content-Type' => "#{body[:type]};version=#{api_version}"}
|
||||
|
|
|
@ -25,10 +25,13 @@ module Fog
|
|||
def get_vdc(vdc_id)
|
||||
response = Excon::Response.new
|
||||
|
||||
vdc = data[:vdc]
|
||||
unless vdc_id == vdc[:uuid]
|
||||
unless valid_uuid?(vdc_id)
|
||||
response.status = 400
|
||||
raise Excon::Errors.status_error({:expects => 200}, response)
|
||||
end
|
||||
unless vdc = data[:vdcs][vdc_id]
|
||||
response.status = 403
|
||||
raise(Excon::Errors.status_error({:expects => 200}, response))
|
||||
raise Excon::Errors.status_error({:expects => 200}, response)
|
||||
end
|
||||
|
||||
body =
|
||||
|
@ -36,9 +39,9 @@ module Fog
|
|||
:xmlns_xsi=>xmlns_xsi,
|
||||
:status=>"1",
|
||||
:name=>vdc[:name],
|
||||
:id=>"urn:vcloud:vdc:#{vdc[:uuid]}",
|
||||
:id=>"urn:vcloud:vdc:#{vdc_id}",
|
||||
:type=>"application/vnd.vmware.vcloud.vdc+xml",
|
||||
:href=>make_href("vdc/#{vdc[:uuid]}"),
|
||||
:href=>make_href("vdc/#{vdc_id}"),
|
||||
:xsi_schemaLocation=>xsi_schema_location,
|
||||
:Link=>
|
||||
[{:rel=>"up",
|
||||
|
@ -46,47 +49,47 @@ module Fog
|
|||
:href=>make_href("org/#{data[:org][:uuid]}")},
|
||||
{:rel=>"down",
|
||||
:type=>"application/vnd.vmware.vcloud.metadata+xml",
|
||||
:href=>make_href("vdc/#{vdc[:uuid]}/metadata")},
|
||||
:href=>make_href("vdc/#{vdc_id}/metadata")},
|
||||
{:rel=>"add",
|
||||
:type=>"application/vnd.vmware.vcloud.uploadVAppTemplateParams+xml",
|
||||
:href=>
|
||||
make_href("vdc/#{vdc[:uuid]}/action/uploadVAppTemplate")},
|
||||
make_href("vdc/#{vdc_id}/action/uploadVAppTemplate")},
|
||||
{:rel=>"add",
|
||||
:type=>"application/vnd.vmware.vcloud.media+xml",
|
||||
:href=>make_href("vdc/#{vdc[:uuid]}/media")},
|
||||
:href=>make_href("vdc/#{vdc_id}/media")},
|
||||
{:rel=>"add",
|
||||
:type=>
|
||||
"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml",
|
||||
:href=>
|
||||
make_href("vdc/#{vdc[:uuid]}/action/instantiateVAppTemplate")},
|
||||
make_href("vdc/#{vdc_id}/action/instantiateVAppTemplate")},
|
||||
{:rel=>"add",
|
||||
:type=>"application/vnd.vmware.vcloud.cloneVAppParams+xml",
|
||||
:href=>make_href("vdc/#{vdc[:uuid]}/action/cloneVApp")},
|
||||
:href=>make_href("vdc/#{vdc_id}/action/cloneVApp")},
|
||||
{:rel=>"add",
|
||||
:type=>"application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml",
|
||||
:href=>
|
||||
make_href("vdc/#{vdc[:uuid]}/action/cloneVAppTemplate")},
|
||||
make_href("vdc/#{vdc_id}/action/cloneVAppTemplate")},
|
||||
{:rel=>"add",
|
||||
:type=>"application/vnd.vmware.vcloud.cloneMediaParams+xml",
|
||||
:href=>make_href("vdc/#{vdc[:uuid]}/action/cloneMedia")},
|
||||
:href=>make_href("vdc/#{vdc_id}/action/cloneMedia")},
|
||||
{:rel=>"add",
|
||||
:type=>"application/vnd.vmware.vcloud.captureVAppParams+xml",
|
||||
:href=>make_href("vdc/#{vdc[:uuid]}/action/captureVApp")},
|
||||
:href=>make_href("vdc/#{vdc_id}/action/captureVApp")},
|
||||
{:rel=>"add",
|
||||
:type=>"application/vnd.vmware.vcloud.composeVAppParams+xml",
|
||||
:href=>make_href("vdc/#{vdc[:uuid]}/action/composeVApp")},
|
||||
:href=>make_href("vdc/#{vdc_id}/action/composeVApp")},
|
||||
{:rel=>"add",
|
||||
:type=>"application/vnd.vmware.vcloud.diskCreateParams+xml",
|
||||
:href=>make_href("vdc/#{vdc[:uuid]}/disk")},
|
||||
:href=>make_href("vdc/#{vdc_id}/disk")},
|
||||
{:rel=>"edgeGateways",
|
||||
:type=>"application/vnd.vmware.vcloud.query.records+xml",
|
||||
:href=>make_href("admin/vdc/#{vdc[:uuid]}/edgeGateways")},
|
||||
:href=>make_href("admin/vdc/#{vdc_id}/edgeGateways")},
|
||||
{:rel=>"add",
|
||||
:type=>"application/vnd.vmware.vcloud.orgVdcNetwork+xml",
|
||||
:href=>make_href("admin/vdc/#{vdc[:uuid]}/networks")},
|
||||
:href=>make_href("admin/vdc/#{vdc_id}/networks")},
|
||||
{:rel=>"orgVdcNetworks",
|
||||
:type=>"application/vnd.vmware.vcloud.query.records+xml",
|
||||
:href=>make_href("admin/vdc/#{vdc[:uuid]}/networks")}],
|
||||
:href=>make_href("admin/vdc/#{vdc_id}/networks")}],
|
||||
:Description=>vdc[:description]||'',
|
||||
:AllocationModel=>"AllocationVApp",
|
||||
:ComputeCapacity=>
|
||||
|
@ -115,37 +118,22 @@ module Fog
|
|||
:VmQuota=>"100",
|
||||
:IsEnabled=>"true"}
|
||||
|
||||
# Emulating Fog::ToHashDocument:
|
||||
if data[:networks].size == 1
|
||||
body[:AvailableNetworks][:Network] =
|
||||
[{:type=>"application/vnd.vmware.vcloud.network+xml",
|
||||
:name=>data[:networks].first[:name],
|
||||
:href=>make_href("network/#{data[:networks].first[:name]}")}]
|
||||
else
|
||||
body[:AvailableNetworks][:Network] = data[:networks].map do |network|
|
||||
{:type=>"application/vnd.vmware.vcloud.network+xml",
|
||||
:name=>network[:name],
|
||||
:href=>make_href("network/#{network[:name]}")}
|
||||
end
|
||||
networks = data[:networks].map do |id, network|
|
||||
{:type=>"application/vnd.vmware.vcloud.network+xml",
|
||||
:name=>network[:name],
|
||||
:href=>make_href("network/#{id}")}
|
||||
end
|
||||
networks = networks.first if networks.size == 1
|
||||
body[:AvailableNetworks][:Network] = networks
|
||||
|
||||
# Emulating Fog::ToHashDocument:
|
||||
if data[:catalog_items].size == 1
|
||||
item_type = data[:catalog_items].first[:type]
|
||||
body[:ResourceEntities][:ResourceEntity] =
|
||||
{:type=>"application/vnd.vmware.vcloud.#{item_type}+xml",
|
||||
:name=>data[:catalog_items].first[:name],
|
||||
:href=>
|
||||
make_href("#{item_type}/#{item_type}-#{data[:catalog_items].first[:uuid]}")}
|
||||
else
|
||||
body[:ResourceEntities][:ResourceEntity] = data[:catalog_items].map do |catalog_item|
|
||||
item_type = catalog_item[:type]
|
||||
{:type=>"application/vnd.vmware.vcloud.#{item_type}+xml",
|
||||
:name=>catalog_item[:name],
|
||||
:href=>
|
||||
make_href("#{item_type}/#{item_type}-#{catalog_item[:uuid]}")}
|
||||
end
|
||||
resources = data[:catalog_items].map do |id, item|
|
||||
{:type=>"application/vnd.vmware.vcloud.#{item[:type]}+xml",
|
||||
:name=>item[:name],
|
||||
:href=>
|
||||
make_href("#{item[:type]}/#{item[:type]}-#{id}")}
|
||||
end
|
||||
resources = resources.first if resources.size == 1
|
||||
body[:ResourceEntities][:ResourceEntity] = resources
|
||||
|
||||
if api_version.to_f >= 5.1
|
||||
# TODO
|
||||
|
|
42
tests/vcloud_director/requests/compute/network_tests.rb
Normal file
42
tests/vcloud_director/requests/compute/network_tests.rb
Normal file
|
@ -0,0 +1,42 @@
|
|||
Shindo.tests('Compute::VcloudDirector | network requests', ['vclouddirector']) do
|
||||
|
||||
GET_NETWORK_FORMAT = {
|
||||
:type => String,
|
||||
:name => String,
|
||||
:href => String,
|
||||
:id => String,
|
||||
:description => Fog::Nullable::String,
|
||||
:is_inherited => Fog::Boolean,
|
||||
:gateway => String,
|
||||
:netmask => String,
|
||||
:dns1 => String,
|
||||
:dns2 => String,
|
||||
:dns_suffix => String,
|
||||
:ip_ranges => [{
|
||||
:start_address => String,
|
||||
:end_address => String
|
||||
}]
|
||||
}
|
||||
|
||||
@service = Fog::Compute::VcloudDirector.new
|
||||
|
||||
tests('Get current organization') do
|
||||
session = @service.get_current_session.body
|
||||
link = session[:Link].detect do |l|
|
||||
l[:type] == 'application/vnd.vmware.vcloud.org+xml'
|
||||
end
|
||||
@org = @service.get_organization(link[:href].split('/').last).body
|
||||
end
|
||||
|
||||
tests('#get_network').data_matches_schema(GET_NETWORK_FORMAT) do
|
||||
link = @org[:Link].detect do |l|
|
||||
l[:rel] == 'down' && l[:type] == 'application/vnd.vmware.vcloud.orgNetwork+xml'
|
||||
end
|
||||
@service.get_network(link[:href].split('/').last).body
|
||||
end
|
||||
|
||||
tests('Retrieve non-existent OrgNetwork').raises(Excon::Errors::Forbidden) do
|
||||
@service.get_network('00000000-0000-0000-0000-000000000000')
|
||||
end
|
||||
|
||||
end
|
|
@ -2,6 +2,25 @@ class VcloudDirector
|
|||
module Compute
|
||||
module Schema
|
||||
|
||||
# Mapping of a content media type to a xsd complex type.
|
||||
MEDIA_TYPE_MAPPING_TYPE = {
|
||||
:MediaType => String,
|
||||
:ComplexTypeName => String,
|
||||
:SchemaLocation => String
|
||||
}
|
||||
|
||||
# Information for one version of the API.
|
||||
VERSION_INFO_TYPE = {
|
||||
:Version => String,
|
||||
:LoginUrl => String,
|
||||
:MediaTypeMapping => [MEDIA_TYPE_MAPPING_TYPE]
|
||||
}
|
||||
|
||||
# List all supported versions.
|
||||
SUPPORTED_VERSIONS_TYPE = {
|
||||
:VersionInfo => [VERSION_INFO_TYPE]
|
||||
}
|
||||
|
||||
# The standard error message type used in the vCloud REST API.
|
||||
ERROR_TYPE = {
|
||||
:majorErrorCode => String,
|
||||
|
|
|
@ -4,15 +4,17 @@ Shindo.tests('Compute::VcloudDirector | vdc requests', ['vclouddirector']) do
|
|||
|
||||
tests('Get current organization') do
|
||||
session = @service.get_current_session.body
|
||||
org_href = session[:Link].detect {|l| l[:type] == 'application/vnd.vmware.vcloud.org+xml'}[:href]
|
||||
org_uuid = org_href.split('/').last
|
||||
@org = @service.get_organization(org_uuid).body
|
||||
link = session[:Link].detect do |l|
|
||||
l[:type] == 'application/vnd.vmware.vcloud.org+xml'
|
||||
end
|
||||
@org = @service.get_organization(link[:href].split('/').last).body
|
||||
end
|
||||
|
||||
tests('#get_vdc').data_matches_schema(VcloudDirector::Compute::Schema::VDC_TYPE) do
|
||||
vdc_href = @org[:Link].detect {|l| l[:type] == 'application/vnd.vmware.vcloud.vdc+xml'}[:href]
|
||||
vdc_uuid = vdc_href.split('/').last
|
||||
vdc = @service.get_vdc(vdc_uuid).body
|
||||
link = @org[:Link].detect do |l|
|
||||
l[:rel] == 'down' && l[:type] == 'application/vnd.vmware.vcloud.vdc+xml'
|
||||
end
|
||||
vdc = @service.get_vdc(link[:href].split('/').last).body
|
||||
vdc[:AvailableNetworks][:Network] = [vdc[:AvailableNetworks][:Network]] if vdc[:AvailableNetworks][:Network].is_a?(Hash)
|
||||
vdc[:ResourceEntities][:ResourceEntity] = [vdc[:ResourceEntities][:ResourceEntity]] if vdc[:ResourceEntities][:ResourceEntity].is_a?(Hash)
|
||||
if vdc.has_key?(:VdcStorageProfiles)
|
||||
|
|
|
@ -1,23 +1,8 @@
|
|||
Shindo.tests('Compute::VcloudDirector | versions requests', ['vclouddirector']) do
|
||||
|
||||
SUPPORTED_VERSIONS_FORMAT = {
|
||||
:xmlns => 'http://www.vmware.com/vcloud/versions',
|
||||
:xmlns_xsi => 'http://www.w3.org/2001/XMLSchema-instance',
|
||||
:xsi_schemaLocation => String,
|
||||
:VersionInfo => [{
|
||||
:Version => String,
|
||||
:LoginUrl => String,
|
||||
:MediaTypeMapping => [{
|
||||
:MediaType => String,
|
||||
:ComplexTypeName => String,
|
||||
:SchemaLocation => String
|
||||
}]
|
||||
}]
|
||||
}
|
||||
|
||||
@service = Fog::Compute::VcloudDirector.new
|
||||
|
||||
tests('#get_supported_versions').formats(SUPPORTED_VERSIONS_FORMAT) do
|
||||
tests('#get_supported_versions').formats(VcloudDirector::Compute::Schema::SUPPORTED_VERSIONS_TYPE) do
|
||||
@versions = @service.get_supported_versions.body
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue