

def _wait_for_state_change(target_state, task):
    'Wait and check for the power state change\n\n    :param target_state: The target state we are waiting for.\n    :param task: a TaskManager instance containing the node to act on.\n    :raises: CIMCException if there is an error communicating with CIMC\n    '
    store = {
        'state': None,
        'retries': CONF.cimc.max_retry,
    }

    def _wait(store):
        current_power_state = None
        with common.cimc_handle(task) as handle:
            try:
                rack_unit = handle.get_imc_managedobject(None, None, params={
                    'Dn': 'sys/rack-unit-1',
                })
            except imcsdk.ImcException as e:
                raise exception.CIMCException(node=task.node.uuid, error=e)
            else:
                current_power_state = rack_unit[0].get_attr('OperPower')
        store['state'] = CIMC_TO_IRONIC_POWER_STATE.get(current_power_state)
        if (store['state'] == target_state):
            raise loopingcall.LoopingCallDone()
        store['retries'] -= 1
        if (store['retries'] <= 0):
            store['state'] = states.ERROR
            raise loopingcall.LoopingCallDone()
    timer = loopingcall.FixedIntervalLoopingCall(_wait, task)
    timer.start(interval=CONF.cimc.action_interval).wait()
    return store['state']

dataset/ETHPy150Open openstack/ironic/ironic/drivers/modules/cimc/power.py _wait_for_state_change/VarMisuse@209/406 `store`->`task`