(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.
This commit is contained in:
Glenn Sarti 2017-03-13 17:11:33 -07:00
parent 07eb4f579a
commit fd93c5bea8

View file

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