diff --git a/vitrage/api_handler/apis/event.py b/vitrage/api_handler/apis/event.py index b42816469..8b83357f3 100644 --- a/vitrage/api_handler/apis/event.py +++ b/vitrage/api_handler/apis/event.py @@ -21,6 +21,9 @@ import socket from vitrage.api_handler.apis.base import EntityGraphApisBase from vitrage.common.constants import EventProperties +from vitrage.datasources.doctor.properties import DoctorDetails +from vitrage.datasources.doctor.properties import DoctorProperties +from vitrage.datasources.doctor.properties import DoctorStatus from vitrage.messaging import get_transport LOG = log.getLogger(__name__) @@ -40,11 +43,18 @@ class EventApis(EntityGraphApisBase): EventProperties.TIME: event_time, EventProperties.DETAILS: details} + if details.get(DoctorDetails.STATUS) == DoctorStatus.UP: + notification_type = DoctorProperties.CUSTOM_EVENT_UP + elif details.get(DoctorDetails.STATUS) == DoctorStatus.DOWN: + notification_type = DoctorProperties.CUSTOM_EVENT_DOWN + else: + raise Exception("Unknown status") + self.oslo_notifier.info( ctxt={'message_id': uuidutils.generate_uuid(), 'publisher_id': self.publisher, 'timestamp': datetime.utcnow()}, - event_type=event_type, + event_type=notification_type, payload=event) except Exception as e: LOG.warning('Failed to post event %s. Exception: %s', diff --git a/vitrage/datasources/doctor/driver.py b/vitrage/datasources/doctor/driver.py index bdbee3c19..80222e108 100644 --- a/vitrage/datasources/doctor/driver.py +++ b/vitrage/datasources/doctor/driver.py @@ -93,7 +93,7 @@ class DoctorDriver(AlarmDriverBase): LOG.debug('Going to enrich event: %s', str(event)) - event[DSProps.EVENT_TYPE] = event_type + event[DSProps.EVENT_TYPE] = event[EventProps.TYPE] old_alarm = self._old_alarm(event) if old_alarm and not self._status_changed(old_alarm, event): @@ -113,4 +113,5 @@ class DoctorDriver(AlarmDriverBase): @staticmethod def get_event_types(): - return [DoctorProps.HOST_DOWN] + return [DoctorProps.CUSTOM_EVENT_DOWN, + DoctorProps.CUSTOM_EVENT_UP] diff --git a/vitrage/datasources/doctor/properties.py b/vitrage/datasources/doctor/properties.py index 55a27c8c3..2c17e170a 100644 --- a/vitrage/datasources/doctor/properties.py +++ b/vitrage/datasources/doctor/properties.py @@ -20,6 +20,8 @@ class DoctorProperties(object): HOST_DOWN = 'compute.host.down' HOST_TYPE = NOVA_HOST_DATASOURCE UPDATE_TIME = 'update_time' + CUSTOM_EVENT_UP = 'vitrage.custom.event.up' + CUSTOM_EVENT_DOWN = 'vitrage.custom.event.down' class DoctorDetails(object):