'Sets power state for the VM.'

def _set_power_state(self, method, vm_ref, pwr_state='poweredOn'):

    if (_db_content.get('VirtualMachine', None) is None):
        raise exception.NotFound('No    Virtual    Machine    has    been    registered    yet')
    if (vm_ref not in _db_content.get('VirtualMachine')):
        raise exception.NotFound(('Virtual    Machine    with    ref    %s    is    not    there' % vm_ref))
    vm_mdo = _db_content.get('VirtualMachine').get(vm_ref)
    vm_mdo.set('runtime.powerState', pwr_state)
    task_mdo = create_task(method, 'success')
    return task_mdo.obj
