code: def unregister_vm(vm_ref):
      '''
      Destroys the virtual machine
  
      vm_ref
          Managed object reference of a virtual machine object
      '''
      vm_name = get_managed_object_name(vm_ref)
      log.trace('Destroying vm \'%s\'', vm_name)
      try:
          vm_ref.UnregisterVM()
      except vim.fault.NoPermission as exc:
          log.exception(exc)
          raise salt.exceptions.VMwareApiError(
              'Not enough permissions. Required privilege: '
              '{}'.format(exc.privilegeId))
      except vim.fault.VimFault as exc:
          raise salt.exceptions.VMwareApiError(exc.msg)
      except vmodl.RuntimeFault as exc:
          raise salt.exceptions.VMwareRuntimeError(exc.msgf unregister_vm(vm_ref):
      '''
      Destroys the virtual machine
  
      vm_ref
          Managed object reference of a virtual machine object
      '''
      vm_name = get_managed_object_name(vm_ref)
      log.trace('Destroying vm \'%s\'', vm_name)
      try:
          vm_ref.UnregisterVM()
      except vim.fault.NoPermission as exc:
          log.exception(exc)
          raise salt.exceptions.VMwareApiError(
              'Not enough permissions. Required privilege: '
              '{}'.format(exc.privilegeId))
      except vim.fault.VimFault as exc:
          raise salt.exceptions.VMwareApiError(exc.msg)
      except vmodl.RuntimeFault as exc:
          raise salt.exceptions.VMwareRuntimeError(exc.msg)
docs: Destroys the virtual machine
  
      vm_ref
          Managed object reference of a virtual machine object