Example #1
0
    def _wait_for_power_status(mutable):

        if mutable['retries'] > CONF.iboot.max_retry:
            LOG.warning(
                _LW('Reached maximum number of attempts (%(attempts)d) to get '
                    'power state for node %(node)s'), {
                        'attempts': mutable['retries'],
                        'node': driver_info['uuid']
                    })
            raise loopingcall.LoopingCallDone()

        try:
            mutable['retries'] += 1
            response = conn.get_relays()
            status = response[relay_id - 1]
            if status:
                mutable['state'] = states.POWER_ON
            else:
                mutable['state'] = states.POWER_OFF
            raise loopingcall.LoopingCallDone()
        except (TypeError, IndexError):
            LOG.warning(
                _LW("Cannot get power state for node '%(node)s' at "
                    "relay '%(relay)s'. iBoot get_relays() failed."), {
                        'node': driver_info['uuid'],
                        'relay': relay_id
                    })
Example #2
0
    def _wait(status):
        status['power'] = _power_status(node)
        if status['power'] == target_state:
            raise loopingcall.LoopingCallDone()

        if status['iter'] >= CONF.amt_driver.max_attempts:
            status['power'] = states.ERROR
            LOG.warning(
                _LW("AMT failed to set power state %(state)s after "
                    "%(tries)s retries on node %(node_id)s."), {
                        'state': target_state,
                        'tries': status['iter'],
                        'node_id': node.uuid
                    })
            raise loopingcall.LoopingCallDone()

        try:
            _set_power_state(node, target_state)
        except Exception:
            # Log failures but keep trying
            LOG.warning(
                _LW("AMT set power state %(state)s for node %(node)s "
                    "- Attempt %(attempt)s times of %(max_attempt)s "
                    "failed."), {
                        'state': target_state,
                        'node': node.uuid,
                        'attempt': status['iter'] + 1,
                        'max_attempt': CONF.amt_driver.max_attempts
                    })
        status['iter'] += 1
Example #3
0
def parse_statistics(raw_data):
    """Parse statistics data."""
    statistics = {}
    raw_int = _raw_to_int(raw_data)

    statistics_values = struct.unpack('<HHHHII', bytearray(
                                      raw_int[3:19]))
    statistics_names = ('current_value', 'minimum_value',
                        'maximum_value', 'average_value',
                        'timestamp', 'reporting_period')
    _add_to_dict(statistics, statistics_values, statistics_names)
    try:
        isotime = _ipmi_timestamp_to_isotime(statistics['timestamp'])
    except exception.InvalidIPMITimestamp as e:
        # there is not "bad time" in standard, reset to start the epoch
        statistics['timestamp'] = _INVALID_TIME
        LOG.warning(_LW('Invalid timestamp in Node Nanager statistics '
                        'data: %s'), six.text_type(e))
    else:
        statistics['timestamp'] = isotime

    statistics['domain_id'] = DOMAINS_REV[raw_int[19] & 0x0F]
    statistics['administrative_enabled'] = bool(raw_int[19] & 0x10)
    statistics['operational_state'] = bool(raw_int[19] & 0x20)
    statistics['measurement_state'] = bool(raw_int[19] & 0x40)
    statistics['activation_state'] = bool(raw_int[19] & 0x80)

    return statistics
    def _wait_for_switch(mutable):
        if mutable['retries'] > CONF.iboot.max_retry:
            LOG.warning(_LW(
                'Reached maximum number of attempts (%(attempts)d) to set '
                'power state for node %(node)s to "%(op)s"'),
                {'attempts': mutable['retries'], 'node': driver_info['uuid'],
                 'op': states.POWER_ON if enabled else states.POWER_OFF})
            raise loopingcall.LoopingCallDone()

        try:
            mutable['retries'] += 1
            mutable['response'] = conn.switch(relay_id, enabled)
            if mutable['response']:
                raise loopingcall.LoopingCallDone()
        except (TypeError, IndexError):
            LOG.warning(_LW("Cannot call set power state for node '%(node)s' "
                            "at relay '%(relay)s'. iBoot switch() failed."),
                        {'node': driver_info['uuid'], 'relay': relay_id})
    def _wait_for_power_status(mutable):

        if mutable['retries'] > CONF.iboot.max_retry:
            LOG.warning(_LW(
                'Reached maximum number of attempts (%(attempts)d) to get '
                'power state for node %(node)s'),
                {'attempts': mutable['retries'], 'node': driver_info['uuid']})
            raise loopingcall.LoopingCallDone()

        try:
            mutable['retries'] += 1
            response = conn.get_relays()
            status = response[relay_id - 1]
            if status:
                mutable['state'] = states.POWER_ON
            else:
                mutable['state'] = states.POWER_OFF
            raise loopingcall.LoopingCallDone()
        except (TypeError, IndexError):
            LOG.warning(_LW("Cannot get power state for node '%(node)s' at "
                            "relay '%(relay)s'. iBoot get_relays() failed."),
                        {'node': driver_info['uuid'], 'relay': relay_id})
Example #6
0
    def _wait_for_switch(mutable):
        if mutable['retries'] > CONF.iboot.max_retry:
            LOG.warning(
                _LW('Reached maximum number of attempts (%(attempts)d) to set '
                    'power state for node %(node)s to "%(op)s"'), {
                        'attempts': mutable['retries'],
                        'node': driver_info['uuid'],
                        'op': states.POWER_ON if enabled else states.POWER_OFF
                    })
            raise loopingcall.LoopingCallDone()

        try:
            mutable['retries'] += 1
            mutable['response'] = conn.switch(relay_id, enabled)
            if mutable['response']:
                raise loopingcall.LoopingCallDone()
        except (TypeError, IndexError):
            LOG.warning(
                _LW("Cannot call set power state for node '%(node)s' "
                    "at relay '%(relay)s'. iBoot switch() failed."), {
                        'node': driver_info['uuid'],
                        'relay': relay_id
                    })
    def _wait(status):
        status['power'] = _power_status(node)
        if status['power'] == target_state:
            raise loopingcall.LoopingCallDone()

        if status['iter'] >= CONF.amt_driver.max_attempts:
            status['power'] = states.ERROR
            LOG.warning(_LW("AMT failed to set power state %(state)s after "
                            "%(tries)s retries on node %(node_id)s."),
                        {'state': target_state, 'tries': status['iter'],
                         'node_id': node.uuid})
            raise loopingcall.LoopingCallDone()

        try:
            _set_power_state(node, target_state)
        except Exception:
            # Log failures but keep trying
            LOG.warning(_LW("AMT set power state %(state)s for node %(node)s "
                            "- Attempt %(attempt)s times of %(max_attempt)s "
                            "failed."),
                        {'state': target_state, 'node': node.uuid,
                         'attempt': status['iter'] + 1,
                         'max_attempt': CONF.amt_driver.max_attempts})
        status['iter'] += 1