1
0
Fork 0
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:
Jeff McCune 2011-09-06 16:44:03 -07:00
parent 4264b1f99c
commit 856eb7e033
2 changed files with 28 additions and 0 deletions

View file

@ -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

View file

@ -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