From aac14c51a2a066d02c3171025d7d10366a09beeb Mon Sep 17 00:00:00 2001 From: Alexey Weyl Date: Sun, 27 Nov 2016 10:23:19 +0200 Subject: [PATCH] rename internal vitrage properties 1. vitrage_sync_mode to vitrage_action_type 2. vitrage_sync_type to vitrage_entity_type Change-Id: Icd60d8f6f6c5658449028bcec9688f61b8da7c62 --- doc/source/add-new-datasource.rst | 4 +-- vitrage/common/constants.py | 6 ++-- vitrage/datasources/alarm_driver_base.py | 16 +++++----- vitrage/datasources/alarm_transformer_base.py | 11 ++++--- vitrage/datasources/aodh/driver.py | 2 +- vitrage/datasources/aodh/transformer.py | 6 ++-- vitrage/datasources/cinder/volume/driver.py | 8 ++--- vitrage/datasources/driver_base.py | 32 +++++++++---------- vitrage/datasources/heat/stack/driver.py | 8 ++--- vitrage/datasources/nagios/driver.py | 5 +-- vitrage/datasources/nagios/transformer.py | 6 ++-- vitrage/datasources/neutron/network/driver.py | 8 ++--- vitrage/datasources/neutron/port/driver.py | 8 ++--- vitrage/datasources/nova/host/driver.py | 4 +-- vitrage/datasources/nova/instance/driver.py | 8 ++--- .../datasources/nova/instance/transformer.py | 2 +- vitrage/datasources/nova/zone/driver.py | 6 ++-- vitrage/datasources/services.py | 13 ++++---- vitrage/datasources/static/driver.py | 8 ++--- vitrage/datasources/static/transformer.py | 8 ++--- vitrage/datasources/static_physical/driver.py | 8 ++--- .../static_physical/transformer.py | 8 ++--- vitrage/datasources/transformer_base.py | 24 +++++++------- vitrage/datasources/zabbix/driver.py | 6 ++-- vitrage/datasources/zabbix/transformer.py | 6 ++-- .../consistency/consistency_enforcer.py | 6 ++-- vitrage/entity_graph/transformer_manager.py | 18 +++++------ vitrage/evaluator/actions/action_executor.py | 6 ++-- vitrage/tests/functional/base.py | 8 ++--- .../static_physical/test_static_physical.py | 2 +- .../states/test_datasource_info_mapper.py | 6 ++-- .../evaluator/test_action_executor.py | 8 ++--- .../evaluator/test_scenario_evaluator.py | 2 +- vitrage/tests/mocks/mock_driver.py | 2 +- .../driver_consistency_update_dynamic.json | 4 +-- .../driver/driver_host_snapshot_dynamic.json | 4 +-- .../driver/driver_inst_snapshot_dynamic.json | 4 +-- .../driver/driver_inst_update_dynamic.json | 2 +- .../driver_nagios_snapshot_dynamic.json | 4 +-- .../driver/driver_stack_snapshot_dynamic.json | 4 +-- .../driver/driver_stack_update_dynamic.json | 4 +-- .../driver_switch_snapshot_dynamic.json | 2 +- .../driver_volume_snapshot_dynamic.json | 4 +-- .../driver/driver_volume_update_dynamic.json | 4 +-- .../driver_zabbix_snapshot_dynamic.json | 4 +-- .../driver/driver_zone_snapshot_dynamic.json | 4 +-- .../transformer_host_snapshot_static.json | 2 +- .../transformer_inst_snapshot_dynamic.json | 4 +-- .../transformer_zone_snapshot_static.json | 2 +- .../cinder/test_cinder_volume_transformer.py | 2 +- .../heat/test_heat_stack_transformer.py | 2 +- .../nagios/test_nagios_transformer.py | 10 +++--- .../nova/test_nova_host_transformer.py | 8 ++--- ...s.py => test_nova_instance_transformer.py} | 8 ++--- .../nova/test_nova_zone_transformer.py | 4 +-- .../datasources/static/test_static_driver.py | 6 ++-- .../test_static_physical_driver.py | 7 ++-- .../zabbix/test_zabbix_transformer.py | 10 +++--- vitrage/tests/unit/entity_graph/base.py | 18 +++++------ .../entity_graph/processor/test_processor.py | 20 ++++++------ vitrage_tempest_tests/tests/base_mock.py | 7 ++-- 61 files changed, 219 insertions(+), 214 deletions(-) rename vitrage/tests/unit/datasources/nova/{test_nova_instance_transformers.py => test_nova_instance_transformer.py} (98%) diff --git a/doc/source/add-new-datasource.rst b/doc/source/add-new-datasource.rst index 2bff48b79..a7731e219 100644 --- a/doc/source/add-new-datasource.rst +++ b/doc/source/add-new-datasource.rst @@ -71,9 +71,9 @@ and must implement the following methods: +----------------------+------------------------------------+--------------------------------+--------------------------------+ | Name | Input | Output | Comments | +======================+====================================+================================+================================+ -| get_all | sync mode | entities | for snapshot mechanism | +| get_all | action type | entities | for snapshot mechanism | +----------------------+------------------------------------+--------------------------------+--------------------------------+ -| get_changes | sync mode | entities | for update pulling mechanism | +| get_changes | action type | entities | for update pulling mechanism | +----------------------+------------------------------------+--------------------------------+--------------------------------+ | get_event_types | | event types | for update pushing mechanism | +----------------------+------------------------------------+--------------------------------+--------------------------------+ diff --git a/vitrage/common/constants.py b/vitrage/common/constants.py index 4c9109531..0ed2b9ab4 100644 --- a/vitrage/common/constants.py +++ b/vitrage/common/constants.py @@ -64,7 +64,7 @@ class EdgeLabel(object): if not label.startswith(('_', 'labels'))] -class SyncMode(object): +class ActionType(object): SNAPSHOT = 'snapshot' INIT_SNAPSHOT = 'init_snapshot' UPDATE = 'update' @@ -88,8 +88,8 @@ class EntityCategory(object): class DatasourceProperties(object): - SYNC_TYPE = 'vitrage_sync_type' - SYNC_MODE = 'vitrage_sync_mode' + ENTITY_TYPE = 'vitrage_entity_type' + ACTION_TYPE = 'vitrage_action_type' SAMPLE_DATE = 'vitrage_sample_date' EVENT_TYPE = 'vitrage_event_type' diff --git a/vitrage/datasources/alarm_driver_base.py b/vitrage/datasources/alarm_driver_base.py index 75cdd088c..a239c3fd7 100644 --- a/vitrage/datasources/alarm_driver_base.py +++ b/vitrage/datasources/alarm_driver_base.py @@ -26,8 +26,8 @@ class AlarmDriverBase(DriverBase): super(DriverBase, self).__init__() self.cache = dict() - def _sync_type(self): - """Return the type of the plugin """ + def _entity_type(self): + """Return the type of the datasource """ pass def _alarm_key(self, alarm): @@ -71,15 +71,15 @@ class AlarmDriverBase(DriverBase): """ pass - def get_all(self, sync_mode): + def get_all(self, action_type): return self.make_pickleable(self._get_all_alarms(), - self._sync_type(), - sync_mode) + self._entity_type(), + action_type) - def get_changes(self, sync_mode): + def get_changes(self, action_type): return self.make_pickleable(self._get_changed_alarms(), - self._sync_type(), - sync_mode) + self._entity_type(), + action_type) def _get_all_alarms(self): alarms = self._get_alarms() diff --git a/vitrage/datasources/alarm_transformer_base.py b/vitrage/datasources/alarm_transformer_base.py index f1c279578..46410c368 100644 --- a/vitrage/datasources/alarm_transformer_base.py +++ b/vitrage/datasources/alarm_transformer_base.py @@ -14,10 +14,10 @@ from oslo_log import log as logging +from vitrage.common.constants import ActionType 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 SyncMode from vitrage.common.exception import VitrageTransformerError from vitrage.datasources.alarm_properties import AlarmProperties as AlarmProps from vitrage.datasources import transformer_base as tbase @@ -44,15 +44,16 @@ class AlarmTransformerBase(tbase.TransformerBase): entity_event[DSProps.EVENT_TYPE] == EventAction.DELETE_ENTITY: return entity_event[DSProps.EVENT_TYPE] - sync_mode = entity_event[DSProps.SYNC_MODE] - if sync_mode in (SyncMode.UPDATE, SyncMode.SNAPSHOT): + action_type = entity_event[DSProps.ACTION_TYPE] + if action_type in (ActionType.UPDATE, ActionType.SNAPSHOT): return EventAction.DELETE_ENTITY if self._ok_status(entity_event) \ else EventAction.UPDATE_ENTITY - if SyncMode.INIT_SNAPSHOT == sync_mode: + if ActionType.INIT_SNAPSHOT == action_type: return EventAction.CREATE_ENTITY - raise VitrageTransformerError('Invalid sync mode: (%s)' % sync_mode) + raise VitrageTransformerError('Invalid action type: (%s)' + % action_type) def _key_values(self, *args): return (EntityCategory.ALARM,) + args diff --git a/vitrage/datasources/aodh/driver.py b/vitrage/datasources/aodh/driver.py index b6c584d4b..bdaf68446 100644 --- a/vitrage/datasources/aodh/driver.py +++ b/vitrage/datasources/aodh/driver.py @@ -35,7 +35,7 @@ class AodhDriver(AlarmDriverBase): self._client = os_clients.ceilometer_client(self.conf) return self._client - def _sync_type(self): + def _entity_type(self): return AODH_DATASOURCE def _alarm_key(self, alarm): diff --git a/vitrage/datasources/aodh/transformer.py b/vitrage/datasources/aodh/transformer.py index 8a602963a..4043e57b4 100644 --- a/vitrage/datasources/aodh/transformer.py +++ b/vitrage/datasources/aodh/transformer.py @@ -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[DSProps.SYNC_TYPE], + entity_type=entity_event[DSProps.ENTITY_TYPE], entity_state=self._get_alarm_state(entity_event), sample_timestamp=sample_timestamp, update_timestamp=update_timestamp, @@ -122,9 +122,9 @@ class AodhTransformer(AlarmTransformerBase): if _is_vitrage_alarm(entity_event): return entity_event.get(AodhProps.VITRAGE_ID) - sync_type = entity_event[DSProps.SYNC_TYPE] + entity_type = entity_event[DSProps.ENTITY_TYPE] alarm_id = entity_event[AodhProps.ALARM_ID] - return tbase.build_key(self._key_values(sync_type, alarm_id)) + return tbase.build_key(self._key_values(entity_type, alarm_id)) @staticmethod def _timestamp(entity_event): diff --git a/vitrage/datasources/cinder/volume/driver.py b/vitrage/datasources/cinder/volume/driver.py index 79a4a003d..184b76d7f 100644 --- a/vitrage/datasources/cinder/volume/driver.py +++ b/vitrage/datasources/cinder/volume/driver.py @@ -12,8 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. +from vitrage.common.constants import ActionType 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 from vitrage import os_clients @@ -36,12 +36,12 @@ class CinderVolumeDriver(DriverBase): def extract_events(volumes): return [volume.__dict__ for volume in volumes] - def get_all(self, sync_mode): + def get_all(self, action_type): return self.make_pickleable( self.extract_events(self.client.volumes.list( search_opts={'all_tenants': 1})), CINDER_VOLUME_DATASOURCE, - sync_mode, + action_type, 'manager') @staticmethod @@ -50,7 +50,7 @@ class CinderVolumeDriver(DriverBase): return CinderVolumeDriver.make_pickleable([event], CINDER_VOLUME_DATASOURCE, - SyncMode.UPDATE)[0] + ActionType.UPDATE)[0] @staticmethod def get_event_types(): diff --git a/vitrage/datasources/driver_base.py b/vitrage/datasources/driver_base.py index c917ae906..82f0f555a 100644 --- a/vitrage/datasources/driver_base.py +++ b/vitrage/datasources/driver_base.py @@ -17,9 +17,9 @@ import six from oslo_log import log +from vitrage.common.constants import ActionType from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EventAction -from vitrage.common.constants import SyncMode from vitrage.common import datetime_utils LOG = log.getLogger(__name__) @@ -32,54 +32,54 @@ class DriverBase(object): pass @abc.abstractmethod - def get_all(self, sync_mode): + def get_all(self, action_type): pass def callback_on_fault(self, exception): LOG.exception('Exception: {0}'.format(exception)) @staticmethod - def _get_end_message(sync_type): + def _get_end_message(entity_type): end_message = { - DSProps.SYNC_TYPE: sync_type, - DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT, + DSProps.ENTITY_TYPE: entity_type, + DSProps.ACTION_TYPE: ActionType.INIT_SNAPSHOT, DSProps.EVENT_TYPE: EventAction.END_MESSAGE } return end_message - def get_changes(self, sync_mode): + def get_changes(self, action_type): pass @classmethod - def make_pickleable(cls, entities, sync_type, sync_mode, *args): + def make_pickleable(cls, entities, entity_type, action_type, *args): pickleable_entities = [] for entity in entities: for field in args: entity.pop(field, None) - cls._add_sync_type(entity, sync_type) - cls._add_sync_mode(entity, sync_mode) + cls._add_entity_type(entity, entity_type) + cls._add_action_type(entity, action_type) cls._add_sampling_time(entity) pickleable_entities.append(entity) - if sync_mode == SyncMode.INIT_SNAPSHOT: - pickleable_entities.append(cls._get_end_message(sync_type)) + if action_type == ActionType.INIT_SNAPSHOT: + pickleable_entities.append(cls._get_end_message(entity_type)) return pickleable_entities @staticmethod - def _add_sync_type(entity, sync_type): - if DSProps.SYNC_TYPE not in entity: - entity[DSProps.SYNC_TYPE] = sync_type + def _add_entity_type(entity, entity_type): + if DSProps.ENTITY_TYPE not in entity: + entity[DSProps.ENTITY_TYPE] = entity_type @staticmethod def _add_sampling_time(entity): entity[DSProps.SAMPLE_DATE] = str(datetime_utils.utcnow()) @staticmethod - def _add_sync_mode(entity, sync_mode): - entity[DSProps.SYNC_MODE] = sync_mode + def _add_action_type(entity, action_type): + entity[DSProps.ACTION_TYPE] = action_type @staticmethod @abc.abstractmethod diff --git a/vitrage/datasources/heat/stack/driver.py b/vitrage/datasources/heat/stack/driver.py index 4de9d1d1b..3bb60bee9 100644 --- a/vitrage/datasources/heat/stack/driver.py +++ b/vitrage/datasources/heat/stack/driver.py @@ -12,8 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. +from vitrage.common.constants import ActionType 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 from vitrage.datasources.heat.stack import HEAT_STACK_DATASOURCE @@ -75,7 +75,7 @@ class HeatStackDriver(DriverBase): return HeatStackDriver.make_pickleable([event], HEAT_STACK_DATASOURCE, - SyncMode.UPDATE)[0] + ActionType.UPDATE)[0] def _filter_resource_types(self): types = self.conf.datasources.types @@ -102,11 +102,11 @@ class HeatStackDriver(DriverBase): HeatStackDriver.RESOURCE_TYPE_CONVERSION] return stack - def get_all(self, sync_mode): + def get_all(self, action_type): stacks = HeatStackDriver.client().stacks.list(global_tenant=True) stacks_list = self._make_stacks_list(stacks) stacks_with_resources = self._append_stacks_resources(stacks_list) return self.make_pickleable(stacks_with_resources, HEAT_STACK_DATASOURCE, - sync_mode, + action_type, 'manager') diff --git a/vitrage/datasources/nagios/driver.py b/vitrage/datasources/nagios/driver.py index a64889213..d89358625 100644 --- a/vitrage/datasources/nagios/driver.py +++ b/vitrage/datasources/nagios/driver.py @@ -25,6 +25,7 @@ from vitrage.datasources.nagios.parser import NagiosParser from vitrage.datasources.nagios.properties import NagiosProperties\ as NagiosProps from vitrage.datasources.nagios.properties import NagiosTestStatus + # noinspection PyProtectedMember from vitrage.i18n import _LE # noinspection PyProtectedMember @@ -41,7 +42,7 @@ class NagiosDriver(AlarmDriverBase): self.conf = conf self.config = NagiosConfig(conf) - def _sync_type(self): + def _entity_type(self): return NAGIOS_DATASOURCE def _alarm_key(self, alarm): @@ -83,7 +84,7 @@ class NagiosDriver(AlarmDriverBase): for alarm in alarms: # based on nagios configuration file, convert nagios host name # to vitrage resource type and name - alarm[DSProps.SYNC_TYPE] = NagiosProps.NAGIOS + alarm[DSProps.ENTITY_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 6c90a8659..2d9d1ffa9 100644 --- a/vitrage/datasources/nagios/transformer.py +++ b/vitrage/datasources/nagios/transformer.py @@ -63,7 +63,7 @@ class NagiosTransformer(AlarmTransformerBase): return graph_utils.create_vertex( self._create_entity_key(entity_event), entity_category=EntityCategory.ALARM, - entity_type=entity_event[DSProps.SYNC_TYPE], + entity_type=entity_event[DSProps.ENTITY_TYPE], entity_state=self._get_alarm_state(entity_event), sample_timestamp=sample_timestamp, update_timestamp=update_timestamp, @@ -124,10 +124,10 @@ class NagiosTransformer(AlarmTransformerBase): def _create_entity_key(self, entity_event): - sync_type = entity_event[DSProps.SYNC_TYPE] + entity_type = entity_event[DSProps.ENTITY_TYPE] alarm_name = entity_event[NagiosProperties.SERVICE] resource_name = entity_event[NagiosProperties.RESOURCE_NAME] - return tbase.build_key(self._key_values(sync_type, + return tbase.build_key(self._key_values(entity_type, resource_name, alarm_name)) diff --git a/vitrage/datasources/neutron/network/driver.py b/vitrage/datasources/neutron/network/driver.py index fe042279d..c6d8b128e 100644 --- a/vitrage/datasources/neutron/network/driver.py +++ b/vitrage/datasources/neutron/network/driver.py @@ -12,8 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. +from vitrage.common.constants import ActionType from vitrage.common.constants import DatasourceProperties as DSProps -from vitrage.common.constants import SyncMode from vitrage.datasources.neutron.base import NeutronBase from vitrage.datasources.neutron.network import NEUTRON_NETWORK_DATASOURCE @@ -33,10 +33,10 @@ class NetworkDriver(NeutronBase): return NetworkDriver.make_pickleable([event], NEUTRON_NETWORK_DATASOURCE, - SyncMode.UPDATE)[0] + ActionType.UPDATE)[0] - def get_all(self, sync_mode): + def get_all(self, action_type): return self.make_pickleable( self.client.list_networks()['networks'], NEUTRON_NETWORK_DATASOURCE, - sync_mode) + action_type) diff --git a/vitrage/datasources/neutron/port/driver.py b/vitrage/datasources/neutron/port/driver.py index b4b56492c..145b846de 100644 --- a/vitrage/datasources/neutron/port/driver.py +++ b/vitrage/datasources/neutron/port/driver.py @@ -12,8 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. +from vitrage.common.constants import ActionType from vitrage.common.constants import DatasourceProperties as DSProps -from vitrage.common.constants import SyncMode from vitrage.datasources.neutron.base import NeutronBase from vitrage.datasources.neutron.port import NEUTRON_PORT_DATASOURCE @@ -32,10 +32,10 @@ class PortDriver(NeutronBase): event[DSProps.EVENT_TYPE] = event_type return PortDriver.make_pickleable([event], NEUTRON_PORT_DATASOURCE, - SyncMode.UPDATE)[0] + ActionType.UPDATE)[0] - def get_all(self, sync_mode): + def get_all(self, action_type): return self.make_pickleable( self.client.list_ports()['ports'], NEUTRON_PORT_DATASOURCE, - sync_mode) + action_type) diff --git a/vitrage/datasources/nova/host/driver.py b/vitrage/datasources/nova/host/driver.py index b74f92dfe..479c351c4 100644 --- a/vitrage/datasources/nova/host/driver.py +++ b/vitrage/datasources/nova/host/driver.py @@ -27,9 +27,9 @@ class HostDriver(NovaDriverBase): compute_hosts.append(host_dict) return compute_hosts - def get_all(self, sync_mode): + def get_all(self, action_type): return self.make_pickleable( self.filter_none_compute_hosts(self.client.hosts.list()), NOVA_HOST_DATASOURCE, - sync_mode, + action_type, 'manager') diff --git a/vitrage/datasources/nova/instance/driver.py b/vitrage/datasources/nova/instance/driver.py index a98bacd97..cb782e789 100644 --- a/vitrage/datasources/nova/instance/driver.py +++ b/vitrage/datasources/nova/instance/driver.py @@ -12,8 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. +from vitrage.common.constants import ActionType 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 @@ -24,12 +24,12 @@ class InstanceDriver(NovaDriverBase): def extract_events(instances): return [instance.__dict__ for instance in instances] - def get_all(self, sync_mode): + def get_all(self, action_type): return self.make_pickleable( self.extract_events(self.client.servers.list( search_opts={'all_tenants': 1})), NOVA_INSTANCE_DATASOURCE, - sync_mode, + action_type, 'manager', 'OS-EXT-SRV-ATTR:user_data', '_info') @@ -40,7 +40,7 @@ class InstanceDriver(NovaDriverBase): return InstanceDriver.make_pickleable([event], NOVA_INSTANCE_DATASOURCE, - SyncMode.UPDATE)[0] + ActionType.UPDATE)[0] @staticmethod def get_event_types(): diff --git a/vitrage/datasources/nova/instance/transformer.py b/vitrage/datasources/nova/instance/transformer.py index 49b8c32fa..9b6337763 100644 --- a/vitrage/datasources/nova/instance/transformer.py +++ b/vitrage/datasources/nova/instance/transformer.py @@ -67,7 +67,7 @@ class InstanceTransformer(ResourceTransformerBase): sample_timestamp = entity_event[DSProps.SAMPLE_DATE] - # TODO(Alexey): need to check here that only the UPDATE sync_mode will + # TODO(Alexey): need to check that only the UPDATE action_type will # update the UPDATE_TIMESTAMP property update_timestamp = self._format_update_timestamp( extract_field_value(entity_event, DSProps.SAMPLE_DATE), diff --git a/vitrage/datasources/nova/zone/driver.py b/vitrage/datasources/nova/zone/driver.py index 30eea9475..b6e87d3a2 100644 --- a/vitrage/datasources/nova/zone/driver.py +++ b/vitrage/datasources/nova/zone/driver.py @@ -10,8 +10,8 @@ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations - # under the License. + from vitrage.datasources.nova.nova_driver_base import NovaDriverBase from vitrage.datasources.nova.zone import NOVA_ZONE_DATASOURCE @@ -27,9 +27,9 @@ class ZoneDriver(NovaDriverBase): zones_res.append(zone_dict) return zones_res - def get_all(self, sync_mode): + def get_all(self, action_type): return self.make_pickleable(self.filter_internal_zone( self.client.availability_zones.list()), NOVA_ZONE_DATASOURCE, - sync_mode, + action_type, 'manager') diff --git a/vitrage/datasources/services.py b/vitrage/datasources/services.py index 2da6a8649..f3036f711 100644 --- a/vitrage/datasources/services.py +++ b/vitrage/datasources/services.py @@ -14,7 +14,7 @@ from oslo_log import log from oslo_service import service as os_service -from vitrage.common.constants import SyncMode +from vitrage.common.constants import ActionType from vitrage.datasources.rescheduler import ReScheduler LOG = log.getLogger(__name__) @@ -48,7 +48,8 @@ class SnapshotsService(DatasourceService): for ds_driver in self.registered_datasources.values(): snap_scheduler.schedule( - func=self.entities_to_queue(ds_driver, SyncMode.INIT_SNAPSHOT), + func=self.entities_to_queue(ds_driver, + ActionType.INIT_SNAPSHOT), standard_interval=standard_interval, fault_interval=fault_interval, times=1, @@ -56,7 +57,7 @@ class SnapshotsService(DatasourceService): fault_callback=ds_driver.callback_on_fault) snap_scheduler.schedule( - func=self.entities_to_queue(ds_driver, SyncMode.SNAPSHOT), + func=self.entities_to_queue(ds_driver, ActionType.SNAPSHOT), initial_delay=standard_interval, standard_interval=standard_interval, fault_interval=fault_interval, @@ -66,9 +67,9 @@ class SnapshotsService(DatasourceService): LOG.info('Vitrage datasources Snapshot Service - Started!') - def entities_to_queue(self, driver, sync_mode): + def entities_to_queue(self, driver, action_type): def _entities_to_queue(): - for entity in driver.get_all(sync_mode): + for entity in driver.get_all(action_type): self.send_to_queue(entity) return _entities_to_queue @@ -115,7 +116,7 @@ class ChangesService(DatasourceService): LOG.debug("start get changes") for datasource in self.registered_datasources: try: - for entity in datasource.get_changes(SyncMode.UPDATE): + for entity in datasource.get_changes(ActionType.UPDATE): self.send_to_queue(entity) except Exception as e: LOG.error("Get changes Failed - %s", e.message) diff --git a/vitrage/datasources/static/driver.py b/vitrage/datasources/static/driver.py index c92c1c208..2ff160bfe 100644 --- a/vitrage/datasources/static/driver.py +++ b/vitrage/datasources/static/driver.py @@ -31,16 +31,16 @@ class StaticDriver(DriverBase): def enrich_event(event, event_type): pass - def get_all(self, sync_mode): + def get_all(self, action_type): """Query all entities and send events to the vitrage events queue""" return self.make_pickleable(self._get_all_entities(), STATIC_DATASOURCE, - sync_mode) + action_type) - def get_changes(self, sync_mode): + def get_changes(self, action_type): return self.make_pickleable(self._get_changes_entities(), STATIC_DATASOURCE, - sync_mode) + action_type) def _get_all_entities(self): """Internal method to get all entities""" diff --git a/vitrage/datasources/static/transformer.py b/vitrage/datasources/static/transformer.py index e6a216fa1..682048e04 100644 --- a/vitrage/datasources/static/transformer.py +++ b/vitrage/datasources/static/transformer.py @@ -46,15 +46,15 @@ class StaticTransformer(ResourceTransformerBase): def _create_entity_key(self, entity_event): entity_id = entity_event[VProps.ID] - sync_type = entity_event[VProps.TYPE] - key_fields = self._key_values(sync_type, entity_id) + entity_type = entity_event[VProps.TYPE] + key_fields = self._key_values(entity_type, entity_id) return transformer_base.build_key(key_fields) def get_type(self): return STATIC_DATASOURCE def _create_vertex(self, entity_event): - sync_type = entity_event[VProps.TYPE] + entity_type = entity_event[VProps.TYPE] entity_id = entity_event[VProps.ID] sample_timestamp = entity_event[DSProps.SAMPLE_DATE] update_timestamp = self._format_update_timestamp( @@ -67,7 +67,7 @@ class StaticTransformer(ResourceTransformerBase): entity_key, entity_id=entity_id, entity_category=EntityCategory.RESOURCE, - entity_type=sync_type, + entity_type=entity_type, sample_timestamp=sample_timestamp, update_timestamp=update_timestamp, entity_state=state) diff --git a/vitrage/datasources/static_physical/driver.py b/vitrage/datasources/static_physical/driver.py index 0c5b94388..e77f74b39 100644 --- a/vitrage/datasources/static_physical/driver.py +++ b/vitrage/datasources/static_physical/driver.py @@ -38,15 +38,15 @@ class StaticPhysicalDriver(DriverBase): self.cfg = conf self.cache = {} - def get_all(self, sync_mode): + def get_all(self, action_type): return self.make_pickleable(self._get_all_entities(), STATIC_PHYSICAL_DATASOURCE, - sync_mode) + action_type) - def get_changes(self, sync_mode): + def get_changes(self, action_type): return self.make_pickleable(self._get_changes_entities(), STATIC_PHYSICAL_DATASOURCE, - sync_mode) + action_type) def _get_all_entities(self): static_entities = [] diff --git a/vitrage/datasources/static_physical/transformer.py b/vitrage/datasources/static_physical/transformer.py index fe6da834e..e48819100 100644 --- a/vitrage/datasources/static_physical/transformer.py +++ b/vitrage/datasources/static_physical/transformer.py @@ -52,7 +52,7 @@ class StaticPhysicalTransformer(ResourceTransformerBase): def _create_vertex(self, entity_event): - sync_type = entity_event[VProps.TYPE] + entity_type = entity_event[VProps.TYPE] entity_id = entity_event[VProps.ID] sample_timestamp = entity_event[DSProps.SAMPLE_DATE] update_timestamp = self._format_update_timestamp( @@ -66,7 +66,7 @@ class StaticPhysicalTransformer(ResourceTransformerBase): entity_key, entity_id=entity_id, entity_category=EntityCategory.RESOURCE, - entity_type=sync_type, + entity_type=entity_type, sample_timestamp=sample_timestamp, update_timestamp=update_timestamp, entity_state=state, @@ -126,8 +126,8 @@ class StaticPhysicalTransformer(ResourceTransformerBase): def _create_entity_key(self, entity_event): entity_id = entity_event[VProps.ID] - sync_type = entity_event[VProps.TYPE] - key_fields = self._key_values(sync_type, entity_id) + entity_type = entity_event[VProps.TYPE] + key_fields = self._key_values(entity_type, entity_id) return transformer_base.build_key(key_fields) @staticmethod diff --git a/vitrage/datasources/transformer_base.py b/vitrage/datasources/transformer_base.py index e7f9e6e2d..8741f08e8 100644 --- a/vitrage/datasources/transformer_base.py +++ b/vitrage/datasources/transformer_base.py @@ -21,9 +21,9 @@ import six from vitrage.common import datetime_utils import vitrage.common.constants as cons +from vitrage.common.constants import ActionType from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EventAction -from vitrage.common.constants import SyncMode from vitrage.common.constants import UpdateMethod from vitrage.common.exception import VitrageTransformerError from vitrage.common import utils @@ -87,7 +87,7 @@ def convert_timestamp_format(current_timestamp_format, timestamp): def is_update_event(event): - return event[DSProps.SYNC_MODE] == SyncMode.UPDATE + return event[DSProps.ACTION_TYPE] == ActionType.UPDATE @six.add_metaclass(abc.ABCMeta) @@ -212,21 +212,21 @@ class TransformerBase(object): :rtype: str """ - sync_mode = entity_event[DSProps.SYNC_MODE] + action_type = entity_event[DSProps.ACTION_TYPE] - if SyncMode.UPDATE == sync_mode: + if ActionType.UPDATE == action_type: return self.UPDATE_EVENT_TYPES.get( entity_event.get(DSProps.EVENT_TYPE, None), EventAction.UPDATE_ENTITY) - if SyncMode.SNAPSHOT == sync_mode: + if ActionType.SNAPSHOT == action_type: return EventAction.UPDATE_ENTITY - if SyncMode.INIT_SNAPSHOT == sync_mode: + if ActionType.INIT_SNAPSHOT == action_type: return EventAction.CREATE_ENTITY raise VitrageTransformerError( - 'Invalid sync mode: (%s)' % sync_mode) + 'Invalid action type: (%s)' % action_type) def _key_values(self, *args): """A list of key fields @@ -240,16 +240,16 @@ class TransformerBase(object): @staticmethod def _create_end_vertex(entity_event): - sync_type = entity_event[DSProps.SYNC_TYPE] + entity_type = entity_event[DSProps.ENTITY_TYPE] return graph_utils.create_vertex( - 'END_MESSAGE:' + sync_type, - entity_type=sync_type) + 'END_MESSAGE:' + entity_type, + entity_type=entity_type) @staticmethod def _is_end_message(entity_event): - sync_mode = entity_event[DSProps.SYNC_MODE] - is_snapshot_event = sync_mode == SyncMode.INIT_SNAPSHOT + action_type = entity_event[DSProps.ACTION_TYPE] + is_snapshot_event = action_type == ActionType.INIT_SNAPSHOT event_type = entity_event.get(DSProps.EVENT_TYPE, None) return is_snapshot_event and event_type == EventAction.END_MESSAGE diff --git a/vitrage/datasources/zabbix/driver.py b/vitrage/datasources/zabbix/driver.py index 44291f636..73d05254e 100644 --- a/vitrage/datasources/zabbix/driver.py +++ b/vitrage/datasources/zabbix/driver.py @@ -17,8 +17,8 @@ from collections import namedtuple from oslo_log import log from oslo_utils import importutils as utils +from vitrage.common.constants import ActionType from vitrage.common.constants import DatasourceProperties as DSProps -from vitrage.common.constants import SyncMode from vitrage.common import file_utils from vitrage.datasources.alarm_driver_base import AlarmDriverBase from vitrage.datasources.zabbix.properties import ZabbixProperties as ZProps @@ -63,7 +63,7 @@ class ZabbixDriver(AlarmDriverBase): LOG.exception('pyzabbix.ZabbixAPI %s', e) self._client = None - def _sync_type(self): + def _entity_type(self): return ZABBIX_DATASOURCE def _alarm_key(self, alarm): @@ -183,7 +183,7 @@ class ZabbixDriver(AlarmDriverBase): event[ZProps.RESOURCE_TYPE] = v_resource[ZProps.RESOURCE_TYPE] return ZabbixDriver.make_pickleable([event], ZABBIX_DATASOURCE, - SyncMode.UPDATE)[0] + ActionType.UPDATE)[0] @staticmethod def get_event_types(): diff --git a/vitrage/datasources/zabbix/transformer.py b/vitrage/datasources/zabbix/transformer.py index 456da7f3e..1701aaaa5 100644 --- a/vitrage/datasources/zabbix/transformer.py +++ b/vitrage/datasources/zabbix/transformer.py @@ -78,7 +78,7 @@ class ZabbixTransformer(AlarmTransformerBase): return graph_utils.create_vertex( self._create_entity_key(entity_event), entity_category=EntityCategory.ALARM, - entity_type=entity_event[DSProps.SYNC_TYPE], + entity_type=entity_event[DSProps.ENTITY_TYPE], entity_state=entity_state, sample_timestamp=sample_timestamp, update_timestamp=update_timestamp, @@ -138,10 +138,10 @@ class ZabbixTransformer(AlarmTransformerBase): def _create_entity_key(self, entity_event): - sync_type = entity_event[DSProps.SYNC_TYPE] + entity_type = entity_event[DSProps.ENTITY_TYPE] alarm_id = entity_event[ZProps.TRIGGER_ID] resource_name = entity_event[ZProps.RESOURCE_NAME] - return tbase.build_key(self._key_values(sync_type, + return tbase.build_key(self._key_values(entity_type, resource_name, alarm_id)) diff --git a/vitrage/entity_graph/consistency/consistency_enforcer.py b/vitrage/entity_graph/consistency/consistency_enforcer.py index 64e6dff05..3ff399a0a 100644 --- a/vitrage/entity_graph/consistency/consistency_enforcer.py +++ b/vitrage/entity_graph/consistency/consistency_enforcer.py @@ -17,10 +17,10 @@ import time from oslo_log import log +from vitrage.common.constants import ActionType 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 SyncMode from vitrage.common.constants import VertexProperties as VProps from vitrage.common.datetime_utils import utcnow from vitrage.datasources.consistency import CONSISTENCY_DATASOURCE @@ -152,8 +152,8 @@ class ConsistencyEnforcer(object): def _push_events_to_queue(self, vertices, action): for vertex in vertices: event = { - DSProps.SYNC_TYPE: CONSISTENCY_DATASOURCE, - DSProps.SYNC_MODE: SyncMode.UPDATE, + DSProps.ENTITY_TYPE: CONSISTENCY_DATASOURCE, + DSProps.ACTION_TYPE: ActionType.UPDATE, DSProps.SAMPLE_DATE: str(utcnow()), DSProps.EVENT_TYPE: action, VProps.VITRAGE_ID: vertex[VProps.VITRAGE_ID] diff --git a/vitrage/entity_graph/transformer_manager.py b/vitrage/entity_graph/transformer_manager.py index cb2b19003..a7add061b 100644 --- a/vitrage/entity_graph/transformer_manager.py +++ b/vitrage/entity_graph/transformer_manager.py @@ -67,21 +67,21 @@ class TransformerManager(object): return transformer def transform(self, entity_event): - sync_type = self.get_sync_type(entity_event) - return self.get_transformer(sync_type).transform(entity_event) + entity_type = self.get_entity_type(entity_event) + return self.get_transformer(entity_type).transform(entity_event) def get_enrich_query(self, entity_event): - sync_type = self.get_sync_type(entity_event) - return self.get_transformer(sync_type).get_enrich_query(entity_event) + entity_type = self.get_entity_type(entity_event) + return self.get_transformer(entity_type).get_enrich_query(entity_event) def extract_key(self, entity_event): - sync_type = self.get_sync_type(entity_event) - return self.get_transformer(sync_type)._create_entity_key() + entity_type = self.get_entity_type(entity_event) + return self.get_transformer(entity_type)._create_entity_key() @staticmethod - def get_sync_type(entity_event): + def get_entity_type(entity_event): try: - return entity_event[DSProps.SYNC_TYPE] + return entity_event[DSProps.ENTITY_TYPE] except KeyError: raise VitrageTransformerError( - 'Entity Event must contains sync_type field.') + 'Entity Event must contains entity_type field.') diff --git a/vitrage/evaluator/actions/action_executor.py b/vitrage/evaluator/actions/action_executor.py index 60285b00e..b2ac9184b 100644 --- a/vitrage/evaluator/actions/action_executor.py +++ b/vitrage/evaluator/actions/action_executor.py @@ -16,8 +16,8 @@ import copy from oslo_utils import importutils +from vitrage.common.constants import ActionType as AType 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 from vitrage.evaluator.actions.base import ActionMode @@ -103,8 +103,8 @@ class ActionExecutor(object): @staticmethod def _add_default_properties(event): - event[DSProps.SYNC_MODE] = SyncMode.UPDATE - event[DSProps.SYNC_TYPE] = VITRAGE_TYPE + event[DSProps.ACTION_TYPE] = AType.UPDATE + event[DSProps.ENTITY_TYPE] = VITRAGE_TYPE event[VProps.UPDATE_TIMESTAMP] = str(datetime_utils.utcnow(False)) event[VProps.SAMPLE_TIMESTAMP] = str(datetime_utils.utcnow()) diff --git a/vitrage/tests/functional/base.py b/vitrage/tests/functional/base.py index 1500e1616..4fb345b17 100644 --- a/vitrage/tests/functional/base.py +++ b/vitrage/tests/functional/base.py @@ -12,8 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. +from vitrage.common.constants import ActionType 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 from vitrage.tests.mocks import mock_driver @@ -38,15 +38,15 @@ class TestFunctionalBase(TestEntityGraphUnitBase): self.NUM_ZONES, self.NUM_HOSTS, snapshot_events=self.NUM_ZONES, - snap_vals={DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT}) + snap_vals={DSProps.ACTION_TYPE: ActionType.INIT_SNAPSHOT}) gen_list += mock_driver.simple_host_generators( self.NUM_ZONES, self.NUM_HOSTS, self.NUM_HOSTS, - snap_vals={DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT}) + snap_vals={DSProps.ACTION_TYPE: ActionType.INIT_SNAPSHOT}) gen_list += mock_driver.simple_instance_generators( self.NUM_HOSTS, self.NUM_INSTANCES, self.NUM_INSTANCES, - snap_vals={DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT}) + snap_vals={DSProps.ACTION_TYPE: ActionType.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 d07a91bd7..13970361e 100644 --- a/vitrage/tests/functional/datasources/static_physical/test_static_physical.py +++ b/vitrage/tests/functional/datasources/static_physical/test_static_physical.py @@ -67,7 +67,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[DSProps.SYNC_TYPE] = SWITCH + static_physical_event[DSProps.ENTITY_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/functional/entity_graph/states/test_datasource_info_mapper.py b/vitrage/tests/functional/entity_graph/states/test_datasource_info_mapper.py index 29b4a82f8..49daa2a9f 100644 --- a/vitrage/tests/functional/entity_graph/states/test_datasource_info_mapper.py +++ b/vitrage/tests/functional/entity_graph/states/test_datasource_info_mapper.py @@ -14,8 +14,8 @@ from oslo_config import cfg +from vitrage.common.constants import ActionType from vitrage.common.constants import EventAction -from vitrage.common.constants import SyncMode from vitrage.common.constants import VertexProperties as VProps from vitrage.datasources.nova.instance.transformer import InstanceTransformer from vitrage.entity_graph.initialization_status import InitializationStatus @@ -40,7 +40,7 @@ class TestDatasourceInfoMapperFunctional(TestFunctionalBase): # setup processor = proc.Processor(self.conf, InitializationStatus()) event = self._create_event(spec_type='INSTANCE_SPEC', - sync_mode=SyncMode.INIT_SNAPSHOT) + action_type=ActionType.INIT_SNAPSHOT) # action processor.process_event(event) @@ -57,7 +57,7 @@ class TestDatasourceInfoMapperFunctional(TestFunctionalBase): # setup vertex, neighbors, processor = self._create_entity( spec_type='INSTANCE_SPEC', - sync_mode=SyncMode.INIT_SNAPSHOT) + action_type=ActionType.INIT_SNAPSHOT) self.assertEqual(2, processor.entity_graph.num_vertices()) neighbors[0].vertex[VProps.STATE] = 'available' diff --git a/vitrage/tests/functional/evaluator/test_action_executor.py b/vitrage/tests/functional/evaluator/test_action_executor.py index 6e935b5f8..9b4d0449c 100644 --- a/vitrage/tests/functional/evaluator/test_action_executor.py +++ b/vitrage/tests/functional/evaluator/test_action_executor.py @@ -259,8 +259,8 @@ class TestActionExecutor(TestFunctionalBase): 'service': 'Check_MK', 'status': 'CRITICAL', 'status_info': 'test test test', - 'vitrage_sync_mode': 'snapshot', - 'vitrage_sync_type': 'nagios', + 'vitrage_action_type': 'snapshot', + 'vitrage_entity_type': 'nagios', 'vitrage_sample_date': '2016-02-07 15:26:04'} @staticmethod @@ -268,10 +268,10 @@ class TestActionExecutor(TestFunctionalBase): return {'target': target_vertex.vertex_id, 'update_timestamp': '2016-03-17 11:33:32.443002', - 'vitrage_sync_mode': 'update', + 'vitrage_action_type': 'update', 'alarm_name': alarm_name, 'state': 'Active', 'type': 'add_vertex', - 'vitrage_sync_type': 'vitrage', + 'vitrage_entity_type': 'vitrage', 'severity': 'CRITICAL', 'sample_timestamp': '2016-03-17 11:33:32.443002+00:00'} diff --git a/vitrage/tests/functional/evaluator/test_scenario_evaluator.py b/vitrage/tests/functional/evaluator/test_scenario_evaluator.py index 15343d3e6..cb074c870 100644 --- a/vitrage/tests/functional/evaluator/test_scenario_evaluator.py +++ b/vitrage/tests/functional/evaluator/test_scenario_evaluator.py @@ -29,7 +29,7 @@ from vitrage.tests.mocks import utils LOG = logging.getLogger(__name__) _TARGET_HOST = 'host-2' -_NAGIOS_TEST_INFO = {'resource_name': _TARGET_HOST, 'sync_mode': 'snapshot'} +_NAGIOS_TEST_INFO = {'resource_name': _TARGET_HOST, 'action_type': 'snapshot'} class TestScenarioEvaluator(TestFunctionalBase): diff --git a/vitrage/tests/mocks/mock_driver.py b/vitrage/tests/mocks/mock_driver.py index a4d81bfd4..d9b4dd1e8 100644 --- a/vitrage/tests/mocks/mock_driver.py +++ b/vitrage/tests/mocks/mock_driver.py @@ -350,7 +350,7 @@ def simple_switch_generators(switch_num, host_num, ) if update_events: update_vals = {} if not update_vals else update_vals - update_vals['sync_mode'] = 'update' + update_vals['action_type'] = 'update' test_entity_spec_list.append( {tg.DYNAMIC_INFO_FKEY: tg.DRIVER_SWITCH_SNAPSHOT_D, tg.STATIC_INFO_FKEY: None, diff --git a/vitrage/tests/resources/mock_configurations/driver/driver_consistency_update_dynamic.json b/vitrage/tests/resources/mock_configurations/driver/driver_consistency_update_dynamic.json index 391704eae..ddfe521dc 100644 --- a/vitrage/tests/resources/mock_configurations/driver/driver_consistency_update_dynamic.json +++ b/vitrage/tests/resources/mock_configurations/driver/driver_consistency_update_dynamic.json @@ -1,7 +1,7 @@ { "vitrage_sample_date": "2015-12-01T12:46:41Z", - "vitrage_sync_type": "consistency", - "vitrage_sync_mode": "update", + "vitrage_entity_type": "consistency", + "vitrage_action_type": "update", "vitrage_event_type": "delete_entity", "vitrage_id": "[0-9]{5}" } diff --git a/vitrage/tests/resources/mock_configurations/driver/driver_host_snapshot_dynamic.json b/vitrage/tests/resources/mock_configurations/driver/driver_host_snapshot_dynamic.json index 5e46b3719..bc2a0f086 100644 --- a/vitrage/tests/resources/mock_configurations/driver/driver_host_snapshot_dynamic.json +++ b/vitrage/tests/resources/mock_configurations/driver/driver_host_snapshot_dynamic.json @@ -7,8 +7,8 @@ "_loaded": "True", "host_name": "compute-0-0.local", "service": "compute", - "vitrage_sync_type": "nova.host", + "vitrage_entity_type": "nova.host", "zone": "zone0", - "vitrage_sync_mode": "init_snapshot", + "vitrage_action_type": "init_snapshot", "vitrage_sample_date": "2015-12-01T12:46:41Z" } diff --git a/vitrage/tests/resources/mock_configurations/driver/driver_inst_snapshot_dynamic.json b/vitrage/tests/resources/mock_configurations/driver/driver_inst_snapshot_dynamic.json index 889781e3e..8d0da8c75 100644 --- a/vitrage/tests/resources/mock_configurations/driver/driver_inst_snapshot_dynamic.json +++ b/vitrage/tests/resources/mock_configurations/driver/driver_inst_snapshot_dynamic.json @@ -1,7 +1,7 @@ { "OS-EXT-STS:task_state": null, - "vitrage_sync_mode": "snapshot", - "vitrage_sync_type": "nova.instance", + "vitrage_action_type": "snapshot", + "vitrage_entity_type": "nova.instance", "vitrage_sample_date": "2015-12-01T12:46:41Z", "addresses": { "public": [ diff --git a/vitrage/tests/resources/mock_configurations/driver/driver_inst_update_dynamic.json b/vitrage/tests/resources/mock_configurations/driver/driver_inst_update_dynamic.json index 7eb3fc5f8..73f5bec4c 100644 --- a/vitrage/tests/resources/mock_configurations/driver/driver_inst_update_dynamic.json +++ b/vitrage/tests/resources/mock_configurations/driver/driver_inst_update_dynamic.json @@ -1,5 +1,5 @@ { - "vitrage_sync_mode": "update", + "vitrage_action_type": "update", "vitrage_sample_date": "2015-12-01T12:46:41Z", "publisher_id": "compute.emalin-devstack", "vitrage_event_type": "compute.instance.pause.end|compute.instance.delete.end|compute.instance.create.start", diff --git a/vitrage/tests/resources/mock_configurations/driver/driver_nagios_snapshot_dynamic.json b/vitrage/tests/resources/mock_configurations/driver/driver_nagios_snapshot_dynamic.json index 97e747460..5a9e28f7c 100644 --- a/vitrage/tests/resources/mock_configurations/driver/driver_nagios_snapshot_dynamic.json +++ b/vitrage/tests/resources/mock_configurations/driver/driver_nagios_snapshot_dynamic.json @@ -1,5 +1,5 @@ { - "vitrage_sync_type": "nagios", + "vitrage_entity_type": "nagios", "resource_type": "nova.host", "resource_name": "compute-[1-9]", "service": "CPU utilization", @@ -9,5 +9,5 @@ "vitrage_sample_date": "2015-12-01T12:46:41Z", "attempt": "1/1", "status_info": "OK - user: 0\\.6%, system: 0\\.3%, wait: 0\\.4%", - "vitrage_sync_mode": "snapshot" + "vitrage_action_type": "snapshot" } diff --git a/vitrage/tests/resources/mock_configurations/driver/driver_stack_snapshot_dynamic.json b/vitrage/tests/resources/mock_configurations/driver/driver_stack_snapshot_dynamic.json index 4968aab8c..8f8383219 100644 --- a/vitrage/tests/resources/mock_configurations/driver/driver_stack_snapshot_dynamic.json +++ b/vitrage/tests/resources/mock_configurations/driver/driver_stack_snapshot_dynamic.json @@ -4,11 +4,11 @@ "creation_time": "2016-08-25T13:03:36", "stack_owner": "admin", "project": "a077142e250543be90f6fce8f623d45d", - "vitrage_sync_mode": "init_snapshot", + "vitrage_action_type": "init_snapshot", "id": "f22416fb-b33c-4e24-822e-0174421f5ece", "stack_status": "CREATE_COMPLETE", "vitrage_sample_date": "2016-08-2515:12:28.281460+00:00", - "vitrage_sync_type": "heat.stack", + "vitrage_entity_type": "heat.stack", "resources": [{ "resource_name": "cinder_volume_1", "logical_resource_id": "cinder_volume_1", diff --git a/vitrage/tests/resources/mock_configurations/driver/driver_stack_update_dynamic.json b/vitrage/tests/resources/mock_configurations/driver/driver_stack_update_dynamic.json index 9640c0beb..63f932577 100644 --- a/vitrage/tests/resources/mock_configurations/driver/driver_stack_update_dynamic.json +++ b/vitrage/tests/resources/mock_configurations/driver/driver_stack_update_dynamic.json @@ -4,12 +4,12 @@ "stack_name": "newstack", "tenant_id": "a077142e250543be90f6fce8f623d45d", "stack_identity": "d2df0a2a-765c-44ef-b117-32d599bc9c3b", - "vitrage_sync_mode": "update", + "vitrage_action_type": "update", "create_at": "2016-08-25T15:23:02", "state": "CREATE_COMPLETE", "vitrage_event_type": "orchestration.stack.create.end", "vitrage_sample_date": "2016-08-2515:23:23.150274+00:00", - "vitrage_sync_type": "heat.stack", + "vitrage_entity_type": "heat.stack", "user_identity": "3515b9535e5d4c9e82cb166324ca29dd", "resources": [{ "resource_name": "cinder_volume_1", diff --git a/vitrage/tests/resources/mock_configurations/driver/driver_switch_snapshot_dynamic.json b/vitrage/tests/resources/mock_configurations/driver/driver_switch_snapshot_dynamic.json index 5118c38c9..f254ada39 100644 --- a/vitrage/tests/resources/mock_configurations/driver/driver_switch_snapshot_dynamic.json +++ b/vitrage/tests/resources/mock_configurations/driver/driver_switch_snapshot_dynamic.json @@ -10,7 +10,7 @@ "id": "[1-9]{5}", "vitrage_sample_date": "2015-12-01T12:46:41Z", "type": "switch", - "vitrage_sync_mode": "snapshot", + "vitrage_action_type": "snapshot", "state": "available", "vitrage_event_type": "entity_update" } diff --git a/vitrage/tests/resources/mock_configurations/driver/driver_volume_snapshot_dynamic.json b/vitrage/tests/resources/mock_configurations/driver/driver_volume_snapshot_dynamic.json index 130affac0..4b6dfd55a 100644 --- a/vitrage/tests/resources/mock_configurations/driver/driver_volume_snapshot_dynamic.json +++ b/vitrage/tests/resources/mock_configurations/driver/driver_volume_snapshot_dynamic.json @@ -4,8 +4,8 @@ "created_at": "2015-12-01T12:46:41Z", "status": "In-use", "id": "12345", - "vitrage_sync_type": "cinder.volume", - "vitrage_sync_mode": "snapshot", + "vitrage_entity_type": "cinder.volume", + "vitrage_action_type": "snapshot", "vitrage_sample_date": "2015-12-01T12:46:41Z", "volume_type": "lvmdriver-1", "size": "1559" diff --git a/vitrage/tests/resources/mock_configurations/driver/driver_volume_update_dynamic.json b/vitrage/tests/resources/mock_configurations/driver/driver_volume_update_dynamic.json index 6a0828bdb..52a7d973c 100644 --- a/vitrage/tests/resources/mock_configurations/driver/driver_volume_update_dynamic.json +++ b/vitrage/tests/resources/mock_configurations/driver/driver_volume_update_dynamic.json @@ -4,8 +4,8 @@ "updated_at": "2015-12-01T12:46:41Z", "status": "In-use", "volume_id": "12345", - "vitrage_sync_type": "cinder.volume", - "vitrage_sync_mode": "update", + "vitrage_entity_type": "cinder.volume", + "vitrage_action_type": "update", "vitrage_event_type": "volume.create.start", "vitrage_sample_date": "2015-12-01T12:46:41Z", "volume_type": "SCSIID", diff --git a/vitrage/tests/resources/mock_configurations/driver/driver_zabbix_snapshot_dynamic.json b/vitrage/tests/resources/mock_configurations/driver/driver_zabbix_snapshot_dynamic.json index 99d1d38db..b38db2b10 100644 --- a/vitrage/tests/resources/mock_configurations/driver/driver_zabbix_snapshot_dynamic.json +++ b/vitrage/tests/resources/mock_configurations/driver/driver_zabbix_snapshot_dynamic.json @@ -1,5 +1,5 @@ { - "vitrage_sync_type": "zabbix", + "vitrage_entity_type": "zabbix", "resource_type": "nova.host", "resource_name": "compute-[1-9]", "zabbix_resource_name": "computer-[1-9]", @@ -12,6 +12,6 @@ "vitrage_sample_date": "2015-12-01T12:46:41Z", "value": "1", "priority": "1", - "vitrage_sync_mode": "snapshot", + "vitrage_action_type": "snapshot", "rawtext": "CPU utilization" } diff --git a/vitrage/tests/resources/mock_configurations/driver/driver_zone_snapshot_dynamic.json b/vitrage/tests/resources/mock_configurations/driver/driver_zone_snapshot_dynamic.json index 67bf8175a..a819b273b 100644 --- a/vitrage/tests/resources/mock_configurations/driver/driver_zone_snapshot_dynamic.json +++ b/vitrage/tests/resources/mock_configurations/driver/driver_zone_snapshot_dynamic.json @@ -9,8 +9,8 @@ "_loaded": "True", "hosts": {}, "vitrage_sample_date": "2015-12-01T12:46:41Z", - "vitrage_sync_type": "nova.zone", - "vitrage_sync_mode": "snapshot", + "vitrage_entity_type": "nova.zone", + "vitrage_action_type": "snapshot", "zoneName": "zone0", "zoneState": { "available": "True" diff --git a/vitrage/tests/resources/mock_configurations/transformer/transformer_host_snapshot_static.json b/vitrage/tests/resources/mock_configurations/transformer/transformer_host_snapshot_static.json index e5df12754..f76833df5 100644 --- a/vitrage/tests/resources/mock_configurations/transformer/transformer_host_snapshot_static.json +++ b/vitrage/tests/resources/mock_configurations/transformer/transformer_host_snapshot_static.json @@ -1,5 +1,5 @@ { - "vitrage_sync_mode": "init_snapshot", + "vitrage_action_type": "init_snapshot", "id": "host[0-3]", "name": "host[0-3]", "zone_id": "zone[0-1]", diff --git a/vitrage/tests/resources/mock_configurations/transformer/transformer_inst_snapshot_dynamic.json b/vitrage/tests/resources/mock_configurations/transformer/transformer_inst_snapshot_dynamic.json index 94708dffa..6119c9cfa 100644 --- a/vitrage/tests/resources/mock_configurations/transformer/transformer_inst_snapshot_dynamic.json +++ b/vitrage/tests/resources/mock_configurations/transformer/transformer_inst_snapshot_dynamic.json @@ -1,5 +1,5 @@ { - "vitrage_sync_mode": "init_snapshot", + "vitrage_action_type": "init_snapshot", "image": "cirros-[a-z]+", "status": "ACTIVE", "tenant_id": "[0-9a-f]{32}", @@ -9,7 +9,7 @@ "id": "vm[0-1][0-9]", "name": "vm[0-9]{3}", "vitrage_event_type": "update", - "vitrage_sync_type": "nova.instance", + "vitrage_entity_type": "nova.instance", "vitrage_sample_date": "2015-12-01T12:46:41Z" } diff --git a/vitrage/tests/resources/mock_configurations/transformer/transformer_zone_snapshot_static.json b/vitrage/tests/resources/mock_configurations/transformer/transformer_zone_snapshot_static.json index d4c18b646..aa8043e93 100644 --- a/vitrage/tests/resources/mock_configurations/transformer/transformer_zone_snapshot_static.json +++ b/vitrage/tests/resources/mock_configurations/transformer/transformer_zone_snapshot_static.json @@ -1,5 +1,5 @@ { - "vitrage_sync_mode": "init_snapshot", + "vitrage_action_type": "init_snapshot", "id": "zone[0-1]", "name": "zone[0-1]", "vitrage_event_type": "update", 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 2023f7c38..fcd2b91b3 100644 --- a/vitrage/tests/unit/datasources/cinder/test_cinder_volume_transformer.py +++ b/vitrage/tests/unit/datasources/cinder/test_cinder_volume_transformer.py @@ -162,7 +162,7 @@ class TestCinderVolumeTransformer(base.BaseTest): is_update_event = tbase.is_update_event(event) self.assertEqual(EntityCategory.RESOURCE, vertex[VProps.CATEGORY]) - self.assertEqual(event[DSProps.SYNC_TYPE], vertex[VProps.TYPE]) + self.assertEqual(event[DSProps.ENTITY_TYPE], vertex[VProps.TYPE]) id_field_path = 'volume_id' if is_update_event else 'id' self.assertEqual( diff --git a/vitrage/tests/unit/datasources/heat/test_heat_stack_transformer.py b/vitrage/tests/unit/datasources/heat/test_heat_stack_transformer.py index 177aea5d4..f94e909f4 100644 --- a/vitrage/tests/unit/datasources/heat/test_heat_stack_transformer.py +++ b/vitrage/tests/unit/datasources/heat/test_heat_stack_transformer.py @@ -163,7 +163,7 @@ class TestHeatStackTransformer(base.BaseTest): is_update_event = tbase.is_update_event(event) self.assertEqual(EntityCategory.RESOURCE, vertex[VProps.CATEGORY]) - self.assertEqual(event[DSProps.SYNC_TYPE], vertex[VProps.TYPE]) + self.assertEqual(event[DSProps.ENTITY_TYPE], vertex[VProps.TYPE]) id_field_path = 'stack_identity' if is_update_event else 'id' self.assertEqual( diff --git a/vitrage/tests/unit/datasources/nagios/test_nagios_transformer.py b/vitrage/tests/unit/datasources/nagios/test_nagios_transformer.py index 71d15654a..444407ebf 100644 --- a/vitrage/tests/unit/datasources/nagios/test_nagios_transformer.py +++ b/vitrage/tests/unit/datasources/nagios/test_nagios_transformer.py @@ -15,11 +15,11 @@ from oslo_config import cfg from oslo_log import log as logging +from vitrage.common.constants import ActionType from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EdgeLabel from vitrage.common.constants import EntityCategory from vitrage.common.constants import EventAction -from vitrage.common.constants import SyncMode from vitrage.common.constants import UpdateMethod from vitrage.common.constants import VertexProperties as VProps from vitrage.datasources.alarm_properties import AlarmProperties as AlarmProps @@ -72,7 +72,7 @@ class NagiosTransformerTest(base.BaseTest): TransformerBase.KEY_SEPARATOR) self.assertEqual(EntityCategory.ALARM, observed_key_fields[0]) - self.assertEqual(event[DSProps.SYNC_TYPE], observed_key_fields[1]) + self.assertEqual(event[DSProps.ENTITY_TYPE], observed_key_fields[1]) self.assertEqual(event[NagiosProperties.RESOURCE_NAME], observed_key_fields[2]) self.assertEqual(event[NagiosProperties.SERVICE], @@ -103,8 +103,8 @@ class NagiosTransformerTest(base.BaseTest): self._validate_action(alarm, wrapper) def _validate_action(self, alarm, wrapper): - sync_mode = alarm[DSProps.SYNC_MODE] - if sync_mode in (SyncMode.SNAPSHOT, SyncMode.UPDATE): + action_type = alarm[DSProps.ACTION_TYPE] + if action_type in (ActionType.SNAPSHOT, ActionType.UPDATE): if alarm[NagiosProperties.STATUS] == 'OK': self.assertEqual(EventAction.DELETE_ENTITY, wrapper.action) else: @@ -115,7 +115,7 @@ class NagiosTransformerTest(base.BaseTest): def _validate_vertex(self, vertex, event): self.assertEqual(EntityCategory.ALARM, vertex[VProps.CATEGORY]) - self.assertEqual(event[DSProps.SYNC_TYPE], vertex[VProps.TYPE]) + self.assertEqual(event[DSProps.ENTITY_TYPE], vertex[VProps.TYPE]) self.assertEqual(event[NagiosProperties.SERVICE], vertex[VProps.NAME]) event_type = event.get(DSProps.EVENT_TYPE, None) 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 f0c7c162c..39c7996f6 100644 --- a/vitrage/tests/unit/datasources/nova/test_nova_host_transformer.py +++ b/vitrage/tests/unit/datasources/nova/test_nova_host_transformer.py @@ -17,11 +17,11 @@ import datetime from oslo_config import cfg from oslo_log import log as logging +from vitrage.common.constants import ActionType from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EdgeLabel from vitrage.common.constants import EntityCategory from vitrage.common.constants import EventAction -from vitrage.common.constants import SyncMode from vitrage.common.constants import UpdateMethod from vitrage.common.constants import VertexProperties from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE @@ -133,7 +133,7 @@ class NovaHostTransformerTest(base.BaseTest): self.assertEqual(1, len(neighbors)) self._validate_zone_neighbor(neighbors[0], event) - if SyncMode.SNAPSHOT == event[DSProps.SYNC_MODE]: + if ActionType.SNAPSHOT == event[DSProps.ACTION_TYPE]: self.assertEqual(EventAction.UPDATE_ENTITY, wrapper.action) else: self.assertEqual(EventAction.CREATE_ENTITY, wrapper.action) @@ -200,7 +200,7 @@ class NovaHostTransformerTest(base.BaseTest): zone_num=1, host_num=1, snapshot_events=1, - snap_vals={DSProps.SYNC_MODE: SyncMode.SNAPSHOT}) + snap_vals={DSProps.ACTION_TYPE: ActionType.SNAPSHOT}) hosts_events = mock_sync.generate_random_events_list(spec_list) host_transformer = self.transformers[NOVA_HOST_DATASOURCE] @@ -216,7 +216,7 @@ class NovaHostTransformerTest(base.BaseTest): zone_num=1, host_num=1, snapshot_events=1, - snap_vals={DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT}) + snap_vals={DSProps.ACTION_TYPE: ActionType.INIT_SNAPSHOT}) hosts_events = mock_sync.generate_random_events_list(spec_list) host_transformer = self.transformers[NOVA_HOST_DATASOURCE] diff --git a/vitrage/tests/unit/datasources/nova/test_nova_instance_transformers.py b/vitrage/tests/unit/datasources/nova/test_nova_instance_transformer.py similarity index 98% rename from vitrage/tests/unit/datasources/nova/test_nova_instance_transformers.py rename to vitrage/tests/unit/datasources/nova/test_nova_instance_transformer.py index e672765c3..b0e3cba19 100644 --- a/vitrage/tests/unit/datasources/nova/test_nova_instance_transformers.py +++ b/vitrage/tests/unit/datasources/nova/test_nova_instance_transformer.py @@ -17,11 +17,11 @@ import datetime from oslo_config import cfg from oslo_log import log as logging +from vitrage.common.constants import ActionType from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EdgeLabel from vitrage.common.constants import EntityCategory from vitrage.common.constants import EventAction -from vitrage.common.constants import SyncMode from vitrage.common.constants import UpdateMethod from vitrage.common.constants import VertexProperties from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE @@ -118,10 +118,10 @@ class NovaInstanceTransformerTest(base.BaseTest): host_neighbor = wrapper.neighbors[0] self._validate_host_neighbor(host_neighbor, event) - sync_mode = event[DSProps.SYNC_MODE] - if sync_mode == SyncMode.INIT_SNAPSHOT: + action_type = event[DSProps.ACTION_TYPE] + if action_type == ActionType.INIT_SNAPSHOT: self.assertEqual(EventAction.CREATE_ENTITY, wrapper.action) - elif sync_mode == SyncMode.SNAPSHOT: + elif action_type == ActionType.SNAPSHOT: self.assertEqual(EventAction.UPDATE_ENTITY, wrapper.action) def test_update_event_transform(self): 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 ca1b2dab8..74b0e2c27 100644 --- a/vitrage/tests/unit/datasources/nova/test_nova_zone_transformer.py +++ b/vitrage/tests/unit/datasources/nova/test_nova_zone_transformer.py @@ -152,7 +152,7 @@ class NovaZoneTransformerTest(base.BaseTest): self._validate_host_neighbor(neighbor, zone_vertex_id, hosts, - event[DSProps.SYNC_MODE]) + event[DSProps.ACTION_TYPE]) self.assertEqual(1, cluster_neighbors_counter, @@ -162,7 +162,7 @@ class NovaZoneTransformerTest(base.BaseTest): host_neighbor, zone_vertex_id, hosts, - sync_mode): + action_type): host_vertex = host_neighbor.vertex host_vertex_id = host_vertex.get(VertexProperties.ID) diff --git a/vitrage/tests/unit/datasources/static/test_static_driver.py b/vitrage/tests/unit/datasources/static/test_static_driver.py index b527bd168..0e8d3ba26 100644 --- a/vitrage/tests/unit/datasources/static/test_static_driver.py +++ b/vitrage/tests/unit/datasources/static/test_static_driver.py @@ -15,8 +15,8 @@ from oslo_config import cfg from oslo_log import log as logging +from vitrage.common.constants import ActionType from vitrage.common.constants import EventAction -from vitrage.common.constants import SyncMode from vitrage.datasources.static import driver from vitrage.datasources.static import STATIC_DATASOURCE from vitrage.tests import base @@ -70,7 +70,7 @@ class TestStaticDriver(base.BaseTest): def test_get_all(self): # Action - static_entities = self.static_driver.get_all(SyncMode.UPDATE) + static_entities = self.static_driver.get_all(ActionType.UPDATE) # Test assertions self.assertEqual(0, len(static_entities)) @@ -78,7 +78,7 @@ class TestStaticDriver(base.BaseTest): # noinspection PyAttributeOutsideInit def test_get_changes(self): # Setup - entities = self.static_driver.get_all(SyncMode.UPDATE) + entities = self.static_driver.get_all(ActionType.UPDATE) self.assertEqual(0, len(entities)) self.conf = cfg.ConfigOpts() 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 004197f33..f8c01093b 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,9 +17,9 @@ import os from oslo_config import cfg from oslo_log import log as logging +from vitrage.common.constants import ActionType from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EventAction -from vitrage.common.constants import SyncMode from vitrage.common.constants import VertexProperties as VProps from vitrage.common import file_utils from vitrage.datasources.static_physical import driver @@ -92,7 +92,8 @@ class TestStaticPhysicalDriver(base.BaseTest): def test_get_all(self): # Action - static_entities = self.static_physical_driver.get_all(SyncMode.UPDATE) + static_entities = \ + self.static_physical_driver.get_all(ActionType.UPDATE) # Test assertions self.assertEqual(5, len(static_entities)) @@ -100,7 +101,7 @@ class TestStaticPhysicalDriver(base.BaseTest): # noinspection PyAttributeOutsideInit def test_get_changes(self): # Setup - entities = self.static_physical_driver.get_all(SyncMode.UPDATE) + entities = self.static_physical_driver.get_all(ActionType.UPDATE) self.assertEqual(5, len(entities)) self.conf = cfg.ConfigOpts() diff --git a/vitrage/tests/unit/datasources/zabbix/test_zabbix_transformer.py b/vitrage/tests/unit/datasources/zabbix/test_zabbix_transformer.py index d7099c4ec..2af76c606 100644 --- a/vitrage/tests/unit/datasources/zabbix/test_zabbix_transformer.py +++ b/vitrage/tests/unit/datasources/zabbix/test_zabbix_transformer.py @@ -15,11 +15,11 @@ from oslo_config import cfg from oslo_log import log as logging +from vitrage.common.constants import ActionType from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EdgeLabel from vitrage.common.constants import EntityCategory from vitrage.common.constants import EventAction -from vitrage.common.constants import SyncMode from vitrage.common.constants import UpdateMethod from vitrage.common.constants import VertexProperties as VProps from vitrage.common.datetime_utils import format_unix_timestamp @@ -77,7 +77,7 @@ class ZabbixTransformerTest(base.BaseTest): TransformerBase.KEY_SEPARATOR) self.assertEqual(EntityCategory.ALARM, observed_key_fields[0]) - self.assertEqual(event[DSProps.SYNC_TYPE], observed_key_fields[1]) + self.assertEqual(event[DSProps.ENTITY_TYPE], observed_key_fields[1]) self.assertEqual(event[ZabbixProps.RESOURCE_NAME], observed_key_fields[2]) self.assertEqual(event[ZabbixProps.TRIGGER_ID], @@ -109,8 +109,8 @@ class ZabbixTransformerTest(base.BaseTest): self._validate_action(alarm, wrapper) def _validate_action(self, alarm, wrapper): - sync_mode = alarm[DSProps.SYNC_MODE] - if sync_mode in (SyncMode.SNAPSHOT, SyncMode.UPDATE): + action_type = alarm[DSProps.ACTION_TYPE] + if action_type in (ActionType.SNAPSHOT, ActionType.UPDATE): if alarm[ZabbixProps.VALUE] == ZabbixTriggerValue.OK: self.assertEqual(EventAction.DELETE_ENTITY, wrapper.action) else: @@ -121,7 +121,7 @@ class ZabbixTransformerTest(base.BaseTest): def _validate_vertex(self, vertex, event): self.assertEqual(EntityCategory.ALARM, vertex[VProps.CATEGORY]) - self.assertEqual(event[DSProps.SYNC_TYPE], vertex[VProps.TYPE]) + self.assertEqual(event[DSProps.ENTITY_TYPE], vertex[VProps.TYPE]) self.assertEqual(event[ZabbixProps.DESCRIPTION], vertex[VProps.NAME]) diff --git a/vitrage/tests/unit/entity_graph/base.py b/vitrage/tests/unit/entity_graph/base.py index e2761b405..129b7d5be 100644 --- a/vitrage/tests/unit/entity_graph/base.py +++ b/vitrage/tests/unit/entity_graph/base.py @@ -14,9 +14,9 @@ from oslo_config import cfg +from vitrage.common.constants import ActionType from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EntityCategory -from vitrage.common.constants import SyncMode from vitrage.datasources.nagios import NAGIOS_DATASOURCE from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE from vitrage.datasources.nova.instance import NOVA_INSTANCE_DATASOURCE @@ -80,24 +80,24 @@ class TestEntityGraphUnitBase(base.BaseTest): self.NUM_ZONES, self.NUM_HOSTS, snapshot_events=self.NUM_ZONES, - snap_vals={DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT}) + snap_vals={DSProps.ACTION_TYPE: ActionType.INIT_SNAPSHOT}) gen_list += mock_sync.simple_host_generators( self.NUM_ZONES, self.NUM_HOSTS, self.NUM_HOSTS, - snap_vals={DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT}) + snap_vals={DSProps.ACTION_TYPE: ActionType.INIT_SNAPSHOT}) gen_list += mock_sync.simple_instance_generators( self.NUM_HOSTS, self.NUM_INSTANCES, self.NUM_INSTANCES, - snap_vals={DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT}) + snap_vals={DSProps.ACTION_TYPE: ActionType.INIT_SNAPSHOT}) return mock_sync.generate_sequential_events_list(gen_list) - def _create_entity(self, processor=None, spec_type=None, sync_mode=None, + def _create_entity(self, processor=None, spec_type=None, action_type=None, event_type=None, properties=None): # create instance event with host neighbor event = self._create_event(spec_type=spec_type, - sync_mode=sync_mode, + action_type=action_type, event_type=event_type, properties=properties) @@ -112,7 +112,7 @@ class TestEntityGraphUnitBase(base.BaseTest): return vertex, neighbors, processor @staticmethod - def _create_event(spec_type=None, sync_mode=None, + def _create_event(spec_type=None, action_type=None, event_type=None, properties=None): # generate event spec_list = mock_sync.simple_instance_generators(1, 1, 1) @@ -120,8 +120,8 @@ class TestEntityGraphUnitBase(base.BaseTest): spec_list) # update properties - if sync_mode is not None: - events_list[0][DSProps.SYNC_MODE] = sync_mode + if action_type is not None: + events_list[0][DSProps.ACTION_TYPE] = action_type if event_type is not None: events_list[0][DSProps.EVENT_TYPE] = event_type diff --git a/vitrage/tests/unit/entity_graph/processor/test_processor.py b/vitrage/tests/unit/entity_graph/processor/test_processor.py index cbf834e64..cb86ca62c 100644 --- a/vitrage/tests/unit/entity_graph/processor/test_processor.py +++ b/vitrage/tests/unit/entity_graph/processor/test_processor.py @@ -14,9 +14,9 @@ from oslo_config import cfg +from vitrage.common.constants import ActionType from vitrage.common.constants import DatasourceProperties as DSProps from vitrage.common.constants import EventAction -from vitrage.common.constants import SyncMode from vitrage.common.constants import VertexProperties as VProps from vitrage.common.datetime_utils import utcnow from vitrage.datasources.transformer_base import Neighbor @@ -51,13 +51,13 @@ class TestProcessor(TestEntityGraphUnitBase): # check create instance event processor = proc.Processor(self.conf, InitializationStatus()) event = self._create_event(spec_type=self.INSTANCE_SPEC, - sync_mode=SyncMode.INIT_SNAPSHOT) + action_type=ActionType.INIT_SNAPSHOT) processor.process_event(event) self._check_graph(processor, self.NUM_VERTICES_AFTER_CREATION, self.NUM_EDGES_AFTER_CREATION) # check update instance even - event[DSProps.SYNC_MODE] = SyncMode.UPDATE + event[DSProps.ACTION_TYPE] = ActionType.UPDATE event[DSProps.EVENT_TYPE] = 'compute.instance.volume.attach' event['hostname'] = 'new_host' event['instance_id'] = event['id'] @@ -68,7 +68,7 @@ class TestProcessor(TestEntityGraphUnitBase): self.NUM_EDGES_AFTER_CREATION) # check delete instance event - event[DSProps.SYNC_MODE] = SyncMode.UPDATE + event[DSProps.ACTION_TYPE] = ActionType.UPDATE event[DSProps.EVENT_TYPE] = 'compute.instance.delete.end' processor.process_event(event) self._check_graph(processor, self.NUM_VERTICES_AFTER_DELETION, @@ -133,10 +133,10 @@ class TestProcessor(TestEntityGraphUnitBase): # setup vertex1, neighbors1, processor = self._create_entity( spec_type=self.INSTANCE_SPEC, - sync_mode=SyncMode.INIT_SNAPSHOT) + action_type=ActionType.INIT_SNAPSHOT) vertex2, neighbors2, processor = self._create_entity( spec_type=self.INSTANCE_SPEC, - sync_mode=SyncMode.INIT_SNAPSHOT, + action_type=ActionType.INIT_SNAPSHOT, processor=processor) self.assertEqual(2, processor.entity_graph.num_edges()) @@ -155,10 +155,10 @@ class TestProcessor(TestEntityGraphUnitBase): # setup vertex1, neighbors1, processor = self._create_entity( spec_type=self.INSTANCE_SPEC, - sync_mode=SyncMode.INIT_SNAPSHOT) + action_type=ActionType.INIT_SNAPSHOT) vertex2, neighbors2, processor = self._create_entity( spec_type=self.INSTANCE_SPEC, - sync_mode=SyncMode.INIT_SNAPSHOT, + action_type=ActionType.INIT_SNAPSHOT, processor=processor) self.assertEqual(2, processor.entity_graph.num_edges()) @@ -179,7 +179,7 @@ class TestProcessor(TestEntityGraphUnitBase): # setup vertex, neighbors, processor = self._create_entity( spec_type=self.INSTANCE_SPEC, - sync_mode=SyncMode.INIT_SNAPSHOT) + action_type=ActionType.INIT_SNAPSHOT) self.assertEqual(1, processor.entity_graph.num_edges()) vertex[VProps.IS_DELETED] = True processor.entity_graph.update_vertex(vertex) @@ -302,7 +302,7 @@ class TestProcessor(TestEntityGraphUnitBase): # create instance event with host neighbor (vertex, neighbors, processor) = self._create_entity( spec_type=self.INSTANCE_SPEC, - sync_mode=SyncMode.INIT_SNAPSHOT, + action_type=ActionType.INIT_SNAPSHOT, properties=kwargs, processor=processor) diff --git a/vitrage_tempest_tests/tests/base_mock.py b/vitrage_tempest_tests/tests/base_mock.py index 37a1331c1..9884762b4 100644 --- a/vitrage_tempest_tests/tests/base_mock.py +++ b/vitrage_tempest_tests/tests/base_mock.py @@ -45,9 +45,10 @@ class BaseMock(testtools.TestCase): @staticmethod def _create_mock_events(): gen_list = mock_sync.simple_zone_generators( - 2, 4, snapshot_events=2, snap_vals={'sync_mode': 'init_snapshot'}) + 2, 4, snapshot_events=2, + snap_vals={'action_type': 'init_snapshot'}) gen_list += mock_sync.simple_host_generators( - 2, 4, 4, snap_vals={'sync_mode': 'init_snapshot'}) + 2, 4, 4, snap_vals={'action_type': 'init_snapshot'}) gen_list += mock_sync.simple_instance_generators( - 4, 15, 15, snap_vals={'sync_mode': 'init_snapshot'}) + 4, 15, 15, snap_vals={'action_type': 'init_snapshot'}) return mock_sync.generate_sequential_events_list(gen_list)