From e47e0b2497358d5641bd860a1e221c1a322b6879 Mon Sep 17 00:00:00 2001 From: liathartal Date: Thu, 7 Apr 2016 11:30:29 +0000 Subject: [PATCH] name refactor - change 'SynchronizerProperties' to DatasourceProperties Change-Id: I83df4f8818fb3318afc3fb1acb94c6e5c5b2e1eb --- etc/vitrage/vitrage.conf.sample | 29 +++++++------------ vitrage/cmd/graph.py | 6 ++-- vitrage/common/constants.py | 2 +- vitrage/datasources/alarm_transformer_base.py | 4 +-- vitrage/datasources/aodh/transformer.py | 8 ++--- vitrage/datasources/cinder/volume/driver.py | 4 +-- .../datasources/cinder/volume/transformer.py | 6 ++-- vitrage/datasources/driver_base.py | 26 ++++++++--------- vitrage/datasources/nagios/driver.py | 4 +-- vitrage/datasources/nagios/transformer.py | 8 ++--- .../neutron/network/transformer.py | 6 ++-- .../datasources/neutron/port/transformer.py | 10 +++---- vitrage/datasources/nova/host/transformer.py | 6 ++-- vitrage/datasources/nova/instance/driver.py | 4 +-- .../datasources/nova/instance/transformer.py | 8 ++--- vitrage/datasources/nova/zone/__init__.py | 2 +- vitrage/datasources/nova/zone/transformer.py | 6 ++-- vitrage/datasources/services.py | 16 +++++----- vitrage/datasources/static_physical/driver.py | 4 +-- .../static_physical/transformer.py | 6 ++-- vitrage/datasources/transformer_base.py | 18 +++++++----- vitrage/entity_graph/service.py | 2 +- vitrage/entity_graph/transformer_manager.py | 4 +-- vitrage/evaluator/actions/action_executor.py | 6 ++-- vitrage/opts.py | 22 +++++++------- vitrage/tests/functional/base.py | 8 ++--- .../static_physical/test_static_physical.py | 4 +-- vitrage/tests/mocks/mock_transformer.py | 2 +- vitrage/tests/mocks/utils.py | 2 +- .../driver_host_snapshot_dynamic.json | 0 .../driver_inst_snapshot_dynamic.json | 0 .../driver_inst_snapshot_static.json | 0 .../driver_inst_update_dynamic.json | 0 .../driver_nagios_snapshot_dynamic.json | 0 .../driver_nagios_snapshot_static.json | 0 .../driver_switch_snapshot_dynamic.json | 0 .../driver_volume_snapshot_dynamic.json | 0 .../driver_volume_update_dynamic.json | 0 .../driver_zone_snapshot_dynamic.json | 0 .../cinder/test_cinder_volume_transformer.py | 6 ++-- .../datasources/nagios/test_nagios_config.py | 2 +- .../nagios/test_nagios_transformer.py | 8 ++--- .../nova/test_nova_host_transformer.py | 12 ++++---- .../nova/test_nova_instance_transformers.py | 10 +++---- .../nova/test_nova_zone_transformer.py | 6 ++-- .../test_static_physical_driver.py | 4 +-- .../test_static_physical_transformer.py | 4 +-- vitrage/tests/unit/entity_graph/base.py | 12 ++++---- .../entity_graph/processor/test_processor.py | 10 +++---- 49 files changed, 152 insertions(+), 155 deletions(-) rename vitrage/tests/resources/mock_configurations/{synchronizer => driver}/driver_host_snapshot_dynamic.json (100%) rename vitrage/tests/resources/mock_configurations/{synchronizer => driver}/driver_inst_snapshot_dynamic.json (100%) rename vitrage/tests/resources/mock_configurations/{synchronizer => driver}/driver_inst_snapshot_static.json (100%) rename vitrage/tests/resources/mock_configurations/{synchronizer => driver}/driver_inst_update_dynamic.json (100%) rename vitrage/tests/resources/mock_configurations/{synchronizer => driver}/driver_nagios_snapshot_dynamic.json (100%) rename vitrage/tests/resources/mock_configurations/{synchronizer => driver}/driver_nagios_snapshot_static.json (100%) rename vitrage/tests/resources/mock_configurations/{synchronizer => driver}/driver_switch_snapshot_dynamic.json (100%) rename vitrage/tests/resources/mock_configurations/{synchronizer => driver}/driver_volume_snapshot_dynamic.json (100%) rename vitrage/tests/resources/mock_configurations/{synchronizer => driver}/driver_volume_update_dynamic.json (100%) rename vitrage/tests/resources/mock_configurations/{synchronizer => driver}/driver_zone_snapshot_dynamic.json (100%) diff --git a/etc/vitrage/vitrage.conf.sample b/etc/vitrage/vitrage.conf.sample index 8939ed71a..f6c50efa4 100644 --- a/etc/vitrage/vitrage.conf.sample +++ b/etc/vitrage/vitrage.conf.sample @@ -118,8 +118,8 @@ # Aodh plugin transformer class path (string value) #transformer = vitrage.datasources.aodh.transformer.AodhTransformer -# Aodh plugin synchronizer class path (string value) -#synchronizer = vitrage.datasources.aodh.driver.AodhDriver +# Aodh datasource driver class path (string value) +#driver = vitrage.datasources.aodh.driver.AodhDriver # interval between checking changes in aodh datasource (integer value) # Minimum value: 30 @@ -399,7 +399,7 @@ #transformer = vitrage.datasources.nagios.transformer.NagiosTransformer # Nagios plugin driver class path (string value) -#synchronizer = vitrage.datasources.nagios.driver.NagiosDriver +#driver = vitrage.datasources.nagios.driver.NagiosDriver # interval between checking changes in nagios datasource (integer value) # Minimum value: 30 @@ -428,7 +428,7 @@ #transformer = vitrage.datasources.nova.host.transformer.HostTransformer # Nova host driver class path (string value) -#synchronizer = vitrage.datasources.nova.host.driver.HostDriver +#driver = vitrage.datasources.nova.host.driver.HostDriver [nova.instance] @@ -441,7 +441,7 @@ #transformer = vitrage.datasources.nova.instance.transformer.InstanceTransformer # Nova instance driver class path (string value) -#synchronizer = vitrage.datasources.nova.instance.driver.InstanceDriver +#driver = vitrage.datasources.nova.instance.driver.InstanceDriver [nova.zone] @@ -454,7 +454,7 @@ #transformer = vitrage.datasources.nova.zone.transformer.ZoneTransformer # Nova zone driver class path (string value) -#synchronizer = vitrage.datasources.nova.zone.driver.ZoneDriver +#driver = vitrage.datasources.nova.zone.driver.ZoneDriver [oslo_middleware] @@ -523,10 +523,10 @@ # # Static physical transformer class path (string value) -#transformer = vitrage.synchronizer.plugins.static_physical.transformer.StaticPhysicalTransformer +#transformer = vitrage.datasources.static_physical.transformer.StaticPhysicalTransformer -# Static physical synchronizer class path (string value) -#synchronizer = vitrage.synchronizer.plugins.static_physical.synchronizer.StaticPhysicalSynchronizer +# Static physical driver class path (string value) +#driver = vitrage.datasources.static_physical.driver.StaticPhysicalDriver # interval between checking changes in the configuration files of the physical # topology plugin (integer value) @@ -540,7 +540,7 @@ #entities = switch -[synchronizer] +[datasources] # # From vitrage @@ -550,12 +550,5 @@ # Minimum value: 10 #snapshots_interval = 600 - -[plugins] - -# -# From vitrage -# - # Names of supported plugins (list value) -#plugin_type = nagios,nova.host,nova.instance,nova.zone,static_physical,aodh +#types = nagios,nova.host,nova.instance,nova.zone,static_physical,aodh diff --git a/vitrage/cmd/graph.py b/vitrage/cmd/graph.py index c834caecc..97fe52218 100644 --- a/vitrage/cmd/graph.py +++ b/vitrage/cmd/graph.py @@ -36,13 +36,13 @@ def main(): 1. Starts the Entity graph service 2. Starts the api_handler service - 3. Starts the Synchronizer service + 3. Starts the datasource service 4. Starts the Consistency service """ conf, event_queue, evaluator, e_graph, initialization_status = init() launcher = os_service.ServiceLauncher(conf) - synchronizers = datasource_launcher.Launcher( + datasources = datasource_launcher.Launcher( conf, datasource_launcher.create_send_to_queue_callback(event_queue)) @@ -52,7 +52,7 @@ def main(): launcher.launch_service(api_handler_svc.VitrageApiHandlerService( conf, e_graph)) - synchronizers.launch() + datasources.launch() launcher.launch_service(consistency_svc.VitrageGraphConsistencyService( conf, event_queue, evaluator, e_graph, initialization_status)) diff --git a/vitrage/common/constants.py b/vitrage/common/constants.py index 6bd8463c3..bb0904e8a 100644 --- a/vitrage/common/constants.py +++ b/vitrage/common/constants.py @@ -58,7 +58,7 @@ class EntityCategory(object): ALARM = 'ALARM' -class SynchronizerProperties(object): +class DatasourceProperties(object): SYNC_TYPE = 'sync_type' SYNC_MODE = 'sync_mode' SAMPLE_DATE = 'sample_date' diff --git a/vitrage/datasources/alarm_transformer_base.py b/vitrage/datasources/alarm_transformer_base.py index 2e1fe2b15..aac424b03 100644 --- a/vitrage/datasources/alarm_transformer_base.py +++ b/vitrage/datasources/alarm_transformer_base.py @@ -14,9 +14,9 @@ from oslo_log import log as logging +from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EntityCategory from vitrage.common.constants import EventAction -from vitrage.common.constants import SynchronizerProperties as SyncProps from vitrage.common.constants import SyncMode from vitrage.common.exception import VitrageTransformerError from vitrage.datasources import transformer_base as tbase @@ -37,7 +37,7 @@ class AlarmTransformerBase(tbase.TransformerBase): pass def _extract_action_type(self, entity_event): - sync_mode = entity_event[SyncProps.SYNC_MODE] + sync_mode = entity_event[DSProps.SYNC_MODE] if sync_mode in (SyncMode.UPDATE, SyncMode.SNAPSHOT): return EventAction.DELETE_ENTITY if self._ok_status(entity_event) \ else EventAction.UPDATE_ENTITY diff --git a/vitrage/datasources/aodh/transformer.py b/vitrage/datasources/aodh/transformer.py index e71d65846..434a592f7 100644 --- a/vitrage/datasources/aodh/transformer.py +++ b/vitrage/datasources/aodh/transformer.py @@ -13,9 +13,9 @@ # under the License. from oslo_log import log as logging +from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EdgeLabels from vitrage.common.constants import EntityCategory -from vitrage.common.constants import SynchronizerProperties as SyncProps from vitrage.common.constants import VertexProperties as VProps from vitrage.common import datetime_utils from vitrage.datasources.alarm_properties import AlarmProperties as AlarmProps @@ -59,7 +59,7 @@ class AodhTransformer(AlarmTransformerBase): metadata[AodhProps.STATE_TIMESTAMP] = \ entity_event[AodhProps.STATE_TIMESTAMP] - sample_timestamp = entity_event[SyncProps.SAMPLE_DATE] + sample_timestamp = entity_event[DSProps.SAMPLE_DATE] update_timestamp = self._format_update_timestamp( AodhTransformer._timestamp(entity_event), sample_timestamp) @@ -68,7 +68,7 @@ class AodhTransformer(AlarmTransformerBase): self._create_entity_key(entity_event), entity_id=entity_event[AodhProps.ALARM_ID], entity_category=EntityCategory.ALARM, - entity_type=entity_event[SyncProps.SYNC_TYPE], + entity_type=entity_event[DSProps.SYNC_TYPE], entity_state=AlarmProps.ALARM_ACTIVE_STATE, sample_timestamp=sample_timestamp, update_timestamp=update_timestamp, @@ -89,7 +89,7 @@ class AodhTransformer(AlarmTransformerBase): return entity_event[AodhProps.STATE] == self.STATUS_OK def _create_entity_key(self, entity_event): - sync_type = entity_event[SyncProps.SYNC_TYPE] + sync_type = entity_event[DSProps.SYNC_TYPE] alarm_name = entity_event[AodhProps.NAME] resource_id = entity_event[AodhProps.RESOURCE_ID] return (tbase.build_key(self._key_values(sync_type, diff --git a/vitrage/datasources/cinder/volume/driver.py b/vitrage/datasources/cinder/volume/driver.py index 3ca2f7c81..3f0325a7b 100644 --- a/vitrage/datasources/cinder/volume/driver.py +++ b/vitrage/datasources/cinder/volume/driver.py @@ -15,7 +15,7 @@ from oslo_log import log as logging from vitrage import clients -from vitrage.common.constants import SynchronizerProperties as SyncProps +from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import SyncMode from vitrage.datasources.cinder.volume import CINDER_VOLUME_DATASOURCE from vitrage.datasources.driver_base import DriverBase @@ -42,7 +42,7 @@ class CinderVolumeDriver(DriverBase): @staticmethod def enrich_event(event, event_type): - event[SyncProps.EVENT_TYPE] = event_type + event[DSProps.EVENT_TYPE] = event_type return CinderVolumeDriver.make_pickleable([event], CINDER_VOLUME_DATASOURCE, diff --git a/vitrage/datasources/cinder/volume/transformer.py b/vitrage/datasources/cinder/volume/transformer.py index 106f6ad6b..65d669bf9 100644 --- a/vitrage/datasources/cinder/volume/transformer.py +++ b/vitrage/datasources/cinder/volume/transformer.py @@ -14,10 +14,10 @@ from oslo_log import log as logging +from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EdgeLabels from vitrage.common.constants import EntityCategory from vitrage.common.constants import EventAction -from vitrage.common.constants import SynchronizerProperties as SyncProps from vitrage.common.constants import VertexProperties as VProps from vitrage.datasources.cinder.volume import CINDER_VOLUME_DATASOURCE from vitrage.datasources.nova.instance import NOVA_INSTANCE_DATASOURCE @@ -79,7 +79,7 @@ class CinderVolumeTransformer(ResourceTransformerBase): entity_key = self._create_entity_key(entity_event) - sample_timestamp = entity_event[SyncProps.SAMPLE_DATE] + sample_timestamp = entity_event[DSProps.SAMPLE_DATE] return graph_utils.create_vertex( entity_key, @@ -136,7 +136,7 @@ class CinderVolumeTransformer(ResourceTransformerBase): instance_id = attachment[instance_id_property] - sample_timestamp = entity_event[SyncProps.SAMPLE_DATE] + sample_timestamp = entity_event[DSProps.SAMPLE_DATE] properties = { VProps.ID: instance_id, diff --git a/vitrage/datasources/driver_base.py b/vitrage/datasources/driver_base.py index aa3995e1c..bb4394f9a 100644 --- a/vitrage/datasources/driver_base.py +++ b/vitrage/datasources/driver_base.py @@ -17,8 +17,8 @@ import six from oslo_log import log +from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EventAction -from vitrage.common.constants import SynchronizerProperties as SyncProps from vitrage.common.constants import SyncMode from vitrage.common import datetime_utils @@ -38,9 +38,9 @@ class DriverBase(object): @staticmethod def _get_end_message(sync_type): end_message = { - SyncProps.SYNC_TYPE: sync_type, - SyncProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT, - SyncProps.EVENT_TYPE: EventAction.END_MESSAGE + DSProps.SYNC_TYPE: sync_type, + DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT, + DSProps.EVENT_TYPE: EventAction.END_MESSAGE } return end_message @@ -68,16 +68,16 @@ class DriverBase(object): @staticmethod def _add_sync_type(entity, sync_type): - if SyncProps.SYNC_TYPE not in entity: - entity[SyncProps.SYNC_TYPE] = sync_type + if DSProps.SYNC_TYPE not in entity: + entity[DSProps.SYNC_TYPE] = sync_type @staticmethod def _add_sampling_time(entity): - entity[SyncProps.SAMPLE_DATE] = str(datetime_utils.utcnow()) + entity[DSProps.SAMPLE_DATE] = str(datetime_utils.utcnow()) @staticmethod def _add_sync_mode(entity, sync_mode): - entity[SyncProps.SYNC_MODE] = sync_mode + entity[DSProps.SYNC_MODE] = sync_mode @staticmethod @abc.abstractmethod @@ -96,14 +96,14 @@ class DriverBase(object): @staticmethod @abc.abstractmethod def get_event_types(conf): - """Return a list of all event types relevant to this synchronizer + """Return a list of all event types relevant to this datasource Example: return ['compute.instance.update', 'compute.instance.resume'] It also supports prefixes- the event types which start - with this prefix will be processed by this synchronizer: + with this prefix will be processed by this driver: Example: return ['compute.instance'] @@ -118,7 +118,7 @@ class DriverBase(object): @staticmethod @abc.abstractmethod def get_topic(conf): - """Return the topic of events processed by this synchronizer + """Return the topic of events processed by this driver Example: to listen to nova topic, add another topic to nova.conf so nova will @@ -130,8 +130,8 @@ class DriverBase(object): example of get_topic(): return 'new_topic' - :param conf: the synchronizer's configuration - :return: the topic of the synchronizer + :param conf: the datasource's configuration + :return: the topic of the datasource :rtype: str """ diff --git a/vitrage/datasources/nagios/driver.py b/vitrage/datasources/nagios/driver.py index af7088e8f..91adf3b3f 100644 --- a/vitrage/datasources/nagios/driver.py +++ b/vitrage/datasources/nagios/driver.py @@ -17,7 +17,7 @@ from collections import namedtuple from oslo_log import log import requests -from vitrage.common.constants import SynchronizerProperties as SyncProps +from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.datasources.alarm_driver_base import AlarmDriverBase from vitrage.datasources.nagios.config import NagiosConfig from vitrage.datasources.nagios import NAGIOS_DATASOURCE @@ -83,7 +83,7 @@ class NagiosDriver(AlarmDriverBase): for alarm in alarms: # based on nagios configuration file, convert nagios host name # to vitrage resource type and name - alarm[SyncProps.SYNC_TYPE] = NagiosProps.NAGIOS + alarm[DSProps.SYNC_TYPE] = NagiosProps.NAGIOS nagios_host = alarm[NagiosProps.RESOURCE_NAME] vitrage_resource = self.config.get_vitrage_resource(nagios_host) diff --git a/vitrage/datasources/nagios/transformer.py b/vitrage/datasources/nagios/transformer.py index 8c7cf6e78..9ca71ba1e 100644 --- a/vitrage/datasources/nagios/transformer.py +++ b/vitrage/datasources/nagios/transformer.py @@ -14,9 +14,9 @@ from oslo_log import log as logging +from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EdgeLabels from vitrage.common.constants import EntityCategory -from vitrage.common.constants import SynchronizerProperties as SyncProps from vitrage.common.constants import VertexProperties as VProps from vitrage.common import datetime_utils from vitrage.datasources.alarm_properties import AlarmProperties as AlarmProps @@ -52,7 +52,7 @@ class NagiosTransformer(AlarmTransformerBase): '%Y-%m-%d %H:%M:%S', tbase.TIMESTAMP_FORMAT) - sample_timestamp = entity_event[SyncProps.SAMPLE_DATE] + sample_timestamp = entity_event[DSProps.SAMPLE_DATE] update_timestamp = self._format_update_timestamp(update_timestamp, sample_timestamp) @@ -70,7 +70,7 @@ class NagiosTransformer(AlarmTransformerBase): return graph_utils.create_vertex( self._create_entity_key(entity_event), entity_category=EntityCategory.ALARM, - entity_type=entity_event[SyncProps.SYNC_TYPE], + entity_type=entity_event[DSProps.SYNC_TYPE], entity_state=entity_state, sample_timestamp=sample_timestamp, update_timestamp=update_timestamp, @@ -125,7 +125,7 @@ class NagiosTransformer(AlarmTransformerBase): def _create_entity_key(self, entity_event): - sync_type = entity_event[SyncProps.SYNC_TYPE] + sync_type = entity_event[DSProps.SYNC_TYPE] alarm_name = entity_event[NagiosProperties.SERVICE] resource_name = entity_event[NagiosProperties.RESOURCE_NAME] return tbase.build_key(self._key_values(sync_type, diff --git a/vitrage/datasources/neutron/network/transformer.py b/vitrage/datasources/neutron/network/transformer.py index 857641857..d5f8b46ee 100644 --- a/vitrage/datasources/neutron/network/transformer.py +++ b/vitrage/datasources/neutron/network/transformer.py @@ -12,8 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. +from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EntityCategory -from vitrage.common.constants import SynchronizerProperties as SyncProps from vitrage.common.constants import VertexProperties as VProps from vitrage.datasources.neutron.network import NEUTRON_NETWORK_DATASOURCE from vitrage.datasources.resource_transformer_base import \ @@ -51,12 +51,12 @@ class NetworkTransformer(ResourceTransformerBase): VProps.NAME: name, } - sample_timestamp = entity_event[SyncProps.SAMPLE_DATE] + sample_timestamp = entity_event[DSProps.SAMPLE_DATE] # TODO(Alexey): need to check here that only the UPDATE sync_mode will # update the UPDATE_TIMESTAMP property update_timestamp = self._format_update_timestamp( - extract_field_value(entity_event, SyncProps.SAMPLE_DATE), + extract_field_value(entity_event, DSProps.SAMPLE_DATE), sample_timestamp) return graph_utils.create_vertex( diff --git a/vitrage/datasources/neutron/port/transformer.py b/vitrage/datasources/neutron/port/transformer.py index e3c83bf97..9dd40663a 100644 --- a/vitrage/datasources/neutron/port/transformer.py +++ b/vitrage/datasources/neutron/port/transformer.py @@ -16,9 +16,9 @@ from vitrage.datasources.resource_transformer_base import \ from oslo_log import log as logging +from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EdgeLabels from vitrage.common.constants import EntityCategory -from vitrage.common.constants import SynchronizerProperties as SyncProps from vitrage.common.constants import VertexProperties as VProps from vitrage.datasources.neutron.network import NEUTRON_NETWORK_DATASOURCE from vitrage.datasources.neutron.port import NEUTRON_PORT_DATASOURCE @@ -58,12 +58,12 @@ class PortTransformer(ResourceTransformerBase): VProps.NAME: name, } - sample_timestamp = entity_event[SyncProps.SAMPLE_DATE] + sample_timestamp = entity_event[DSProps.SAMPLE_DATE] # TODO(Alexey): need to check here that only the UPDATE sync_mode will # update the UPDATE_TIMESTAMP property update_timestamp = self._format_update_timestamp( - extract_field_value(entity_event, SyncProps.SAMPLE_DATE), + extract_field_value(entity_event, DSProps.SAMPLE_DATE), sample_timestamp) return graph_utils.create_vertex( @@ -118,7 +118,7 @@ class PortTransformer(ResourceTransformerBase): instance_id = entity_event[instance_id_property] - sample_timestamp = entity_event[SyncProps.SAMPLE_DATE] + sample_timestamp = entity_event[DSProps.SAMPLE_DATE] properties = { VProps.ID: instance_id, @@ -139,7 +139,7 @@ class PortTransformer(ResourceTransformerBase): net_id = entity_event[net_id_property] - sample_timestamp = entity_event[SyncProps.SAMPLE_DATE] + sample_timestamp = entity_event[DSProps.SAMPLE_DATE] properties = { VProps.ID: net_id, diff --git a/vitrage/datasources/nova/host/transformer.py b/vitrage/datasources/nova/host/transformer.py index 6c30e0ecc..825a07d9e 100644 --- a/vitrage/datasources/nova/host/transformer.py +++ b/vitrage/datasources/nova/host/transformer.py @@ -14,9 +14,9 @@ from oslo_log import log as logging +from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EdgeLabels from vitrage.common.constants import EntityCategory -from vitrage.common.constants import SynchronizerProperties as SyncProps from vitrage.common.constants import VertexProperties as VProps from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE from vitrage.datasources.nova.zone import NOVA_ZONE_DATASOURCE @@ -49,7 +49,7 @@ class HostTransformer(ResourceTransformerBase): metadata = {VProps.NAME: host_name} entity_key = self._create_entity_key(entity_event) - sample_timestamp = entity_event[SyncProps.SAMPLE_DATE] + sample_timestamp = entity_event[DSProps.SAMPLE_DATE] update_timestamp = self._format_update_timestamp(None, sample_timestamp) @@ -69,7 +69,7 @@ class HostTransformer(ResourceTransformerBase): # Support snapshot and snapshot_init events only zone_neighbor = self._create_zone_neighbor( entity_event, - entity_event[SyncProps.SAMPLE_DATE], + entity_event[DSProps.SAMPLE_DATE], self._create_entity_key(entity_event), 'zone') diff --git a/vitrage/datasources/nova/instance/driver.py b/vitrage/datasources/nova/instance/driver.py index b18f41fca..53bb9c54c 100644 --- a/vitrage/datasources/nova/instance/driver.py +++ b/vitrage/datasources/nova/instance/driver.py @@ -14,7 +14,7 @@ from oslo_log import log as logging -from vitrage.common.constants import SynchronizerProperties as SyncProps +from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import SyncMode from vitrage.datasources.nova.instance import NOVA_INSTANCE_DATASOURCE from vitrage.datasources.nova.nova_driver_base import NovaDriverBase @@ -37,7 +37,7 @@ class InstanceDriver(NovaDriverBase): @staticmethod def enrich_event(event, event_type): - event[SyncProps.EVENT_TYPE] = event_type + event[DSProps.EVENT_TYPE] = event_type return InstanceDriver.make_pickleable([event], NOVA_INSTANCE_DATASOURCE, diff --git a/vitrage/datasources/nova/instance/transformer.py b/vitrage/datasources/nova/instance/transformer.py index e030c3e49..72bd64c07 100644 --- a/vitrage/datasources/nova/instance/transformer.py +++ b/vitrage/datasources/nova/instance/transformer.py @@ -14,10 +14,10 @@ from oslo_log import log as logging +from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EdgeLabels from vitrage.common.constants import EntityCategory from vitrage.common.constants import EventAction -from vitrage.common.constants import SynchronizerProperties as SyncProps from vitrage.common.constants import VertexProperties as VProps from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE from vitrage.datasources.nova.instance import NOVA_INSTANCE_DATASOURCE @@ -67,12 +67,12 @@ class InstanceTransformer(ResourceTransformerBase): VProps.PROJECT_ID: project } - sample_timestamp = entity_event[SyncProps.SAMPLE_DATE] + sample_timestamp = entity_event[DSProps.SAMPLE_DATE] # TODO(Alexey): need to check here that only the UPDATE sync_mode will # update the UPDATE_TIMESTAMP property update_timestamp = self._format_update_timestamp( - extract_field_value(entity_event, SyncProps.SAMPLE_DATE), + extract_field_value(entity_event, DSProps.SAMPLE_DATE), sample_timestamp) return graph_utils.create_vertex( @@ -97,7 +97,7 @@ class InstanceTransformer(ResourceTransformerBase): host_neighbor = self._create_host_neighbor( self._create_entity_key(entity_event), extract_field_value(entity_event, host_name), - entity_event[SyncProps.SAMPLE_DATE], + entity_event[DSProps.SAMPLE_DATE], host_transformer) neighbors.append(host_neighbor) else: diff --git a/vitrage/datasources/nova/zone/__init__.py b/vitrage/datasources/nova/zone/__init__.py index 7fa01b05c..5a9d7e89e 100644 --- a/vitrage/datasources/nova/zone/__init__.py +++ b/vitrage/datasources/nova/zone/__init__.py @@ -25,6 +25,6 @@ OPTS = [ cfg.StrOpt('driver', default='vitrage.datasources.nova.zone.driver' '.ZoneDriver', - help='Nova zone synchronizer class path', + help='Nova zone datasource class path', required=True), ] diff --git a/vitrage/datasources/nova/zone/transformer.py b/vitrage/datasources/nova/zone/transformer.py index 00bf9806d..e5b7699a7 100644 --- a/vitrage/datasources/nova/zone/transformer.py +++ b/vitrage/datasources/nova/zone/transformer.py @@ -14,9 +14,9 @@ from oslo_log import log as logging +from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EdgeLabels from vitrage.common.constants import EntityCategory -from vitrage.common.constants import SynchronizerProperties as SyncProps from vitrage.common.constants import VertexProperties as VProps from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE from vitrage.datasources.nova.zone import NOVA_ZONE_DATASOURCE @@ -59,7 +59,7 @@ class ZoneTransformer(ResourceTransformerBase): } entity_key = self._create_entity_key(entity_event) - sample_timestamp = entity_event[SyncProps.SAMPLE_DATE] + sample_timestamp = entity_event[DSProps.SAMPLE_DATE] update_timestamp = self._format_update_timestamp(None, sample_timestamp) @@ -98,7 +98,7 @@ class ZoneTransformer(ResourceTransformerBase): zone_vertex_id, hostname, host_state, - entity_event[SyncProps.SAMPLE_DATE]) + entity_event[DSProps.SAMPLE_DATE]) neighbors.append(host_neighbor) else: diff --git a/vitrage/datasources/services.py b/vitrage/datasources/services.py index 917083c7e..b70eabc0a 100644 --- a/vitrage/datasources/services.py +++ b/vitrage/datasources/services.py @@ -21,15 +21,15 @@ from vitrage.common.constants import SyncMode LOG = log.getLogger(__name__) -class SynchronizerService(os_service.Service): +class DatasourceService(os_service.Service): def __init__(self, conf, registered_datasources, callback_function): - super(SynchronizerService, self).__init__() + super(DatasourceService, self).__init__() self.conf = conf self.registered_datasources = registered_datasources self.callback_function = callback_function -class SnapshotsService(SynchronizerService): +class SnapshotsService(DatasourceService): def __init__(self, conf, registered_datasources, callback_function): super(SnapshotsService, self).__init__(conf, registered_datasources, @@ -66,7 +66,7 @@ class SnapshotsService(SynchronizerService): self.first_time = False -class ChangesService(SynchronizerService): +class ChangesService(DatasourceService): def __init__(self, conf, registered_datasources, changes_interval, @@ -77,7 +77,7 @@ class ChangesService(SynchronizerService): self.changes_interval = changes_interval def start(self): - LOG.info("Vitrage Synchronizer Changes Service For: %s - Starting...", + LOG.info("Vitrage Datasource Changes Service For: %s - Starting...", self.registered_datasources[0].__class__.__name__) super(ChangesService, self).start() @@ -85,16 +85,16 @@ class ChangesService(SynchronizerService): callback=self._get_changes, initial_delay=self.changes_interval) - LOG.info("Vitrage Synchronizer Changes Service For: %s - Started!", + LOG.info("Vitrage Datasource Changes Service For: %s - Started!", self.registered_datasources[0].__class__.__name__) def stop(self, graceful=False): - LOG.info("Vitrage Synchronizer Changes Service For: %s - Stopping...", + LOG.info("Vitrage Datasource Changes Service For: %s - Stopping...", self.registered_datasources[0].__class__.__name__) super(ChangesService, self).stop() - LOG.info("Vitrage Synchronizer Changes Service For: %s - Stopped!", + LOG.info("Vitrage Datasource Changes Service For: %s - Stopped!", self.registered_datasources[0].__class__.__name__) def _get_changes(self): diff --git a/vitrage/datasources/static_physical/driver.py b/vitrage/datasources/static_physical/driver.py index 99ea47d2b..09fb95942 100644 --- a/vitrage/datasources/static_physical/driver.py +++ b/vitrage/datasources/static_physical/driver.py @@ -15,8 +15,8 @@ import copy import os +from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EventAction -from vitrage.common.constants import SynchronizerProperties as SyncProps from vitrage.common.constants import VertexProperties as VProps from vitrage.common import file_utils from vitrage.datasources.driver_base import DriverBase @@ -130,4 +130,4 @@ class StaticPhysicalDriver(DriverBase): @staticmethod def _set_event_type(entity, event_type): - entity[SyncProps.EVENT_TYPE] = event_type + entity[DSProps.EVENT_TYPE] = event_type diff --git a/vitrage/datasources/static_physical/transformer.py b/vitrage/datasources/static_physical/transformer.py index bc42ca801..7e06ce7c0 100644 --- a/vitrage/datasources/static_physical/transformer.py +++ b/vitrage/datasources/static_physical/transformer.py @@ -14,8 +14,8 @@ from oslo_log import log as logging +from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EntityCategory -from vitrage.common.constants import SynchronizerProperties as SyncProps from vitrage.common.constants import VertexProperties as VProps from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE from vitrage.datasources.resource_transformer_base import \ @@ -47,7 +47,7 @@ class StaticPhysicalTransformer(ResourceTransformerBase): sync_type = entity_event[VProps.TYPE] entity_id = entity_event[VProps.ID] - sample_timestamp = entity_event[SyncProps.SAMPLE_DATE] + sample_timestamp = entity_event[DSProps.SAMPLE_DATE] update_timestamp = self._format_update_timestamp( update_timestamp=None, sample_timestamp=sample_timestamp) @@ -69,7 +69,7 @@ class StaticPhysicalTransformer(ResourceTransformerBase): neighbors = [] entity_type = entity_event[VProps.TYPE] entity_key = self._create_entity_key(entity_event) - timestamp = entity_event[SyncProps.SAMPLE_DATE] + timestamp = entity_event[DSProps.SAMPLE_DATE] for neighbor_details in entity_event[self.RELATIONSHIPS_SECTION]: # TODO(alexey): need to decide what to do if one of the entities diff --git a/vitrage/datasources/transformer_base.py b/vitrage/datasources/transformer_base.py index 081710bf1..7285deb9a 100644 --- a/vitrage/datasources/transformer_base.py +++ b/vitrage/datasources/transformer_base.py @@ -21,8 +21,8 @@ import six from vitrage.common import datetime_utils import vitrage.common.constants as cons +from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EventAction -from vitrage.common.constants import SynchronizerProperties as SyncProps from vitrage.common.constants import SyncMode from vitrage.common.exception import VitrageTransformerError from vitrage.datasources import OPENSTACK_NODE @@ -83,7 +83,7 @@ def convert_timestamp_format(current_timestamp_format, timestamp): def is_update_event(event): - return event[SyncProps.SYNC_MODE] == SyncMode.UPDATE + return event[DSProps.SYNC_MODE] == SyncMode.UPDATE @six.add_metaclass(abc.ABCMeta) @@ -184,11 +184,11 @@ class TransformerBase(object): :rtype: str """ - sync_mode = entity_event[SyncProps.SYNC_MODE] + sync_mode = entity_event[DSProps.SYNC_MODE] if SyncMode.UPDATE == sync_mode: return self.UPDATE_EVENT_TYPES.get( - entity_event.get(SyncProps.EVENT_TYPE, None), + entity_event.get(DSProps.EVENT_TYPE, None), EventAction.UPDATE_ENTITY) if SyncMode.SNAPSHOT == sync_mode: @@ -212,16 +212,18 @@ class TransformerBase(object): @staticmethod def _create_end_vertex(entity_event): - sync_type = entity_event[SyncProps.SYNC_TYPE] + sync_type = entity_event[DSProps.SYNC_TYPE] return graph_utils.create_vertex( 'END_MESSAGE:' + sync_type, entity_type=sync_type) @staticmethod def _is_end_message(entity_event): - return entity_event[SyncProps.SYNC_MODE] == SyncMode.INIT_SNAPSHOT and\ - SyncProps.EVENT_TYPE in entity_event and \ - entity_event[SyncProps.EVENT_TYPE] == EventAction.END_MESSAGE + + sync_mode = entity_event[DSProps.SYNC_MODE] + is_snapshot_event = sync_mode == SyncMode.INIT_SNAPSHOT + event_type = entity_event.get(DSProps.EVENT_TYPE, None) + return is_snapshot_event and event_type == EventAction.END_MESSAGE @staticmethod def _format_update_timestamp(update_timestamp, sample_timestamp): diff --git a/vitrage/entity_graph/service.py b/vitrage/entity_graph/service.py index 4c6947144..57f86f725 100644 --- a/vitrage/entity_graph/service.py +++ b/vitrage/entity_graph/service.py @@ -58,7 +58,7 @@ class VitrageGraphService(os_service.Service): self._process_event_non_blocking() def _process_event_non_blocking(self): - """Process events received from the synchronizer + """Process events received from datasource In order that other services (such as graph consistency, api handler) could get work time as well, the work processing performed for 2 diff --git a/vitrage/entity_graph/transformer_manager.py b/vitrage/entity_graph/transformer_manager.py index fd48956a9..220aa5688 100644 --- a/vitrage/entity_graph/transformer_manager.py +++ b/vitrage/entity_graph/transformer_manager.py @@ -16,7 +16,7 @@ from oslo_log import log as logging from oslo_utils import importutils -from vitrage.common.constants import SynchronizerProperties as SyncProps +from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.exception import VitrageTransformerError from vitrage.common.utils import opt_exists from vitrage.evaluator.actions.evaluator_event_transformer import \ @@ -75,7 +75,7 @@ class TransformerManager(object): @staticmethod def get_sync_type(entity_event): try: - return entity_event[SyncProps.SYNC_TYPE] + return entity_event[DSProps.SYNC_TYPE] except KeyError: raise VitrageTransformerError( 'Entity Event must contains sync_type field.') diff --git a/vitrage/evaluator/actions/action_executor.py b/vitrage/evaluator/actions/action_executor.py index b7b5e1c35..243daffef 100644 --- a/vitrage/evaluator/actions/action_executor.py +++ b/vitrage/evaluator/actions/action_executor.py @@ -17,7 +17,7 @@ import copy from oslo_log import log as logging from oslo_utils import importutils -from vitrage.common.constants import SynchronizerProperties as SyncProps +from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import SyncMode from vitrage.common.constants import VertexProperties as VProps from vitrage.common import datetime_utils @@ -115,8 +115,8 @@ class ActionExecutor(object): @staticmethod def _add_default_properties(event): - event[SyncProps.SYNC_MODE] = SyncMode.UPDATE - event[SyncProps.SYNC_TYPE] = VITRAGE_TYPE + event[DSProps.SYNC_MODE] = SyncMode.UPDATE + event[DSProps.SYNC_TYPE] = VITRAGE_TYPE event[VProps.UPDATE_TIMESTAMP] = str(datetime_utils.utcnow(False)) event[VProps.SAMPLE_TIMESTAMP] = str(datetime_utils.utcnow()) diff --git a/vitrage/opts.py b/vitrage/opts.py index c2c2849fb..30149b6e4 100644 --- a/vitrage/opts.py +++ b/vitrage/opts.py @@ -25,7 +25,7 @@ import vitrage.evaluator import vitrage.keystone_client import vitrage.rpc -DATASOURCES_MODULE_PATH = 'vitrage.datasources.' +DATASOURCES_PATH = 'vitrage.datasources.' DATASOURCE_FS_PATH = os.path.join('vitrage', 'datasources') DRIVER_FILE = 'driver.py' TRANSFORMER_FILE = 'alarm_transformer_base.py' @@ -44,18 +44,20 @@ def list_opts(): def datasources_opts(): + top = os.getcwd() - plugin_names = _normalize_path_to_plugin_name( - _filter_folders_containing_transformer( - _get_folders_containing_synchronizer(top)), top) - return [(plugin_name, plugin_module.OPTS) for plugin_name in plugin_names - for plugin_module in - [importutils.import_module(DATASOURCES_MODULE_PATH + plugin_name)] - if 'OPTS' in plugin_module.__dict__] + datasources = _normalize_path_to_datasource_name( + _filter_folders_containing_transformer(_get_datasources_folders(top)), + top) + + return [(datasource, module.OPTS) for datasource in datasources + for module in + [importutils.import_module(DATASOURCES_PATH + datasource)] + if 'OPTS' in module.__dict__] -def _get_folders_containing_synchronizer(top=os.getcwd()): +def _get_datasources_folders(top=os.getcwd()): return [os.path.dirname(os.path.join(root, name)) for root, dirs, files in os.walk(top, topdown=False) for name in files if name == DRIVER_FILE] @@ -67,6 +69,6 @@ def _filter_folders_containing_transformer(folders): name in files if name == TRANSFORMER_FILE] -def _normalize_path_to_plugin_name(path_list, top=os.getcwd()): +def _normalize_path_to_datasource_name(path_list, top=os.getcwd()): return [os.path.relpath(path, os.path.join(top, DATASOURCE_FS_PATH)) .replace(os.sep, '.') for path in path_list] diff --git a/vitrage/tests/functional/base.py b/vitrage/tests/functional/base.py index c99705ce7..1500e1616 100644 --- a/vitrage/tests/functional/base.py +++ b/vitrage/tests/functional/base.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -from vitrage.common.constants import SynchronizerProperties as SyncProps +from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import SyncMode from vitrage.entity_graph.initialization_status import InitializationStatus from vitrage.entity_graph.processor import processor as proc @@ -38,15 +38,15 @@ class TestFunctionalBase(TestEntityGraphUnitBase): self.NUM_ZONES, self.NUM_HOSTS, snapshot_events=self.NUM_ZONES, - snap_vals={SyncProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT}) + snap_vals={DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT}) gen_list += mock_driver.simple_host_generators( self.NUM_ZONES, self.NUM_HOSTS, self.NUM_HOSTS, - snap_vals={SyncProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT}) + snap_vals={DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT}) gen_list += mock_driver.simple_instance_generators( self.NUM_HOSTS, self.NUM_INSTANCES, self.NUM_INSTANCES, - snap_vals={SyncProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT}) + snap_vals={DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT}) return mock_driver.generate_sequential_events_list(gen_list) diff --git a/vitrage/tests/functional/datasources/static_physical/test_static_physical.py b/vitrage/tests/functional/datasources/static_physical/test_static_physical.py index f351877d1..e901fee44 100644 --- a/vitrage/tests/functional/datasources/static_physical/test_static_physical.py +++ b/vitrage/tests/functional/datasources/static_physical/test_static_physical.py @@ -14,8 +14,8 @@ from oslo_config import cfg +from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EntityCategory -from vitrage.common.constants import SynchronizerProperties as SyncProps from vitrage.common.constants import VertexProperties as VProps from vitrage.datasources import NAGIOS_DATASOURCE from vitrage.datasources import NOVA_HOST_DATASOURCE @@ -66,7 +66,7 @@ class TestStaticPhysical(TestDataSourcesBase): snapshot_events=1) static_events = mock_driver.generate_random_events_list(spec_list) static_physical_event = static_events[0] - static_physical_event[SyncProps.SYNC_TYPE] = SWITCH + static_physical_event[DSProps.SYNC_TYPE] = SWITCH static_physical_event['relationships'][0]['name'] = \ self._find_entity_id_by_type(processor.entity_graph, NOVA_HOST_DATASOURCE) diff --git a/vitrage/tests/mocks/mock_transformer.py b/vitrage/tests/mocks/mock_transformer.py index 938b2b061..44f2c7f50 100644 --- a/vitrage/tests/mocks/mock_transformer.py +++ b/vitrage/tests/mocks/mock_transformer.py @@ -29,7 +29,7 @@ def generate_random_events_list(generator_spec_list): :param generator_spec_list: list of generators :type generator_spec_list: list - :return list of synchronizer events + :return list of datasource events :rtype list """ diff --git a/vitrage/tests/mocks/utils.py b/vitrage/tests/mocks/utils.py index 1d3a79b0d..d11c0ac43 100644 --- a/vitrage/tests/mocks/utils.py +++ b/vitrage/tests/mocks/utils.py @@ -57,7 +57,7 @@ def _get_full_path(target_filename, target_folder): """ if target_folder is None: - target_folder = '%s/mock_configurations/synchronizer' % \ + target_folder = '%s/mock_configurations/driver' % \ get_resources_dir() target = '{0}/{1}'.format(target_folder, target_filename) return target diff --git a/vitrage/tests/resources/mock_configurations/synchronizer/driver_host_snapshot_dynamic.json b/vitrage/tests/resources/mock_configurations/driver/driver_host_snapshot_dynamic.json similarity index 100% rename from vitrage/tests/resources/mock_configurations/synchronizer/driver_host_snapshot_dynamic.json rename to vitrage/tests/resources/mock_configurations/driver/driver_host_snapshot_dynamic.json diff --git a/vitrage/tests/resources/mock_configurations/synchronizer/driver_inst_snapshot_dynamic.json b/vitrage/tests/resources/mock_configurations/driver/driver_inst_snapshot_dynamic.json similarity index 100% rename from vitrage/tests/resources/mock_configurations/synchronizer/driver_inst_snapshot_dynamic.json rename to vitrage/tests/resources/mock_configurations/driver/driver_inst_snapshot_dynamic.json diff --git a/vitrage/tests/resources/mock_configurations/synchronizer/driver_inst_snapshot_static.json b/vitrage/tests/resources/mock_configurations/driver/driver_inst_snapshot_static.json similarity index 100% rename from vitrage/tests/resources/mock_configurations/synchronizer/driver_inst_snapshot_static.json rename to vitrage/tests/resources/mock_configurations/driver/driver_inst_snapshot_static.json diff --git a/vitrage/tests/resources/mock_configurations/synchronizer/driver_inst_update_dynamic.json b/vitrage/tests/resources/mock_configurations/driver/driver_inst_update_dynamic.json similarity index 100% rename from vitrage/tests/resources/mock_configurations/synchronizer/driver_inst_update_dynamic.json rename to vitrage/tests/resources/mock_configurations/driver/driver_inst_update_dynamic.json diff --git a/vitrage/tests/resources/mock_configurations/synchronizer/driver_nagios_snapshot_dynamic.json b/vitrage/tests/resources/mock_configurations/driver/driver_nagios_snapshot_dynamic.json similarity index 100% rename from vitrage/tests/resources/mock_configurations/synchronizer/driver_nagios_snapshot_dynamic.json rename to vitrage/tests/resources/mock_configurations/driver/driver_nagios_snapshot_dynamic.json diff --git a/vitrage/tests/resources/mock_configurations/synchronizer/driver_nagios_snapshot_static.json b/vitrage/tests/resources/mock_configurations/driver/driver_nagios_snapshot_static.json similarity index 100% rename from vitrage/tests/resources/mock_configurations/synchronizer/driver_nagios_snapshot_static.json rename to vitrage/tests/resources/mock_configurations/driver/driver_nagios_snapshot_static.json diff --git a/vitrage/tests/resources/mock_configurations/synchronizer/driver_switch_snapshot_dynamic.json b/vitrage/tests/resources/mock_configurations/driver/driver_switch_snapshot_dynamic.json similarity index 100% rename from vitrage/tests/resources/mock_configurations/synchronizer/driver_switch_snapshot_dynamic.json rename to vitrage/tests/resources/mock_configurations/driver/driver_switch_snapshot_dynamic.json diff --git a/vitrage/tests/resources/mock_configurations/synchronizer/driver_volume_snapshot_dynamic.json b/vitrage/tests/resources/mock_configurations/driver/driver_volume_snapshot_dynamic.json similarity index 100% rename from vitrage/tests/resources/mock_configurations/synchronizer/driver_volume_snapshot_dynamic.json rename to vitrage/tests/resources/mock_configurations/driver/driver_volume_snapshot_dynamic.json diff --git a/vitrage/tests/resources/mock_configurations/synchronizer/driver_volume_update_dynamic.json b/vitrage/tests/resources/mock_configurations/driver/driver_volume_update_dynamic.json similarity index 100% rename from vitrage/tests/resources/mock_configurations/synchronizer/driver_volume_update_dynamic.json rename to vitrage/tests/resources/mock_configurations/driver/driver_volume_update_dynamic.json diff --git a/vitrage/tests/resources/mock_configurations/synchronizer/driver_zone_snapshot_dynamic.json b/vitrage/tests/resources/mock_configurations/driver/driver_zone_snapshot_dynamic.json similarity index 100% rename from vitrage/tests/resources/mock_configurations/synchronizer/driver_zone_snapshot_dynamic.json rename to vitrage/tests/resources/mock_configurations/driver/driver_zone_snapshot_dynamic.json diff --git a/vitrage/tests/unit/datasources/cinder/test_cinder_volume_transformer.py b/vitrage/tests/unit/datasources/cinder/test_cinder_volume_transformer.py index 9b4b749b4..5ee49110e 100644 --- a/vitrage/tests/unit/datasources/cinder/test_cinder_volume_transformer.py +++ b/vitrage/tests/unit/datasources/cinder/test_cinder_volume_transformer.py @@ -16,9 +16,9 @@ import datetime from oslo_log import log as logging +from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EdgeLabels from vitrage.common.constants import EntityCategory -from vitrage.common.constants import SynchronizerProperties as SyncProps from vitrage.common.constants import VertexProperties as VProps from vitrage.datasources.cinder.volume import CINDER_VOLUME_DATASOURCE from vitrage.datasources.cinder.volume.transformer \ @@ -151,14 +151,14 @@ class TestCinderVolumeTransformer(base.BaseTest): is_update_event = tbase.is_update_event(event) self.assertEqual(EntityCategory.RESOURCE, vertex[VProps.CATEGORY]) - self.assertEqual(event[SyncProps.SYNC_TYPE], vertex[VProps.TYPE]) + self.assertEqual(event[DSProps.SYNC_TYPE], vertex[VProps.TYPE]) id_field_path = 'volume_id' if is_update_event else 'id' self.assertEqual( tbase.extract_field_value(event, id_field_path), vertex[VProps.ID]) - self.assertEqual(event[SyncProps.SAMPLE_DATE], + self.assertEqual(event[DSProps.SAMPLE_DATE], vertex[VProps.SAMPLE_TIMESTAMP]) name_field_path = 'display_name' diff --git a/vitrage/tests/unit/datasources/nagios/test_nagios_config.py b/vitrage/tests/unit/datasources/nagios/test_nagios_config.py index 1f6802991..eb6b97607 100644 --- a/vitrage/tests/unit/datasources/nagios/test_nagios_config.py +++ b/vitrage/tests/unit/datasources/nagios/test_nagios_config.py @@ -35,7 +35,7 @@ class TestNagiosConfig(base.BaseTest): required=True), cfg.StrOpt('driver', default='vitrage.datasources.nagios.driver.NagiosDriver', - help='Nagios plugin synchronizer class path', + help='Nagios driver class path', required=True), cfg.IntOpt('changes_interval', default=30, diff --git a/vitrage/tests/unit/datasources/nagios/test_nagios_transformer.py b/vitrage/tests/unit/datasources/nagios/test_nagios_transformer.py index 9349d88eb..90ab7223b 100644 --- a/vitrage/tests/unit/datasources/nagios/test_nagios_transformer.py +++ b/vitrage/tests/unit/datasources/nagios/test_nagios_transformer.py @@ -14,10 +14,10 @@ from oslo_log import log as logging +from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EdgeLabels from vitrage.common.constants import EntityCategory from vitrage.common.constants import EventAction -from vitrage.common.constants import SynchronizerProperties as SyncProps from vitrage.common.constants import SyncMode from vitrage.common.constants import VertexProperties as VProps from vitrage.datasources.alarm_properties import AlarmProperties as AlarmProps @@ -62,7 +62,7 @@ class NagiosTransformerTest(base.BaseTest): TransformerBase.KEY_SEPARATOR) self.assertEqual(EntityCategory.ALARM, observed_key_fields[0]) - self.assertEqual(event[SyncProps.SYNC_TYPE], observed_key_fields[1]) + self.assertEqual(event[DSProps.SYNC_TYPE], observed_key_fields[1]) self.assertEqual(event[NagiosProperties.RESOURCE_NAME], observed_key_fields[2]) self.assertEqual(event[NagiosProperties.SERVICE], @@ -92,7 +92,7 @@ class NagiosTransformerTest(base.BaseTest): self._validate_action(alarm, wrapper) def _validate_action(self, alarm, wrapper): - sync_mode = alarm[SyncProps.SYNC_MODE] + sync_mode = alarm[DSProps.SYNC_MODE] if sync_mode in (SyncMode.SNAPSHOT, SyncMode.UPDATE): if alarm[NagiosProperties.STATUS] == 'OK': self.assertEqual(EventAction.DELETE_ENTITY, wrapper.action) @@ -104,7 +104,7 @@ class NagiosTransformerTest(base.BaseTest): def _validate_vertex(self, vertex, event): self.assertEqual(EntityCategory.ALARM, vertex[VProps.CATEGORY]) - self.assertEqual(event[SyncProps.SYNC_TYPE], vertex[VProps.TYPE]) + self.assertEqual(event[DSProps.SYNC_TYPE], vertex[VProps.TYPE]) self.assertEqual(event[NagiosProperties.SERVICE], vertex[VProps.NAME]) event_status = event[NagiosProperties.STATUS] diff --git a/vitrage/tests/unit/datasources/nova/test_nova_host_transformer.py b/vitrage/tests/unit/datasources/nova/test_nova_host_transformer.py index 757fd4c0c..692447643 100644 --- a/vitrage/tests/unit/datasources/nova/test_nova_host_transformer.py +++ b/vitrage/tests/unit/datasources/nova/test_nova_host_transformer.py @@ -16,10 +16,10 @@ import datetime from oslo_log import log as logging +from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EdgeLabels from vitrage.common.constants import EntityCategory from vitrage.common.constants import EventAction -from vitrage.common.constants import SynchronizerProperties as SyncProps from vitrage.common.constants import SyncMode from vitrage.common.constants import VertexProperties from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE @@ -124,7 +124,7 @@ class NovaHostTransformerTest(base.BaseTest): self.assertEqual(1, len(neighbors)) self._validate_zone_neighbor(neighbors[0], event) - if SyncMode.SNAPSHOT == event[SyncProps.SYNC_MODE]: + if SyncMode.SNAPSHOT == event[DSProps.SYNC_MODE]: self.assertEqual(EventAction.UPDATE_ENTITY, wrapper.action) else: self.assertEqual(EventAction.CREATE_ENTITY, wrapper.action) @@ -132,7 +132,7 @@ class NovaHostTransformerTest(base.BaseTest): def _validate_zone_neighbor(self, zone, event): zone_name = tbase.extract_field_value(event, 'zone') - time = event[SyncProps.SAMPLE_DATE] + time = event[DSProps.SAMPLE_DATE] zt = self.transformers[NOVA_ZONE_DATASOURCE] properties = { @@ -169,7 +169,7 @@ class NovaHostTransformerTest(base.BaseTest): vertex[VertexProperties.TYPE] ) - expected_timestamp = event[SyncProps.SAMPLE_DATE] + expected_timestamp = event[DSProps.SAMPLE_DATE] observed_timestamp = vertex[VertexProperties.SAMPLE_TIMESTAMP] self.assertEqual(expected_timestamp, observed_timestamp) @@ -191,7 +191,7 @@ class NovaHostTransformerTest(base.BaseTest): zone_num=1, host_num=1, snapshot_events=1, - snap_vals={SyncProps.SYNC_MODE: SyncMode.SNAPSHOT}) + snap_vals={DSProps.SYNC_MODE: SyncMode.SNAPSHOT}) hosts_events = mock_sync.generate_random_events_list(spec_list) host_transformer = HostTransformer(self.transformers) @@ -207,7 +207,7 @@ class NovaHostTransformerTest(base.BaseTest): zone_num=1, host_num=1, snapshot_events=1, - snap_vals={SyncProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT}) + snap_vals={DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT}) hosts_events = mock_sync.generate_random_events_list(spec_list) host_transformer = HostTransformer(self.transformers) diff --git a/vitrage/tests/unit/datasources/nova/test_nova_instance_transformers.py b/vitrage/tests/unit/datasources/nova/test_nova_instance_transformers.py index f5213d5e2..18248f2b4 100644 --- a/vitrage/tests/unit/datasources/nova/test_nova_instance_transformers.py +++ b/vitrage/tests/unit/datasources/nova/test_nova_instance_transformers.py @@ -16,10 +16,10 @@ import datetime from oslo_log import log as logging +from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EdgeLabels from vitrage.common.constants import EntityCategory from vitrage.common.constants import EventAction -from vitrage.common.constants import SynchronizerProperties as SyncProps from vitrage.common.constants import SyncMode from vitrage.common.constants import VertexProperties from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE @@ -109,7 +109,7 @@ class NovaInstanceTransformerTest(base.BaseTest): host_neighbor = wrapper.neighbors[0] self._validate_host_neighbor(host_neighbor, event) - sync_mode = event[SyncProps.SYNC_MODE] + sync_mode = event[DSProps.SYNC_MODE] if sync_mode == SyncMode.INIT_SNAPSHOT: self.assertEqual(EventAction.CREATE_ENTITY, wrapper.action) elif sync_mode == SyncMode.SNAPSHOT: @@ -138,7 +138,7 @@ class NovaInstanceTransformerTest(base.BaseTest): self.assertEqual(1, len(neighbors)) self._validate_host_neighbor(neighbors[0], event) - event_type = event[SyncProps.EVENT_TYPE] + event_type = event[DSProps.EVENT_TYPE] if event_type == 'compute.instance.delete.end': self.assertEqual(EventAction.DELETE_ENTITY, wrapper.action) elif event_type == 'compute.instance.create.start': @@ -175,7 +175,7 @@ class NovaInstanceTransformerTest(base.BaseTest): observed_state = vertex[VertexProperties.STATE] self.assertEqual(expected_state, observed_state) - expected_timestamp = event[SyncProps.SAMPLE_DATE] + expected_timestamp = event[DSProps.SAMPLE_DATE] observed_timestamp = vertex[VertexProperties.SAMPLE_TIMESTAMP] self.assertEqual(expected_timestamp, observed_timestamp) @@ -197,7 +197,7 @@ class NovaInstanceTransformerTest(base.BaseTest): name = 'host' if tbase.is_update_event(event) \ else 'OS-EXT-SRV-ATTR:host' host_name = tbase.extract_field_value(event, name) - time = event[SyncProps.SAMPLE_DATE] + time = event[DSProps.SAMPLE_DATE] ht = self.transformers[NOVA_HOST_DATASOURCE] properties = { diff --git a/vitrage/tests/unit/datasources/nova/test_nova_zone_transformer.py b/vitrage/tests/unit/datasources/nova/test_nova_zone_transformer.py index bcd02acc3..f847ce359 100644 --- a/vitrage/tests/unit/datasources/nova/test_nova_zone_transformer.py +++ b/vitrage/tests/unit/datasources/nova/test_nova_zone_transformer.py @@ -16,9 +16,9 @@ import datetime from oslo_log import log as logging +from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EdgeLabels from vitrage.common.constants import EntityCategory -from vitrage.common.constants import SynchronizerProperties as SyncProps from vitrage.common.constants import VertexProperties from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE from vitrage.datasources.nova.host.transformer import HostTransformer @@ -143,7 +143,7 @@ class NovaZoneTransformerTest(base.BaseTest): self._validate_host_neighbor(neighbor, zone_vertex_id, hosts, - event[SyncProps.SYNC_MODE]) + event[DSProps.SYNC_MODE]) self.assertEqual(1, node_neighbors_counter, @@ -218,7 +218,7 @@ class NovaZoneTransformerTest(base.BaseTest): self.assertEqual(NOVA_ZONE_DATASOURCE, vertex[VertexProperties.TYPE]) - expected_timestamp = event[SyncProps.SAMPLE_DATE] + expected_timestamp = event[DSProps.SAMPLE_DATE] observed_timestamp = vertex[VertexProperties.SAMPLE_TIMESTAMP] self.assertEqual(expected_timestamp, observed_timestamp) diff --git a/vitrage/tests/unit/datasources/static_physical/test_static_physical_driver.py b/vitrage/tests/unit/datasources/static_physical/test_static_physical_driver.py index 7f60366df..004197f33 100644 --- a/vitrage/tests/unit/datasources/static_physical/test_static_physical_driver.py +++ b/vitrage/tests/unit/datasources/static_physical/test_static_physical_driver.py @@ -17,8 +17,8 @@ import os from oslo_config import cfg from oslo_log import log as logging +from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EventAction -from vitrage.common.constants import SynchronizerProperties as SyncProps from vitrage.common.constants import SyncMode from vitrage.common.constants import VertexProperties as VProps from vitrage.common import file_utils @@ -119,7 +119,7 @@ class TestStaticPhysicalDriver(base.BaseTest): status = any(change[VProps.TYPE] == SWITCH and change[VProps.ID] == '23456' and - change[SyncProps.EVENT_TYPE] == EventAction.DELETE_ENTITY + change[DSProps.EVENT_TYPE] == EventAction.DELETE_ENTITY for change in changes) self.assertEqual(True, status) diff --git a/vitrage/tests/unit/datasources/static_physical/test_static_physical_transformer.py b/vitrage/tests/unit/datasources/static_physical/test_static_physical_transformer.py index 5fb913aa9..b481e5a84 100644 --- a/vitrage/tests/unit/datasources/static_physical/test_static_physical_transformer.py +++ b/vitrage/tests/unit/datasources/static_physical/test_static_physical_transformer.py @@ -16,9 +16,9 @@ import datetime from oslo_log import log as logging +from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EdgeLabels from vitrage.common.constants import EntityCategory -from vitrage.common.constants import SynchronizerProperties as SyncProps from vitrage.common.constants import VertexProperties as VProps from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE from vitrage.datasources.nova.host.transformer import HostTransformer @@ -166,7 +166,7 @@ class TestStaticPhysicalTransformer(base.BaseTest): def _validate_switch_vertex_props(self, vertex, event): self._validate_common_vertex_props(vertex, event) - self.assertEqual(event[SyncProps.SAMPLE_DATE], + self.assertEqual(event[DSProps.SAMPLE_DATE], vertex[VProps.SAMPLE_TIMESTAMP]) self.assertEqual(event[VProps.NAME], vertex[VProps.NAME]) self.assertEqual(event[VProps.STATE], vertex[VProps.STATE]) diff --git a/vitrage/tests/unit/entity_graph/base.py b/vitrage/tests/unit/entity_graph/base.py index 41b7a7e24..a1184c503 100644 --- a/vitrage/tests/unit/entity_graph/base.py +++ b/vitrage/tests/unit/entity_graph/base.py @@ -14,8 +14,8 @@ from oslo_config import cfg +from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EntityCategory -from vitrage.common.constants import SynchronizerProperties as SyncProps from vitrage.common.constants import SyncMode from vitrage.common.datetime_utils import utcnow from vitrage.datasources.nagios import NAGIOS_DATASOURCE @@ -81,17 +81,17 @@ class TestEntityGraphUnitBase(base.BaseTest): self.NUM_ZONES, self.NUM_HOSTS, snapshot_events=self.NUM_ZONES, - snap_vals={SyncProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT}) + snap_vals={DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT}) gen_list += mock_sync.simple_host_generators( self.NUM_ZONES, self.NUM_HOSTS, self.NUM_HOSTS, - snap_vals={SyncProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT}) + snap_vals={DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT}) gen_list += mock_sync.simple_instance_generators( self.NUM_HOSTS, self.NUM_INSTANCES, self.NUM_INSTANCES, - snap_vals={SyncProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT}) + snap_vals={DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT}) return mock_sync.generate_sequential_events_list(gen_list) def _create_entity(self, processor=None, spec_type=None, sync_mode=None, @@ -122,10 +122,10 @@ class TestEntityGraphUnitBase(base.BaseTest): # update properties if sync_mode is not None: - events_list[0][SyncProps.SYNC_MODE] = sync_mode + events_list[0][DSProps.SYNC_MODE] = sync_mode if event_type is not None: - events_list[0][SyncProps.EVENT_TYPE] = event_type + events_list[0][DSProps.EVENT_TYPE] = event_type if properties is not None: for key, value in properties.items(): diff --git a/vitrage/tests/unit/entity_graph/processor/test_processor.py b/vitrage/tests/unit/entity_graph/processor/test_processor.py index d755ca3c0..fa9a52a0e 100644 --- a/vitrage/tests/unit/entity_graph/processor/test_processor.py +++ b/vitrage/tests/unit/entity_graph/processor/test_processor.py @@ -16,8 +16,8 @@ import unittest from oslo_config import cfg +from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EventAction -from vitrage.common.constants import SynchronizerProperties as SyncProps from vitrage.common.constants import SyncMode from vitrage.common.constants import VertexProperties as VProps from vitrage.common.datetime_utils import utcnow @@ -63,16 +63,16 @@ class TestProcessor(TestEntityGraphUnitBase): # check update instance even # TODO(Alexey): Create an event in update event structure # (update snapshot fields won't work) - event[SyncProps.SYNC_MODE] = SyncMode.UPDATE - event[SyncProps.EVENT_TYPE] = 'compute.instance.volume.attach' + event[DSProps.SYNC_MODE] = SyncMode.UPDATE + event[DSProps.EVENT_TYPE] = 'compute.instance.volume.attach' event['hostname'] = 'new_host' processor.process_event(event) self._check_graph(processor, self.NUM_VERTICES_AFTER_CREATION, self.NUM_EDGES_AFTER_CREATION) # check delete instance event - event[SyncProps.SYNC_MODE] = SyncMode.UPDATE - event[SyncProps.EVENT_TYPE] = 'compute.instance.delete.end' + event[DSProps.SYNC_MODE] = SyncMode.UPDATE + event[DSProps.EVENT_TYPE] = 'compute.instance.delete.end' processor.process_event(event) self._check_graph(processor, self.NUM_VERTICES_AFTER_DELETION, self.NUM_EDGES_AFTER_DELETION)