Merge "add operational severity to alarms table"

This commit is contained in:
Zuul 2018-08-09 16:51:28 +00:00 committed by Gerrit Code Review
commit 140b631e36
4 changed files with 15 additions and 9 deletions

View File

@ -232,8 +232,8 @@ def _is_alarm_severity_change(before, curr):
return False return False
# returns true on activation, deactivation and severity change # returns true on activation, deactivation and severity change
if not before and curr \ if not before and curr \
or (before.get(VProps.VITRAGE_AGGREGATED_SEVERITY) != or (before.get(VProps.VITRAGE_OPERATIONAL_SEVERITY) !=
curr.get(VProps.VITRAGE_AGGREGATED_SEVERITY)): curr.get(VProps.VITRAGE_OPERATIONAL_SEVERITY)):
return True return True
return False return False

View File

@ -102,6 +102,8 @@ class VitragePersistorEndpoint(object):
vitrage_type=data.get(VProps.VITRAGE_TYPE), vitrage_type=data.get(VProps.VITRAGE_TYPE),
vitrage_aggregated_severity=data.get( vitrage_aggregated_severity=data.get(
VProps.VITRAGE_AGGREGATED_SEVERITY), VProps.VITRAGE_AGGREGATED_SEVERITY),
vitrage_operational_severity=data.get(
VProps.VITRAGE_OPERATIONAL_SEVERITY),
project_id=data.get(VProps.PROJECT_ID), project_id=data.get(VProps.PROJECT_ID),
vitrage_resource_type=data.get(VProps.VITRAGE_RESOURCE_TYPE), vitrage_resource_type=data.get(VProps.VITRAGE_RESOURCE_TYPE),
vitrage_resource_id=data.get(VProps.VITRAGE_RESOURCE_ID), vitrage_resource_id=data.get(VProps.VITRAGE_RESOURCE_ID),
@ -147,7 +149,7 @@ class VitragePersistorEndpoint(object):
models.Change( models.Change(
vitrage_id=data.get(VProps.VITRAGE_ID), vitrage_id=data.get(VProps.VITRAGE_ID),
timestamp=event_timestamp, timestamp=event_timestamp,
severity=data.get(VProps.VITRAGE_AGGREGATED_SEVERITY), severity=data.get(VProps.VITRAGE_OPERATIONAL_SEVERITY),
payload=data) payload=data)
self.db.changes.create(change_row) self.db.changes.create(change_row)

View File

@ -68,15 +68,15 @@ class HistoryFacadeConnection(object):
query, project_id, is_admin_project) query, project_id, is_admin_project)
query_severe = query.filter( query_severe = query.filter(
models.Alarm.vitrage_aggregated_severity == OSeverity.SEVERE) models.Alarm.vitrage_operational_severity == OSeverity.SEVERE)
query_critical = query.filter( query_critical = query.filter(
models.Alarm.vitrage_aggregated_severity == OSeverity.CRITICAL) models.Alarm.vitrage_operational_severity == OSeverity.CRITICAL)
query_warning = query.filter( query_warning = query.filter(
models.Alarm.vitrage_aggregated_severity == OSeverity.WARNING) models.Alarm.vitrage_operational_severity == OSeverity.WARNING)
query_ok = query.filter( query_ok = query.filter(
models.Alarm.vitrage_aggregated_severity == OSeverity.OK) models.Alarm.vitrage_operational_severity == OSeverity.OK)
query_na = query.filter( query_na = query.filter(
models.Alarm.vitrage_aggregated_severity == OSeverity.NA) models.Alarm.vitrage_operational_severity == OSeverity.NA)
counts = {OSeverity.SEVERE: query_severe.count(), counts = {OSeverity.SEVERE: query_severe.count(),
OSeverity.CRITICAL: query_critical.count(), OSeverity.CRITICAL: query_critical.count(),
@ -258,8 +258,8 @@ class HistoryFacadeConnection(object):
@staticmethod @staticmethod
def _add_time_frame_to_query(query, start, end): def _add_time_frame_to_query(query, start, end):
start = timeutils.normalize_time(start) start = timeutils.normalize_time(start)
end = timeutils.normalize_time(end)
if start and end: if start and end:
end = timeutils.normalize_time(end)
query = \ query = \
query.filter( query.filter(
or_(and_(models.Alarm.start_timestamp >= start, or_(and_(models.Alarm.start_timestamp >= start,

View File

@ -238,6 +238,8 @@ class Alarm(Base):
vitrage_type = Column(String(64), nullable=False) vitrage_type = Column(String(64), nullable=False)
vitrage_aggregated_severity = Column(String(64), index=True, vitrage_aggregated_severity = Column(String(64), index=True,
nullable=False) nullable=False)
vitrage_operational_severity = Column(String(64), index=True,
nullable=False)
project_id = Column(String(64), index=True) project_id = Column(String(64), index=True)
vitrage_resource_type = Column(String(64)) vitrage_resource_type = Column(String(64))
vitrage_resource_id = Column(String(64)) vitrage_resource_id = Column(String(64))
@ -253,6 +255,7 @@ class Alarm(Base):
"name='%s'," \ "name='%s'," \
"vitrage_type='%s'," \ "vitrage_type='%s'," \
"vitrage_aggregated_severity='%s'," \ "vitrage_aggregated_severity='%s'," \
"vitrage_operational_severity='%s'," \
"project_id='%s'," \ "project_id='%s'," \
"vitrage_resource_type='%s'," \ "vitrage_resource_type='%s'," \
"vitrage_resource_id='%s'," \ "vitrage_resource_id='%s'," \
@ -265,6 +268,7 @@ class Alarm(Base):
self.name, self.name,
self.vitrage_type, self.vitrage_type,
self.vitrage_aggregated_severity, self.vitrage_aggregated_severity,
self.vitrage_operational_severity,
self.project_id, self.project_id,
self.vitrage_resource_type, self.vitrage_resource_type,
self.vitrage_resource_id, self.vitrage_resource_id,