Base Alarm history persistence model
Provides the storage model and non-implemented hooks into the storage drivers as a placeholder. Partially implements bp alarm-audit-api Change-Id: I950bef5f01e545982709bfb78a2364fb8d4def7b
This commit is contained in:
parent
9adbc082b2
commit
e775ac06c6
@ -205,6 +205,19 @@ class Connection(object):
|
|||||||
"""Delete a alarm
|
"""Delete a alarm
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@abc.abstractmethod
|
||||||
|
def get_alarm_changes(self, alarm_id, on_behalf_of):
|
||||||
|
"""Yields list of AlarmChanges describing alarm history
|
||||||
|
:param alarm_id: ID of alarm to return changes for
|
||||||
|
:param on_behalf_of: ID of tenant to scope changes query (None for
|
||||||
|
administrative user, indicating all projects)
|
||||||
|
"""
|
||||||
|
|
||||||
|
@abc.abstractmethod
|
||||||
|
def record_alarm_change(self, alarm_change):
|
||||||
|
"""Record alarm change event.
|
||||||
|
"""
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def clear(self):
|
def clear(self):
|
||||||
"""Clear database."""
|
"""Clear database."""
|
||||||
|
@ -616,6 +616,19 @@ class Connection(base.Connection):
|
|||||||
"""
|
"""
|
||||||
self.db.alarm.remove({'alarm_id': alarm_id})
|
self.db.alarm.remove({'alarm_id': alarm_id})
|
||||||
|
|
||||||
|
def get_alarm_changes(self, alarm_id, on_behalf_of):
|
||||||
|
"""Yields list of AlarmChanges describing alarm history
|
||||||
|
:param alarm_id: ID of alarm to return changes for
|
||||||
|
:param on_behalf_of: ID of tenant to scope changes query (None for
|
||||||
|
administrative user, indicating all projects)
|
||||||
|
"""
|
||||||
|
raise NotImplementedError('Alarm history not implemented')
|
||||||
|
|
||||||
|
def record_alarm_change(self, alarm_change):
|
||||||
|
"""Record alarm change event.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError('Alarm history not implemented')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def record_events(events):
|
def record_events(events):
|
||||||
"""Write the events.
|
"""Write the events.
|
||||||
|
@ -609,6 +609,19 @@ class Connection(base.Connection):
|
|||||||
"""
|
"""
|
||||||
raise NotImplementedError('Alarms not implemented')
|
raise NotImplementedError('Alarms not implemented')
|
||||||
|
|
||||||
|
def get_alarm_changes(self, alarm_id, on_behalf_of):
|
||||||
|
"""Yields list of AlarmChanges describing alarm history
|
||||||
|
:param alarm_id: ID of alarm to return changes for
|
||||||
|
:param on_behalf_of: ID of tenant to scope changes query (None for
|
||||||
|
administrative user, indicating all projects)
|
||||||
|
"""
|
||||||
|
raise NotImplementedError('Alarm history not implemented')
|
||||||
|
|
||||||
|
def record_alarm_change(self, alarm_change):
|
||||||
|
"""Record alarm change event.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError('Alarm history not implemented')
|
||||||
|
|
||||||
def delete_alarm(self, alarm_id):
|
def delete_alarm(self, alarm_id):
|
||||||
"""Delete a alarm
|
"""Delete a alarm
|
||||||
"""
|
"""
|
||||||
|
@ -175,6 +175,19 @@ class Connection(base.Connection):
|
|||||||
"""Delete a alarm
|
"""Delete a alarm
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def get_alarm_changes(self, alarm_id, on_behalf_of):
|
||||||
|
"""Yields list of AlarmChanges describing alarm history
|
||||||
|
:param alarm_id: ID of alarm to return changes for
|
||||||
|
:param on_behalf_of: ID of tenant to scope changes query (None for
|
||||||
|
administrative user, indicating all projects)
|
||||||
|
"""
|
||||||
|
raise NotImplementedError('Alarm history not implemented')
|
||||||
|
|
||||||
|
def record_alarm_change(self, alarm_change):
|
||||||
|
"""Record alarm change event.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError('Alarm history not implemented')
|
||||||
|
|
||||||
def record_events(self, events):
|
def record_events(self, events):
|
||||||
"""Write the events.
|
"""Write the events.
|
||||||
|
|
||||||
|
@ -865,6 +865,19 @@ class Connection(base.Connection):
|
|||||||
"""
|
"""
|
||||||
self.db.alarm.remove({'alarm_id': alarm_id})
|
self.db.alarm.remove({'alarm_id': alarm_id})
|
||||||
|
|
||||||
|
def get_alarm_changes(self, alarm_id, on_behalf_of):
|
||||||
|
"""Yields list of AlarmChanges describing alarm history
|
||||||
|
:param alarm_id: ID of alarm to return changes for
|
||||||
|
:param on_behalf_of: ID of tenant to scope changes query (None for
|
||||||
|
administrative user, indicating all projects)
|
||||||
|
"""
|
||||||
|
raise NotImplementedError('Alarm history not implemented')
|
||||||
|
|
||||||
|
def record_alarm_change(self, alarm_change):
|
||||||
|
"""Record alarm change event.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError('Alarm history not implemented')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def record_events(events):
|
def record_events(events):
|
||||||
"""Write the events.
|
"""Write the events.
|
||||||
|
@ -646,6 +646,19 @@ class Connection(base.Connection):
|
|||||||
session.query(Alarm).filter(Alarm.id == alarm_id).delete()
|
session.query(Alarm).filter(Alarm.id == alarm_id).delete()
|
||||||
session.flush()
|
session.flush()
|
||||||
|
|
||||||
|
def get_alarm_changes(self, alarm_id, on_behalf_of):
|
||||||
|
"""Yields list of AlarmChanges describing alarm history
|
||||||
|
:param alarm_id: ID of alarm to return changes for
|
||||||
|
:param on_behalf_of: ID of tenant to scope changes query (None for
|
||||||
|
administrative user, indicating all projects)
|
||||||
|
"""
|
||||||
|
raise NotImplementedError('Alarm history not implemented')
|
||||||
|
|
||||||
|
def record_alarm_change(self, alarm_change):
|
||||||
|
"""Record alarm change event.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError('Alarm history not implemented')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_unique(session, key):
|
def _get_unique(session, key):
|
||||||
return session.query(UniqueName).filter(UniqueName.key == key).first()
|
return session.query(UniqueName).filter(UniqueName.key == key).first()
|
||||||
|
@ -322,3 +322,44 @@ class Alarm(Model):
|
|||||||
insufficient_data_actions,
|
insufficient_data_actions,
|
||||||
repeat_actions=repeat_actions,
|
repeat_actions=repeat_actions,
|
||||||
matching_metadata=matching_metadata)
|
matching_metadata=matching_metadata)
|
||||||
|
|
||||||
|
|
||||||
|
class AlarmChange(Model):
|
||||||
|
"""Record of an alarm change.
|
||||||
|
|
||||||
|
:param event_id: UUID of the change event
|
||||||
|
:param alarm_id: UUID of the alarm
|
||||||
|
:param type: The type of change
|
||||||
|
:param detail: JSON fragment describing change
|
||||||
|
:param user_id: the user ID of the initiating identity
|
||||||
|
:param project_id: the project ID of the initiating identity
|
||||||
|
:param on_behalf_of: the tenant on behalf of which the change
|
||||||
|
is being made
|
||||||
|
:param timestamp: the timestamp of the change
|
||||||
|
"""
|
||||||
|
|
||||||
|
CREATION = 'creation'
|
||||||
|
RULE_CHANGE = 'rule change'
|
||||||
|
STATE_TRANSITION = 'state transition'
|
||||||
|
DELETION = 'deletion'
|
||||||
|
|
||||||
|
def __init__(self,
|
||||||
|
event_id,
|
||||||
|
alarm_id,
|
||||||
|
type,
|
||||||
|
detail,
|
||||||
|
user_id,
|
||||||
|
project_id,
|
||||||
|
on_behalf_of,
|
||||||
|
timestamp=None
|
||||||
|
):
|
||||||
|
Model.__init__(
|
||||||
|
self,
|
||||||
|
event_id=event_id,
|
||||||
|
alarm_id=alarm_id,
|
||||||
|
type=type,
|
||||||
|
detail=detail,
|
||||||
|
user_id=user_id,
|
||||||
|
project_id=project_id,
|
||||||
|
on_behalf_of=on_behalf_of,
|
||||||
|
timestamp=timestamp)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user