def suspend(self, instance, callback):
        vm_ref = self._get_vm_ref_from_the_name(instance.name)
        if vm_ref is None:
            raise exception.InstanceNotFound(instance_id=instance.id)

        pwr_state = self._session._call_method(vim_util,
                    "get_dynamic_property", vm_ref,
                    "VirtualMachine", "runtime.powerState")
        # Only PoweredOn VMs can be suspended.
        if pwr_state == "poweredOn":
            LOG.debug(_("Suspending the VM %s ") % instance.name)
            suspend_task = self._session._call_method(self._session._get_vim(),
                    "SuspendVM_Task", vm_ref)
            self._wait_with_callback(instance.id, suspend_task, callback)
            LOG.debug(_("Suspended the VM %s ") % instance.name)
        # Raise Exception if VM is poweredOff
        elif pwr_state == "poweredOff":
            reason = _("instance is powered off and can not be suspended.")
            raise exception.InstanceSuspendFailure(reason=reason)

        LOG.debug(_("VM %s was already in suspended state. So returning "
                    "without doing anything") % instance.name)
Suspend the specified instance.
dataset/ETHPy150Open nii-cloud/dodai-compute/nova/virt/vmwareapi/vmops.py/VMWareVMOps.suspend