From fd93c5bea8967ac8380af8c92dcce67f436a5558 Mon Sep 17 00:00:00 2001 From: Glenn Sarti Date: Mon, 13 Mar 2017 17:11:33 -0700 Subject: [PATCH] (GH-203) Change use of abort to raise in in vsphere_helper.rb Previously, in `find_vm` and `find_pool` if in an expected object was found the entire pool manager, and probably API process, will terminate due to the use of `abort`. This commit changes the use of abort to raise so that the error can be trapped and handled instead of the entire process being shutdown. This is also required so that the methods can be tested, otherwise rspec is shutdown prematurely. --- lib/vmpooler/vsphere_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/vmpooler/vsphere_helper.rb b/lib/vmpooler/vsphere_helper.rb index 68db65d..3ad8843 100644 --- a/lib/vmpooler/vsphere_helper.rb +++ b/lib/vmpooler/vsphere_helper.rb @@ -181,7 +181,7 @@ module Vmpooler if base.is_a? RbVmomi::VIM::Folder base = base.childEntity.find { |f| f.name == folder } else - abort "Unexpected object type encountered (#{base.class}) while finding folder" + raise(RuntimeError, "Unexpected object type encountered (#{base.class}) while finding folder") end end @@ -284,7 +284,7 @@ module Vmpooler when base.is_a?(RbVmomi::VIM::ResourcePool) base = base.resourcePool.find { |f| f.name == pool } else - abort "Unexpected object type encountered (#{base.class}) while finding resource pool" + raise(RuntimeError, "Unexpected object type encountered (#{base.class}) while finding resource pool") end end