'Waiting for a VM to be in a disabled state.
:return: True if the instance is shutdown within time_limit,
False otherwise.'

def _wait_for_power_off(self, instance_name, time_limit):

    desired_vm_states = [os_win_const.HYPERV_VM_STATE_DISABLED]
    def _check_vm_status(instance_name):
        if (self._get_vm_state(instance_name) in desired_vm_states):
            raise loopingcall.LoopingCallDone()
    periodic_call = loopingcall.FixedIntervalLoopingCall(_check_vm_status, instance_name)
    try:
        periodic_call.start(interval=SHUTDOWN_TIME_INCREMENT)
        etimeout.with_timeout(time_limit, periodic_call.wait)
    except etimeout.Timeout:
        return False
    finally:
        periodic_call.stop()
    return True
