'Suspend the specified instance.'

def suspend(self, instance):

    vm_ref = vm_util.get_vm_ref(self._session, instance)
    pwr_state = self._session._call_method(vutil, 'get_object_property', vm_ref, 'runtime.powerState')
    if (pwr_state == 'poweredOn'):
        LOG.debug('Suspending    the    VM', instance=instance)
        suspend_task = self._session._call_method(self._session.vim, 'SuspendVM_Task', vm_ref)
        self._session._wait_for_task(suspend_task)
        LOG.debug('Suspended    the    VM', instance=instance)
    elif (pwr_state == 'poweredOff'):
        reason = _('instance    is    powered    off    and    cannot    be    suspended.')
        raise exception.InstanceSuspendFailure(reason=reason)
    else:
        LOG.debug('VM    was    already    in    suspended    state.    So    returning    without    doing    anything', instance=instance)
