Beispiel #1
0
    def get_alarms_degrade(self,
                           context,
                           alarm_ignore_list=[],
                           entity_instance_id_filter=""):
        """Return all the alarms that cause the degrade"""
        db_alarms = fmclient(context).alarm.list(include_suppress=True)
        degrade_alarms = []

        for db_alarm in db_alarms:
            if isinstance(db_alarm, tuple):
                alarm = db_alarm[0]
                degrade_affecting = db_alarm[constants.DB_DEGRADE_AFFECTING]
            else:
                alarm = db_alarm
                degrade_affecting = db_alarm.degrade_affecting
            # Ignore alarms that are part of the ignore list sent as parameter
            # and also filter the alarms bases on entity instance id.
            # If multiple alarms with the same ID exist, we only return the ID
            # one time.
            if degrade_affecting == 'True':
                if (entity_instance_id_filter in alarm.entity_instance_id
                        and alarm.alarm_id not in alarm_ignore_list
                        and alarm.alarm_id not in degrade_alarms):
                    degrade_alarms.append(alarm.alarm_id)
        return degrade_alarms
Beispiel #2
0
    def _check_alarms(self, context, force=False):
        """Checks that no alarms are active"""
        alarms = fmclient(context).alarm.list(include_suppress=True)

        success = True
        allowed = 0
        affecting = 0
        # Separate alarms that are mgmt affecting
        for alarm in alarms:
            mgmt_affecting = alarm.mgmt_affecting == "True"
            if not mgmt_affecting:
                allowed += 1
                if not force:
                    success = False
            else:
                affecting += 1
                success = False

        return success, allowed, affecting
Beispiel #3
0
    def get_alarms_degrade(self, context, alarm_ignore_list=None,
            entity_instance_id_filter=""):
        """Return all the alarms that cause the degrade"""
        alarms = fmclient(context).alarm.list(include_suppress=True)
        degrade_alarms = []
        if alarm_ignore_list is None:
            alarm_ignore_list = []

        for alarm in alarms:
            degrade_affecting = alarm.degrade_affecting
            # Ignore alarms that are part of the ignore list sent as parameter
            # and also filter the alarms bases on entity instance id.
            # If multiple alarms with the same ID exist, we only return the ID
            # one time.
            if degrade_affecting == 'True':
                if (entity_instance_id_filter in alarm.entity_instance_id and
                        alarm.alarm_id not in alarm_ignore_list and
                        alarm.alarm_id not in degrade_alarms):
                    degrade_alarms.append(alarm.alarm_id)
        return degrade_alarms
Beispiel #4
0
    def _check_alarms(self, context, force=False):
        """Checks that no alarms are active"""
        db_alarms = fmclient(context).alarm.list(include_suppress=True)

        success = True
        allowed = 0
        affecting = 0
        # Only fail if we find alarms past their affecting threshold
        for db_alarm in db_alarms:
            if isinstance(db_alarm, tuple):
                alarm = db_alarm[0]
                mgmt_affecting = db_alarm[constants.DB_MGMT_AFFECTING]
            else:
                alarm = db_alarm
                mgmt_affecting = db_alarm.mgmt_affecting
            if fm_api.FaultAPIs.alarm_allowed(alarm.severity, mgmt_affecting):
                allowed += 1
                if not force:
                    success = False
            else:
                affecting += 1
                success = False

        return success, allowed, affecting