def _create_inbuilt_alarms_config(self): self._inbuilt_alarms = {} for table, plugins in self._alarm_plugins.iteritems(): for extn in plugins[table]: alarm_name = camel_case_to_hyphen(extn.obj.__class__.__name__) if self._inbuilt_alarms.has_key(alarm_name): uve_keys = self._inbuilt_alarms[alarm_name].get_uve_keys() uve_keys.uve_key.append(_INVERSE_UVE_MAP[table]) self._inbuilt_alarms[alarm_name].set_uve_keys(uve_keys) else: alarm_or_list = None if extn.obj.rules(): alarm_or_list = [] for and_list in extn.obj.rules()['or_list']: alarm_and_list = [] for exp in and_list['and_list']: alarm_and_list.append( AlarmExpression( operation=exp['operation'], operand1=exp['operand1'], operand2=AlarmOperand2( uve_attribute=exp['operand2'].get( 'uve_attribute'), json_value=exp['operand2'].get( 'json_value')), variables=exp.get('variables'))) alarm_or_list.append(AlarmAndList(alarm_and_list)) desc = ' '.join([l.strip() \ for l in extn.obj.__doc__.splitlines()]) id_perms = IdPermsType(creator='system', description=desc) kwargs = { 'parent_type': 'global-system-config', 'fq_name': ['default-global-system-config', alarm_name] } self._inbuilt_alarms[alarm_name] = Alarm( name=alarm_name, uve_keys=UveKeysType([_INVERSE_UVE_MAP[table]]), alarm_severity=extn.obj.severity(), alarm_rules=AlarmOrList(alarm_or_list), id_perms=id_perms, **kwargs) extn.obj._config = self._inbuilt_alarms[alarm_name] fqname_str = self._fqname_to_str(extn.obj._config.fq_name) uve_keys = [_INVERSE_UVE_MAP[table]] self._update_alarm_config_table(fqname_str, extn.obj, uve_keys, 'CREATE')
def _create_inbuilt_alarms_config(self): self._inbuilt_alarms = {} for table, plugins in self._alarm_plugins.iteritems(): for extn in plugins[table]: alarm_name = camel_case_to_hyphen( extn.obj.__class__.__name__) if self._inbuilt_alarms.has_key(alarm_name): uve_keys = self._inbuilt_alarms[alarm_name].get_uve_keys() uve_keys.uve_key.append(_INVERSE_UVE_MAP[table]) self._inbuilt_alarms[alarm_name].set_uve_keys(uve_keys) else: alarm_or_list = None if extn.obj.rules(): alarm_or_list = [] for and_list in extn.obj.rules()['or_list']: alarm_and_list = [] for exp in and_list['and_list']: alarm_and_list.append(AlarmExpression( operation=exp['operation'], operand1=exp['operand1'], operand2=AlarmOperand2(uve_attribute= exp['operand2'].get('uve_attribute'), json_value=exp['operand2'].get( 'json_value')), variables=exp.get('variables'))) alarm_or_list.append(AlarmAndList(alarm_and_list)) desc = ' '.join([l.strip() \ for l in extn.obj.__doc__.splitlines()]) id_perms = IdPermsType(creator='system', description=desc) kwargs = {'parent_type': 'global-system-config', 'fq_name': ['default-global-system-config', alarm_name]} self._inbuilt_alarms[alarm_name] = Alarm(name=alarm_name, uve_keys=UveKeysType([_INVERSE_UVE_MAP[table]]), alarm_severity=extn.obj.severity(), alarm_rules=AlarmOrList(alarm_or_list), id_perms=id_perms, **kwargs) extn.obj._config = self._inbuilt_alarms[alarm_name] fqname_str = self._fqname_to_str(extn.obj._config.fq_name) uve_keys = [_INVERSE_UVE_MAP[table]] self._update_alarm_config_table(fqname_str, extn.obj, uve_keys, 'CREATE')