diff --git a/lib/fog/vsphere/compute.rb b/lib/fog/vsphere/compute.rb index 5aa38835f..e3f437aef 100644 --- a/lib/fog/vsphere/compute.rb +++ b/lib/fog/vsphere/compute.rb @@ -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 diff --git a/lib/fog/vsphere/requests/compute/find_template_by_instance_uuid.rb b/lib/fog/vsphere/requests/compute/find_template_by_instance_uuid.rb new file mode 100644 index 000000000..3a1776b2d --- /dev/null +++ b/lib/fog/vsphere/requests/compute/find_template_by_instance_uuid.rb @@ -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