From ffe967ba38827104d4a9b9015c388e10b4bb7b25 Mon Sep 17 00:00:00 2001 From: Ifat Afek Date: Thu, 15 Dec 2016 12:28:27 +0000 Subject: [PATCH] enrich_event should not be a static method Change-Id: I6ccbf39e3a5547905919522cc10dcd2bc65070bf --- vitrage/datasources/cinder/volume/driver.py | 3 +-- vitrage/datasources/driver_base.py | 4 +--- vitrage/datasources/heat/stack/driver.py | 3 +-- vitrage/datasources/neutron/network/driver.py | 3 +-- vitrage/datasources/neutron/port/driver.py | 3 +-- vitrage/datasources/nova/instance/driver.py | 3 +-- vitrage/datasources/static/driver.py | 3 +-- vitrage/datasources/static_physical/driver.py | 3 +-- vitrage/datasources/zabbix/driver.py | 3 +-- vitrage/tests/unit/datasources/nagios/mock_driver.py | 3 +-- vitrage/tests/unit/datasources/zabbix/mock_driver.py | 3 +-- 11 files changed, 11 insertions(+), 23 deletions(-) diff --git a/vitrage/datasources/cinder/volume/driver.py b/vitrage/datasources/cinder/volume/driver.py index 49bfc1254..fa92aea07 100644 --- a/vitrage/datasources/cinder/volume/driver.py +++ b/vitrage/datasources/cinder/volume/driver.py @@ -44,8 +44,7 @@ class CinderVolumeDriver(DriverBase): datasource_action, 'manager') - @staticmethod - def enrich_event(event, event_type): + def enrich_event(self, event, event_type): event[DSProps.EVENT_TYPE] = event_type return CinderVolumeDriver.make_pickleable([event], diff --git a/vitrage/datasources/driver_base.py b/vitrage/datasources/driver_base.py index cb1cf8efc..a3b4015c4 100644 --- a/vitrage/datasources/driver_base.py +++ b/vitrage/datasources/driver_base.py @@ -81,9 +81,7 @@ class DriverBase(object): def _add_datasource_action(entity, datasource_action): entity[DSProps.DATASOURCE_ACTION] = datasource_action - @staticmethod - @abc.abstractmethod - def enrich_event(event, event_type): + def enrich_event(self, event, event_type): """Return the given event with extra fields We add extra data, which the transformer uses later on. diff --git a/vitrage/datasources/heat/stack/driver.py b/vitrage/datasources/heat/stack/driver.py index caae249d7..b2ff49f28 100644 --- a/vitrage/datasources/heat/stack/driver.py +++ b/vitrage/datasources/heat/stack/driver.py @@ -63,8 +63,7 @@ class HeatStackDriver(DriverBase): 'orchestration.stack.resume.error', 'orchestration.stack.resume.end'] - @staticmethod - def enrich_event(event, event_type): + def enrich_event(self, event, event_type): # TODO(Nofar): add call to get resources of the stack if not deleted # change transformer that if delete we remove the stack from the graph # and hence all the edges to it diff --git a/vitrage/datasources/neutron/network/driver.py b/vitrage/datasources/neutron/network/driver.py index 3ee093063..f3007b3cf 100644 --- a/vitrage/datasources/neutron/network/driver.py +++ b/vitrage/datasources/neutron/network/driver.py @@ -27,8 +27,7 @@ class NetworkDriver(NeutronBase): 'network.update.end', 'network.delete.end'] - @staticmethod - def enrich_event(event, event_type): + def enrich_event(self, event, event_type): event[DSProps.EVENT_TYPE] = event_type return NetworkDriver.make_pickleable([event], diff --git a/vitrage/datasources/neutron/port/driver.py b/vitrage/datasources/neutron/port/driver.py index 16f794177..4298997c3 100644 --- a/vitrage/datasources/neutron/port/driver.py +++ b/vitrage/datasources/neutron/port/driver.py @@ -27,8 +27,7 @@ class PortDriver(NeutronBase): 'port.update.end', 'port.delete.end'] - @staticmethod - def enrich_event(event, event_type): + def enrich_event(self, event, event_type): event[DSProps.EVENT_TYPE] = event_type return PortDriver.make_pickleable([event], NEUTRON_PORT_DATASOURCE, diff --git a/vitrage/datasources/nova/instance/driver.py b/vitrage/datasources/nova/instance/driver.py index e299ad33a..1fccad027 100644 --- a/vitrage/datasources/nova/instance/driver.py +++ b/vitrage/datasources/nova/instance/driver.py @@ -34,8 +34,7 @@ class InstanceDriver(NovaDriverBase): 'OS-EXT-SRV-ATTR:user_data', '_info') - @staticmethod - def enrich_event(event, event_type): + def enrich_event(self, event, event_type): event[DSProps.EVENT_TYPE] = event_type return InstanceDriver.make_pickleable([event], diff --git a/vitrage/datasources/static/driver.py b/vitrage/datasources/static/driver.py index 599a8716f..5b56e936a 100644 --- a/vitrage/datasources/static/driver.py +++ b/vitrage/datasources/static/driver.py @@ -45,8 +45,7 @@ class StaticDriver(DriverBase): def get_event_types(): return [] - @staticmethod - def enrich_event(event, event_type): + def enrich_event(self, event, event_type): pass def get_all(self, datasource_action): diff --git a/vitrage/datasources/static_physical/driver.py b/vitrage/datasources/static_physical/driver.py index eeecce5b9..6527b126e 100644 --- a/vitrage/datasources/static_physical/driver.py +++ b/vitrage/datasources/static_physical/driver.py @@ -32,8 +32,7 @@ class StaticPhysicalDriver(DriverBase): def get_event_types(): return [] - @staticmethod - def enrich_event(event, event_type): + def enrich_event(self, event, event_type): pass ENTITIES_SECTION = 'entities' diff --git a/vitrage/datasources/zabbix/driver.py b/vitrage/datasources/zabbix/driver.py index af6cde552..1ee58e570 100644 --- a/vitrage/datasources/zabbix/driver.py +++ b/vitrage/datasources/zabbix/driver.py @@ -171,8 +171,7 @@ class ZabbixDriver(AlarmDriverBase): LOG.exception('failed in init %s ', e) return {} - @staticmethod - def enrich_event(event, event_type): + def enrich_event(self, event, event_type): event[DSProps.EVENT_TYPE] = event_type if ZabbixDriver.conf_map: diff --git a/vitrage/tests/unit/datasources/nagios/mock_driver.py b/vitrage/tests/unit/datasources/nagios/mock_driver.py index 700200099..d09c98313 100644 --- a/vitrage/tests/unit/datasources/nagios/mock_driver.py +++ b/vitrage/tests/unit/datasources/nagios/mock_driver.py @@ -27,8 +27,7 @@ class MockNagiosDriver(NagiosDriver): def get_event_types(): return [] - @staticmethod - def enrich_event(event, event_type): + def enrich_event(self, event, event_type): pass def __init__(self, conf): diff --git a/vitrage/tests/unit/datasources/zabbix/mock_driver.py b/vitrage/tests/unit/datasources/zabbix/mock_driver.py index 5a6715a0b..b081079b3 100644 --- a/vitrage/tests/unit/datasources/zabbix/mock_driver.py +++ b/vitrage/tests/unit/datasources/zabbix/mock_driver.py @@ -27,8 +27,7 @@ class MockZabbixDriver(ZabbixDriver): def get_event_types(): return [] - @staticmethod - def enrich_event(event, event_type): + def enrich_event(self, event, event_type): pass def __init__(self, conf):