mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
(#9241) Add find_template_by_instance_uuid request
Without this patch we did not have a convenient way to find a template by instance UUID. We could only find virtual machines by instance UUID, which may or may not be a template. This patch adds a specific request to obtain the VMware managed object instance of of a specific template. This is necessary plumbing for the clone request.
This commit is contained in:
parent
4264b1f99c
commit
856eb7e033
2 changed files with 28 additions and 0 deletions
|
@ -21,6 +21,7 @@ module Fog
|
|||
request :vm_destroy
|
||||
request :find_all_by_uuid
|
||||
request :find_all_by_instance_uuid
|
||||
request :find_template_by_instance_uuid
|
||||
|
||||
class Mock
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Vsphere
|
||||
class Real
|
||||
|
||||
def find_template_by_instance_uuid(instance_uuid)
|
||||
vm = list_virtual_machines.detect(lambda { raise Fog::Vsphere::Errors::NotFound }) do |vm|
|
||||
vm.config.instanceUuid == instance_uuid
|
||||
end
|
||||
unless vm.config.template
|
||||
raise Fog::Vsphere::Errors::NotFound, "VM with Instance UUID #{instance_uuid} is not a template."
|
||||
end
|
||||
vm
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def find_template_by_instance_uuid(instance_uuid)
|
||||
Fog::Mock.not_implmented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue