

def _wait_for_state_change(target_state, ucs_power_handle):
    'Wait and check for the power state change.'
    state = [None]
    retries = [0]

    def _wait(state, retries):
        state[0] = ucs_power_handle.get_power_state()
        if ((retries[0] != 0) and (UCS_TO_IRONIC_POWER_STATE.get(state[0]) == target_state)):
            raise loopingcall.LoopingCallDone()
        if (retries[0] > CONF.cisco_ucs.max_retry):
            state[0] = states.ERROR
            raise loopingcall.LoopingCallDone()
        retries[0] += 1
    timer = loopingcall.FixedIntervalLoopingCall(_wait, state, retries)
    ucs_power_handle.start(interval=CONF.cisco_ucs.action_interval).wait()
    return UCS_TO_IRONIC_POWER_STATE.get(state[0], states.ERROR)

dataset/ETHPy150Open openstack/ironic/ironic/drivers/modules/ucs/power.py _wait_for_state_change/VarMisuse@138/205 `timer`->`ucs_power_handle`