lib/vmpooler/providers/vsphere.rb
# The connection_pool method is normally used only for testing
The connection_pool method is normally used only for testing
The connection_pool method is normally used only for testing
def destroy_vm(pool_name, vm_name)
          @connection_pool.with_metrics do |pool_object|
            connection = ensured_vsphere_connection(pool_object)
            vm_object = find_vm(pool_name, vm_name, connection)
            return true if vm_object.nil?
            vm_object.PowerOffVM_Task.wait_for_completion if vm_object.runtime&.powerState && vm_object.runtime.powerState == 'poweredOn'
            vm_object.Destroy_Task.wait_for_completion
          end
          true
        end
def destroy_vm ( pool_name , vm_name ) @connection_pool . with_metrics do | pool_object | connection = ensured_vsphere_connection ( pool_object ) vm_object = find_vm ( pool_name , vm_name , connection ) return true if vm_object . nil? vm_object . PowerOffVM_Task . wait_for_completion if vm_object . runtime &. powerState && vm_object . runtime . powerState == 'poweredOn' vm_object . Destroy_Task . wait_for_completion end true end
The connection_pool method is normally used only for testing
The connection_pool method is normally used only for testing
# If a VM doesn't exist then it is effectively deleted # Poweroff the VM if it's running # Kill it with fire
pool_name
vm_name