aodh notifier and better logging

Change-Id: I4872215e1b7ed24ba99cc0218913efbec88cec96
This commit is contained in:
Idan Hefetz
2016-03-17 08:53:17 +00:00
parent 2d17e51be1
commit 597dc57ea8
6 changed files with 25 additions and 17 deletions

View File

@@ -84,5 +84,5 @@ class EventAction(object):
class NotifierEventTypes(object):
ACTIVATE_ALARM_EVENT = 'vitrage.deduced_alarm.activate'
DEACTIVATE_ALARM_EVENT = 'vitrage.deduced_alarm.deactivate'
ACTIVATE_DEDUCED_ALARM_EVENT = 'vitrage.deduced_alarm.activate'
DEACTIVATE_DEDUCED_ALARM_EVENT = 'vitrage.deduced_alarm.deactivate'

View File

@@ -48,6 +48,7 @@ class Processor(processor.ProcessorBase):
:type event: Dictionary
"""
LOG.debug('Processor event received')
entity = self.transform_entity(event)
self._calculate_aggregated_state(entity.vertex, entity.action)
return self.actions[entity.action](entity.vertex, entity.neighbors)
@@ -64,7 +65,7 @@ class Processor(processor.ProcessorBase):
:type neighbors: List
"""
LOG.debug("Add entity to entity graph: %s", new_vertex)
LOG.debug('Add entity to entity graph:\n%s', new_vertex)
self.entity_graph.add_vertex(new_vertex)
self._connect_neighbors(neighbors, [], EventAction.CREATE_ENTITY)
@@ -81,7 +82,7 @@ class Processor(processor.ProcessorBase):
:type neighbors: List
"""
LOG.debug("Update entity in entity graph: %s", updated_vertex)
LOG.debug('Update entity in entity graph:\n%s', updated_vertex)
graph_vertex = \
self.entity_graph.get_vertex(updated_vertex.vertex_id)
@@ -106,7 +107,7 @@ class Processor(processor.ProcessorBase):
:type neighbors: List
"""
LOG.debug("Delete entity from entity graph: %s", deleted_vertex)
LOG.debug('Delete entity from entity graph:\n%s', deleted_vertex)
graph_vertex = \
self.entity_graph.get_vertex(deleted_vertex.vertex_id)
@@ -130,14 +131,14 @@ class Processor(processor.ProcessorBase):
deleted_vertex)
def update_relationship(self, entity_vertex, neighbors):
LOG.debug("Update relationship in entity graph: %s", neighbors)
LOG.debug('Update relationship in entity graph:\n%s', neighbors)
for neighbor in neighbors:
# TODO(Alexey): maybe to check if the vertices exists
self.entity_graph.update_edge(neighbor.edge)
def delete_relationship(self, updated_vertex, neighbors):
LOG.debug("Delete relationship from entity graph: %s", neighbors)
LOG.debug('Delete relationship from entity graph:\n%s', neighbors)
for neighbor in neighbors:
# TODO(Alexey): maybe to check if the vertices exists
@@ -152,7 +153,6 @@ class Processor(processor.ProcessorBase):
def transform_entity(self, event):
entity = self.transformer_manager.transform(event)
LOG.debug('Transformed entity: %s', entity)
return entity
def _update_neighbors(self, vertex, neighbors):
@@ -171,6 +171,10 @@ class Processor(processor.ProcessorBase):
def _connect_neighbors(self, neighbors, valid_edges, action):
"""Updates the neighbor vertex and adds the connection edges """
if not neighbors:
LOG.debug('connect_neighbors - nothing to do')
return
LOG.debug("Connect neighbors. Neighbors: %s, valid_edges: %s",
neighbors, valid_edges)
for (vertex, edge) in neighbors:
@@ -194,11 +198,14 @@ class Processor(processor.ProcessorBase):
Finds the old connections that are connected to updated_vertex,
and marks them as deleted
"""
if not obsolete_edges:
LOG.debug('obsolete_edges - nothing to do')
return
LOG.debug("Delete old connections. Vertex: %s, old edges: %s",
vertex, obsolete_edges)
LOG.debug('Delete old connections. Vertex:\n%s', vertex)
# remove old edges and placeholder vertices if exist
for edge in obsolete_edges:
LOG.debug("Delete obsolete edge:\n%s", edge)
self.entity_graph.mark_edge_as_deleted(edge)
graph_ver = self.entity_graph.get_vertex(
edge.other_vertex(vertex.vertex_id))
@@ -263,8 +270,8 @@ class Processor(processor.ProcessorBase):
EventAction.DELETE_RELATIONSHIP]:
return None
else:
LOG.info('not recognized action: %s for vertex: %s',
action, vertex)
LOG.error('unrecognized action: %s for vertex: %s',
action, vertex)
return None
self.state_manager.aggregated_state(vertex, graph_vertex)

View File

@@ -72,7 +72,6 @@ class VitrageGraphService(os_service.Service):
try:
event = self.queue.get()
LOG.debug("got event: %s" % event)
self.processor.process_event(event)
except Exception as e:
LOG.exception("Exception: %s", e)

View File

@@ -64,6 +64,8 @@ class TransformerManager(object):
def transform(self, entity_event):
try:
sync_type = entity_event[SyncProps.SYNC_TYPE]
LOG.info('TRANSFORMER EVENT: %s', sync_type)
LOG.debug('Event:\n%s', entity_event)
except KeyError:
raise VitrageTransformerError(
'Entity Event must contains sync_type field.')

View File

@@ -46,7 +46,7 @@ class RaiseAlarm(base.Recipe):
notify_step = RaiseAlarm._get_notify_step(
action_spec,
NotifierEventTypes.ACTIVATE_ALARM_EVENT)
NotifierEventTypes.ACTIVATE_DEDUCED_ALARM_EVENT)
return [add_vertex_step, notify_step]
@@ -59,7 +59,7 @@ class RaiseAlarm(base.Recipe):
notify_step = RaiseAlarm._get_notify_step(
action_spec,
NotifierEventTypes.DEACTIVATE_ALARM_EVENT)
NotifierEventTypes.DEACTIVATE_DEDUCED_ALARM_EVENT)
return [remove_vertex_step, notify_step]

View File

@@ -40,9 +40,9 @@ class AodhNotifier(NotifierBase):
self.client = clients.ceilometer_client(conf)
def process_event(self, data, event_type):
if event_type == NotifierEventTypes.DEACTIVATE_ALARM_EVENT:
if event_type == NotifierEventTypes.DEACTIVATE_DEDUCED_ALARM_EVENT:
self._deactivate_aodh_alarm(data)
elif event_type == NotifierEventTypes.ACTIVATE_ALARM_EVENT:
elif event_type == NotifierEventTypes.ACTIVATE_DEDUCED_ALARM_EVENT:
self._activate_aodh_alarm(data)
def _activate_aodh_alarm(self, data):