def _update_alarm_config_table(self, table, alarm_name, alarm_obj):
     try:
         alarm_table = self._alarm_config[table]
     except KeyError:
         self._alarm_config[table] = {}
         alarm_table = self._alarm_config[table]
     finally:
         if not isinstance(alarm_obj, AlarmBase):
             alarm_base_obj = AlarmBase(alarm_obj.alarm_severity)
             alarm_base_obj.set_config(alarm_obj)
             self._alarm_config[table][alarm_name] = alarm_base_obj
         else:
             self._alarm_config[table][alarm_name] = alarm_obj
 def _update_alarm_config_table(self, alarm_fqname, alarm_obj, uve_keys,
                                operation):
     alarm_config_change_map = {}
     for key in uve_keys:
         uve_type_name = key.split(':', 1)
         try:
             table = UVE_MAP[uve_type_name[0]]
         except KeyError:
             # Use the table name in the config, if there is no mapping
             # in UVE_MAP
             table = uve_type_name[0]
         finally:
             if len(uve_type_name) == 2:
                 uve_key = table + ':' + uve_type_name[1]
             else:
                 uve_key = table
             try:
                 alarm_table = self._alarm_config_db[uve_key]
             except KeyError:
                 self._alarm_config_db[uve_key] = {}
                 alarm_table = self._alarm_config_db[uve_key]
             finally:
                 if operation == 'CREATE' or operation == 'UPDATE':
                     if not isinstance(alarm_obj, AlarmBase):
                         if alarm_table.has_key(alarm_fqname):
                             alarm_table[alarm_fqname].set_config(alarm_obj)
                         else:
                             alarm_base_obj = AlarmBase(config=alarm_obj)
                             alarm_table[alarm_fqname] = alarm_base_obj
                     else:
                         alarm_table[alarm_fqname] = alarm_obj
                 elif operation == 'DELETE':
                     if alarm_table.has_key(alarm_fqname):
                         del alarm_table[alarm_fqname]
                     if not len(alarm_table):
                         del self._alarm_config_db[uve_key]
                 else:
                     assert (0)
                 alarm_config_change_map[uve_key] = {
                     alarm_fqname: operation
                 }
     return alarm_config_change_map
예제 #3
0
 def _update_alarm_config_table(self, alarm_fqname, alarm_obj, uve_keys,
                                operation):
     alarm_config_change_map = {}
     for key in uve_keys:
         uve_type_name = key.split(':', 1)
         try:
             table = UVE_MAP[uve_type_name[0]]
         except KeyError:
             self._logger.error('Invalid uve_key "%s" specified in '
                                'alarm config "%s"' % (key, alarm_fqname))
         else:
             if len(uve_type_name) == 2:
                 uve_key = table + ':' + uve_type_name[1]
             else:
                 uve_key = table
             try:
                 alarm_table = self._alarm_config_db[uve_key]
             except KeyError:
                 self._alarm_config_db[uve_key] = {}
                 alarm_table = self._alarm_config_db[uve_key]
             finally:
                 if operation == 'CREATE' or operation == 'UPDATE':
                     if not isinstance(alarm_obj, AlarmBase):
                         if alarm_table.has_key(alarm_fqname):
                             alarm_table[alarm_fqname].set_config(alarm_obj)
                         else:
                             alarm_base_obj = AlarmBase(config=alarm_obj)
                             alarm_table[alarm_fqname] = alarm_base_obj
                     else:
                         alarm_table[alarm_fqname] = alarm_obj
                 elif operation == 'DELETE':
                     if alarm_table.has_key(alarm_fqname):
                         del alarm_table[alarm_fqname]
                     if not len(alarm_table):
                         del self._alarm_config_db[uve_key]
                 else:
                     assert (0)
                 alarm_config_change_map[uve_key] = {
                     alarm_fqname: operation
                 }
     return alarm_config_change_map
예제 #4
0
 def _update_alarm_config_table(self, alarm_fqname, alarm_obj, uve_keys,
                                operation):
     alarm_config_change_map = {}
     for key in uve_keys:
         try:
             table = UVE_MAP[key]
         except KeyError:
             self._logger(
                 'Invalid table name "%s" specified in '
                 'alarm config "%s"' % (key, alarm_fqname),
                 SandeshLevel.SYS_ERR)
         else:
             try:
                 alarm_table = self._alarm_config_db[table]
             except KeyError:
                 self._alarm_config_db[table] = {}
                 alarm_table = self._alarm_config_db[table]
             finally:
                 if operation == 'CREATE' or operation == 'UPDATE':
                     if not isinstance(alarm_obj, AlarmBase):
                         if alarm_table.has_key(alarm_fqname):
                             alarm_table[alarm_fqname].set_config(alarm_obj)
                         else:
                             alarm_base_obj = AlarmBase(config=alarm_obj)
                             alarm_table[alarm_fqname] = alarm_base_obj
                     else:
                         alarm_table[alarm_fqname] = alarm_obj
                 elif operation == 'DELETE':
                     if alarm_table.has_key(alarm_fqname):
                         del alarm_table[alarm_fqname]
                     if not len(alarm_table):
                         del self._alarm_config_db[table]
                 else:
                     assert (0)
                 alarm_config_change_map[table] = {alarm_fqname: operation}
     return alarm_config_change_map