mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Add Mock for get_vms_in_lease_from_query
The only option implemented here is a filter by href as that is all we need for our tests. It can easily be extended as required.
This commit is contained in:
parent
6fabfd0423
commit
9edaed0985
2 changed files with 56 additions and 1 deletions
|
@ -90,6 +90,61 @@ module Fog
|
|||
response
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_vms_in_lease_from_query(options={})
|
||||
|
||||
if options.key?(:filter) && options[:filter] =~ /^href==([^;,]+)$/
|
||||
href = $1
|
||||
id = href.split('/').last
|
||||
else
|
||||
Fog::Mock.not_implemented("Filter by href is currently the only option implemented in get_vms_in_lease_from_query Mock")
|
||||
end
|
||||
|
||||
vm = data[:vms][id]
|
||||
parent_vapp_id = vm[:parent_vapp]
|
||||
vdc_id = data[:vapps][parent_vapp_id][:vdc_id]
|
||||
|
||||
body = {
|
||||
:xmlns=>xmlns,
|
||||
:xmlns_xsi=>xmlns_xsi,
|
||||
:href=>make_href('query'),
|
||||
:name=>"vm",
|
||||
:type=>"application/vnd.vmware.vcloud.query.records+xml",
|
||||
:xsi_schemaLocation=>xsi_schema_location,
|
||||
:total=>"1",
|
||||
:pageSize=>"25",
|
||||
:page=>"1",
|
||||
:Link=>
|
||||
[{:rel=>"alternate",
|
||||
:type=>"application/vnd.vmware.vcloud.query.references+xml",
|
||||
:href=>make_href('query')},
|
||||
{:rel=>"alternate",
|
||||
:type=>"application/vnd.vmware.vcloud.query.idrecords+xml",
|
||||
:href=>make_href('query')}],
|
||||
:VMRecord=>
|
||||
[{:vdc=>make_href(vdc_id),
|
||||
:numberOfCpus=>vm[:cpu_count],
|
||||
:name=>vm[:name],
|
||||
:containerName=>data[:vapps][parent_vapp_id][:name],
|
||||
:memoryMB=>vm[:memory_in_mb],
|
||||
:isVAppTemplate=>"false",
|
||||
:href=>make_href(id),
|
||||
:taskStatus=>"success",
|
||||
:task=>make_href("task/#{uuid}"),
|
||||
:taskDetails=>" ",
|
||||
:taskStatusName=>"vappUpdateVm"}]
|
||||
}
|
||||
|
||||
Excon::Response.new(
|
||||
:status => 200,
|
||||
:headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
|
||||
:body => body
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -130,6 +130,7 @@ module Fog
|
|||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def post_instantiate_vapp_template(vdc_id, vapp_template_id, name, options={})
|
||||
unless data[:vdcs][vdc_id]
|
||||
raise Fog::Compute::VcloudDirector::Forbidden.new(
|
||||
|
@ -190,7 +191,6 @@ module Fog
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue