name refactor - change 'SynchronizerProperties' to DatasourceProperties

Change-Id: I83df4f8818fb3318afc3fb1acb94c6e5c5b2e1eb
This commit is contained in:
liathartal 2016-04-07 11:30:29 +00:00
parent d60ff5abee
commit e47e0b2497
49 changed files with 152 additions and 155 deletions

View File

@ -118,8 +118,8 @@
# Aodh plugin transformer class path (string value) # Aodh plugin transformer class path (string value)
#transformer = vitrage.datasources.aodh.transformer.AodhTransformer #transformer = vitrage.datasources.aodh.transformer.AodhTransformer
# Aodh plugin synchronizer class path (string value) # Aodh datasource driver class path (string value)
#synchronizer = vitrage.datasources.aodh.driver.AodhDriver #driver = vitrage.datasources.aodh.driver.AodhDriver
# interval between checking changes in aodh datasource (integer value) # interval between checking changes in aodh datasource (integer value)
# Minimum value: 30 # Minimum value: 30
@ -399,7 +399,7 @@
#transformer = vitrage.datasources.nagios.transformer.NagiosTransformer #transformer = vitrage.datasources.nagios.transformer.NagiosTransformer
# Nagios plugin driver class path (string value) # 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) # interval between checking changes in nagios datasource (integer value)
# Minimum value: 30 # Minimum value: 30
@ -428,7 +428,7 @@
#transformer = vitrage.datasources.nova.host.transformer.HostTransformer #transformer = vitrage.datasources.nova.host.transformer.HostTransformer
# Nova host driver class path (string value) # Nova host driver class path (string value)
#synchronizer = vitrage.datasources.nova.host.driver.HostDriver #driver = vitrage.datasources.nova.host.driver.HostDriver
[nova.instance] [nova.instance]
@ -441,7 +441,7 @@
#transformer = vitrage.datasources.nova.instance.transformer.InstanceTransformer #transformer = vitrage.datasources.nova.instance.transformer.InstanceTransformer
# Nova instance driver class path (string value) # Nova instance driver class path (string value)
#synchronizer = vitrage.datasources.nova.instance.driver.InstanceDriver #driver = vitrage.datasources.nova.instance.driver.InstanceDriver
[nova.zone] [nova.zone]
@ -454,7 +454,7 @@
#transformer = vitrage.datasources.nova.zone.transformer.ZoneTransformer #transformer = vitrage.datasources.nova.zone.transformer.ZoneTransformer
# Nova zone driver class path (string value) # Nova zone driver class path (string value)
#synchronizer = vitrage.datasources.nova.zone.driver.ZoneDriver #driver = vitrage.datasources.nova.zone.driver.ZoneDriver
[oslo_middleware] [oslo_middleware]
@ -523,10 +523,10 @@
# #
# Static physical transformer class path (string value) # 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) # Static physical driver class path (string value)
#synchronizer = vitrage.synchronizer.plugins.static_physical.synchronizer.StaticPhysicalSynchronizer #driver = vitrage.datasources.static_physical.driver.StaticPhysicalDriver
# interval between checking changes in the configuration files of the physical # interval between checking changes in the configuration files of the physical
# topology plugin (integer value) # topology plugin (integer value)
@ -540,7 +540,7 @@
#entities = switch #entities = switch
[synchronizer] [datasources]
# #
# From vitrage # From vitrage
@ -550,12 +550,5 @@
# Minimum value: 10 # Minimum value: 10
#snapshots_interval = 600 #snapshots_interval = 600
[plugins]
#
# From vitrage
#
# Names of supported plugins (list value) # 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

View File

@ -36,13 +36,13 @@ def main():
1. Starts the Entity graph service 1. Starts the Entity graph service
2. Starts the api_handler service 2. Starts the api_handler service
3. Starts the Synchronizer service 3. Starts the datasource service
4. Starts the Consistency service 4. Starts the Consistency service
""" """
conf, event_queue, evaluator, e_graph, initialization_status = init() conf, event_queue, evaluator, e_graph, initialization_status = init()
launcher = os_service.ServiceLauncher(conf) launcher = os_service.ServiceLauncher(conf)
synchronizers = datasource_launcher.Launcher( datasources = datasource_launcher.Launcher(
conf, conf,
datasource_launcher.create_send_to_queue_callback(event_queue)) datasource_launcher.create_send_to_queue_callback(event_queue))
@ -52,7 +52,7 @@ def main():
launcher.launch_service(api_handler_svc.VitrageApiHandlerService( launcher.launch_service(api_handler_svc.VitrageApiHandlerService(
conf, e_graph)) conf, e_graph))
synchronizers.launch() datasources.launch()
launcher.launch_service(consistency_svc.VitrageGraphConsistencyService( launcher.launch_service(consistency_svc.VitrageGraphConsistencyService(
conf, event_queue, evaluator, e_graph, initialization_status)) conf, event_queue, evaluator, e_graph, initialization_status))

View File

@ -58,7 +58,7 @@ class EntityCategory(object):
ALARM = 'ALARM' ALARM = 'ALARM'
class SynchronizerProperties(object): class DatasourceProperties(object):
SYNC_TYPE = 'sync_type' SYNC_TYPE = 'sync_type'
SYNC_MODE = 'sync_mode' SYNC_MODE = 'sync_mode'
SAMPLE_DATE = 'sample_date' SAMPLE_DATE = 'sample_date'

View File

@ -14,9 +14,9 @@
from oslo_log import log as logging 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 EntityCategory
from vitrage.common.constants import EventAction 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 SyncMode
from vitrage.common.exception import VitrageTransformerError from vitrage.common.exception import VitrageTransformerError
from vitrage.datasources import transformer_base as tbase from vitrage.datasources import transformer_base as tbase
@ -37,7 +37,7 @@ class AlarmTransformerBase(tbase.TransformerBase):
pass pass
def _extract_action_type(self, entity_event): 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): if sync_mode in (SyncMode.UPDATE, SyncMode.SNAPSHOT):
return EventAction.DELETE_ENTITY if self._ok_status(entity_event) \ return EventAction.DELETE_ENTITY if self._ok_status(entity_event) \
else EventAction.UPDATE_ENTITY else EventAction.UPDATE_ENTITY

View File

@ -13,9 +13,9 @@
# under the License. # under the License.
from oslo_log import log as logging 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 EdgeLabels
from vitrage.common.constants import EntityCategory 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.constants import VertexProperties as VProps
from vitrage.common import datetime_utils from vitrage.common import datetime_utils
from vitrage.datasources.alarm_properties import AlarmProperties as AlarmProps from vitrage.datasources.alarm_properties import AlarmProperties as AlarmProps
@ -59,7 +59,7 @@ class AodhTransformer(AlarmTransformerBase):
metadata[AodhProps.STATE_TIMESTAMP] = \ metadata[AodhProps.STATE_TIMESTAMP] = \
entity_event[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( update_timestamp = self._format_update_timestamp(
AodhTransformer._timestamp(entity_event), sample_timestamp) AodhTransformer._timestamp(entity_event), sample_timestamp)
@ -68,7 +68,7 @@ class AodhTransformer(AlarmTransformerBase):
self._create_entity_key(entity_event), self._create_entity_key(entity_event),
entity_id=entity_event[AodhProps.ALARM_ID], entity_id=entity_event[AodhProps.ALARM_ID],
entity_category=EntityCategory.ALARM, entity_category=EntityCategory.ALARM,
entity_type=entity_event[SyncProps.SYNC_TYPE], entity_type=entity_event[DSProps.SYNC_TYPE],
entity_state=AlarmProps.ALARM_ACTIVE_STATE, entity_state=AlarmProps.ALARM_ACTIVE_STATE,
sample_timestamp=sample_timestamp, sample_timestamp=sample_timestamp,
update_timestamp=update_timestamp, update_timestamp=update_timestamp,
@ -89,7 +89,7 @@ class AodhTransformer(AlarmTransformerBase):
return entity_event[AodhProps.STATE] == self.STATUS_OK return entity_event[AodhProps.STATE] == self.STATUS_OK
def _create_entity_key(self, entity_event): 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] alarm_name = entity_event[AodhProps.NAME]
resource_id = entity_event[AodhProps.RESOURCE_ID] resource_id = entity_event[AodhProps.RESOURCE_ID]
return (tbase.build_key(self._key_values(sync_type, return (tbase.build_key(self._key_values(sync_type,

View File

@ -15,7 +15,7 @@
from oslo_log import log as logging from oslo_log import log as logging
from vitrage import clients 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.common.constants import SyncMode
from vitrage.datasources.cinder.volume import CINDER_VOLUME_DATASOURCE from vitrage.datasources.cinder.volume import CINDER_VOLUME_DATASOURCE
from vitrage.datasources.driver_base import DriverBase from vitrage.datasources.driver_base import DriverBase
@ -42,7 +42,7 @@ class CinderVolumeDriver(DriverBase):
@staticmethod @staticmethod
def enrich_event(event, event_type): def enrich_event(event, event_type):
event[SyncProps.EVENT_TYPE] = event_type event[DSProps.EVENT_TYPE] = event_type
return CinderVolumeDriver.make_pickleable([event], return CinderVolumeDriver.make_pickleable([event],
CINDER_VOLUME_DATASOURCE, CINDER_VOLUME_DATASOURCE,

View File

@ -14,10 +14,10 @@
from oslo_log import log as logging 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 EdgeLabels
from vitrage.common.constants import EntityCategory from vitrage.common.constants import EntityCategory
from vitrage.common.constants import EventAction 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.constants import VertexProperties as VProps
from vitrage.datasources.cinder.volume import CINDER_VOLUME_DATASOURCE from vitrage.datasources.cinder.volume import CINDER_VOLUME_DATASOURCE
from vitrage.datasources.nova.instance import NOVA_INSTANCE_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) 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( return graph_utils.create_vertex(
entity_key, entity_key,
@ -136,7 +136,7 @@ class CinderVolumeTransformer(ResourceTransformerBase):
instance_id = attachment[instance_id_property] instance_id = attachment[instance_id_property]
sample_timestamp = entity_event[SyncProps.SAMPLE_DATE] sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
properties = { properties = {
VProps.ID: instance_id, VProps.ID: instance_id,

View File

@ -17,8 +17,8 @@ import six
from oslo_log import log from oslo_log import log
from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import EventAction 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 SyncMode
from vitrage.common import datetime_utils from vitrage.common import datetime_utils
@ -38,9 +38,9 @@ class DriverBase(object):
@staticmethod @staticmethod
def _get_end_message(sync_type): def _get_end_message(sync_type):
end_message = { end_message = {
SyncProps.SYNC_TYPE: sync_type, DSProps.SYNC_TYPE: sync_type,
SyncProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT, DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT,
SyncProps.EVENT_TYPE: EventAction.END_MESSAGE DSProps.EVENT_TYPE: EventAction.END_MESSAGE
} }
return end_message return end_message
@ -68,16 +68,16 @@ class DriverBase(object):
@staticmethod @staticmethod
def _add_sync_type(entity, sync_type): def _add_sync_type(entity, sync_type):
if SyncProps.SYNC_TYPE not in entity: if DSProps.SYNC_TYPE not in entity:
entity[SyncProps.SYNC_TYPE] = sync_type entity[DSProps.SYNC_TYPE] = sync_type
@staticmethod @staticmethod
def _add_sampling_time(entity): def _add_sampling_time(entity):
entity[SyncProps.SAMPLE_DATE] = str(datetime_utils.utcnow()) entity[DSProps.SAMPLE_DATE] = str(datetime_utils.utcnow())
@staticmethod @staticmethod
def _add_sync_mode(entity, sync_mode): def _add_sync_mode(entity, sync_mode):
entity[SyncProps.SYNC_MODE] = sync_mode entity[DSProps.SYNC_MODE] = sync_mode
@staticmethod @staticmethod
@abc.abstractmethod @abc.abstractmethod
@ -96,14 +96,14 @@ class DriverBase(object):
@staticmethod @staticmethod
@abc.abstractmethod @abc.abstractmethod
def get_event_types(conf): 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: Example:
return ['compute.instance.update', return ['compute.instance.update',
'compute.instance.resume'] 'compute.instance.resume']
It also supports prefixes- the event types which start 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: Example:
return ['compute.instance'] return ['compute.instance']
@ -118,7 +118,7 @@ class DriverBase(object):
@staticmethod @staticmethod
@abc.abstractmethod @abc.abstractmethod
def get_topic(conf): def get_topic(conf):
"""Return the topic of events processed by this synchronizer """Return the topic of events processed by this driver
Example: Example:
to listen to nova topic, add another topic to nova.conf so nova will 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(): example of get_topic():
return 'new_topic' return 'new_topic'
:param conf: the synchronizer's configuration :param conf: the datasource's configuration
:return: the topic of the synchronizer :return: the topic of the datasource
:rtype: str :rtype: str
""" """

View File

@ -17,7 +17,7 @@ from collections import namedtuple
from oslo_log import log from oslo_log import log
import requests 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.alarm_driver_base import AlarmDriverBase
from vitrage.datasources.nagios.config import NagiosConfig from vitrage.datasources.nagios.config import NagiosConfig
from vitrage.datasources.nagios import NAGIOS_DATASOURCE from vitrage.datasources.nagios import NAGIOS_DATASOURCE
@ -83,7 +83,7 @@ class NagiosDriver(AlarmDriverBase):
for alarm in alarms: for alarm in alarms:
# based on nagios configuration file, convert nagios host name # based on nagios configuration file, convert nagios host name
# to vitrage resource type and 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] nagios_host = alarm[NagiosProps.RESOURCE_NAME]
vitrage_resource = self.config.get_vitrage_resource(nagios_host) vitrage_resource = self.config.get_vitrage_resource(nagios_host)

View File

@ -14,9 +14,9 @@
from oslo_log import log as logging 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 EdgeLabels
from vitrage.common.constants import EntityCategory 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.constants import VertexProperties as VProps
from vitrage.common import datetime_utils from vitrage.common import datetime_utils
from vitrage.datasources.alarm_properties import AlarmProperties as AlarmProps from vitrage.datasources.alarm_properties import AlarmProperties as AlarmProps
@ -52,7 +52,7 @@ class NagiosTransformer(AlarmTransformerBase):
'%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M:%S',
tbase.TIMESTAMP_FORMAT) 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, update_timestamp = self._format_update_timestamp(update_timestamp,
sample_timestamp) sample_timestamp)
@ -70,7 +70,7 @@ class NagiosTransformer(AlarmTransformerBase):
return graph_utils.create_vertex( return graph_utils.create_vertex(
self._create_entity_key(entity_event), self._create_entity_key(entity_event),
entity_category=EntityCategory.ALARM, entity_category=EntityCategory.ALARM,
entity_type=entity_event[SyncProps.SYNC_TYPE], entity_type=entity_event[DSProps.SYNC_TYPE],
entity_state=entity_state, entity_state=entity_state,
sample_timestamp=sample_timestamp, sample_timestamp=sample_timestamp,
update_timestamp=update_timestamp, update_timestamp=update_timestamp,
@ -125,7 +125,7 @@ class NagiosTransformer(AlarmTransformerBase):
def _create_entity_key(self, entity_event): 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] alarm_name = entity_event[NagiosProperties.SERVICE]
resource_name = entity_event[NagiosProperties.RESOURCE_NAME] resource_name = entity_event[NagiosProperties.RESOURCE_NAME]
return tbase.build_key(self._key_values(sync_type, return tbase.build_key(self._key_values(sync_type,

View File

@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import EntityCategory 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.constants import VertexProperties as VProps
from vitrage.datasources.neutron.network import NEUTRON_NETWORK_DATASOURCE from vitrage.datasources.neutron.network import NEUTRON_NETWORK_DATASOURCE
from vitrage.datasources.resource_transformer_base import \ from vitrage.datasources.resource_transformer_base import \
@ -51,12 +51,12 @@ class NetworkTransformer(ResourceTransformerBase):
VProps.NAME: name, 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 # TODO(Alexey): need to check here that only the UPDATE sync_mode will
# update the UPDATE_TIMESTAMP property # update the UPDATE_TIMESTAMP property
update_timestamp = self._format_update_timestamp( update_timestamp = self._format_update_timestamp(
extract_field_value(entity_event, SyncProps.SAMPLE_DATE), extract_field_value(entity_event, DSProps.SAMPLE_DATE),
sample_timestamp) sample_timestamp)
return graph_utils.create_vertex( return graph_utils.create_vertex(

View File

@ -16,9 +16,9 @@ from vitrage.datasources.resource_transformer_base import \
from oslo_log import log as logging 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 EdgeLabels
from vitrage.common.constants import EntityCategory 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.constants import VertexProperties as VProps
from vitrage.datasources.neutron.network import NEUTRON_NETWORK_DATASOURCE from vitrage.datasources.neutron.network import NEUTRON_NETWORK_DATASOURCE
from vitrage.datasources.neutron.port import NEUTRON_PORT_DATASOURCE from vitrage.datasources.neutron.port import NEUTRON_PORT_DATASOURCE
@ -58,12 +58,12 @@ class PortTransformer(ResourceTransformerBase):
VProps.NAME: name, 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 # TODO(Alexey): need to check here that only the UPDATE sync_mode will
# update the UPDATE_TIMESTAMP property # update the UPDATE_TIMESTAMP property
update_timestamp = self._format_update_timestamp( update_timestamp = self._format_update_timestamp(
extract_field_value(entity_event, SyncProps.SAMPLE_DATE), extract_field_value(entity_event, DSProps.SAMPLE_DATE),
sample_timestamp) sample_timestamp)
return graph_utils.create_vertex( return graph_utils.create_vertex(
@ -118,7 +118,7 @@ class PortTransformer(ResourceTransformerBase):
instance_id = entity_event[instance_id_property] instance_id = entity_event[instance_id_property]
sample_timestamp = entity_event[SyncProps.SAMPLE_DATE] sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
properties = { properties = {
VProps.ID: instance_id, VProps.ID: instance_id,
@ -139,7 +139,7 @@ class PortTransformer(ResourceTransformerBase):
net_id = entity_event[net_id_property] net_id = entity_event[net_id_property]
sample_timestamp = entity_event[SyncProps.SAMPLE_DATE] sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
properties = { properties = {
VProps.ID: net_id, VProps.ID: net_id,

View File

@ -14,9 +14,9 @@
from oslo_log import log as logging 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 EdgeLabels
from vitrage.common.constants import EntityCategory 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.constants import VertexProperties as VProps
from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
from vitrage.datasources.nova.zone import NOVA_ZONE_DATASOURCE from vitrage.datasources.nova.zone import NOVA_ZONE_DATASOURCE
@ -49,7 +49,7 @@ class HostTransformer(ResourceTransformerBase):
metadata = {VProps.NAME: host_name} metadata = {VProps.NAME: host_name}
entity_key = self._create_entity_key(entity_event) 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, update_timestamp = self._format_update_timestamp(None,
sample_timestamp) sample_timestamp)
@ -69,7 +69,7 @@ class HostTransformer(ResourceTransformerBase):
# Support snapshot and snapshot_init events only # Support snapshot and snapshot_init events only
zone_neighbor = self._create_zone_neighbor( zone_neighbor = self._create_zone_neighbor(
entity_event, entity_event,
entity_event[SyncProps.SAMPLE_DATE], entity_event[DSProps.SAMPLE_DATE],
self._create_entity_key(entity_event), self._create_entity_key(entity_event),
'zone') 'zone')

View File

@ -14,7 +14,7 @@
from oslo_log import log as logging 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.common.constants import SyncMode
from vitrage.datasources.nova.instance import NOVA_INSTANCE_DATASOURCE from vitrage.datasources.nova.instance import NOVA_INSTANCE_DATASOURCE
from vitrage.datasources.nova.nova_driver_base import NovaDriverBase from vitrage.datasources.nova.nova_driver_base import NovaDriverBase
@ -37,7 +37,7 @@ class InstanceDriver(NovaDriverBase):
@staticmethod @staticmethod
def enrich_event(event, event_type): def enrich_event(event, event_type):
event[SyncProps.EVENT_TYPE] = event_type event[DSProps.EVENT_TYPE] = event_type
return InstanceDriver.make_pickleable([event], return InstanceDriver.make_pickleable([event],
NOVA_INSTANCE_DATASOURCE, NOVA_INSTANCE_DATASOURCE,

View File

@ -14,10 +14,10 @@
from oslo_log import log as logging 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 EdgeLabels
from vitrage.common.constants import EntityCategory from vitrage.common.constants import EntityCategory
from vitrage.common.constants import EventAction 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.constants import VertexProperties as VProps
from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
from vitrage.datasources.nova.instance import NOVA_INSTANCE_DATASOURCE from vitrage.datasources.nova.instance import NOVA_INSTANCE_DATASOURCE
@ -67,12 +67,12 @@ class InstanceTransformer(ResourceTransformerBase):
VProps.PROJECT_ID: project 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 # TODO(Alexey): need to check here that only the UPDATE sync_mode will
# update the UPDATE_TIMESTAMP property # update the UPDATE_TIMESTAMP property
update_timestamp = self._format_update_timestamp( update_timestamp = self._format_update_timestamp(
extract_field_value(entity_event, SyncProps.SAMPLE_DATE), extract_field_value(entity_event, DSProps.SAMPLE_DATE),
sample_timestamp) sample_timestamp)
return graph_utils.create_vertex( return graph_utils.create_vertex(
@ -97,7 +97,7 @@ class InstanceTransformer(ResourceTransformerBase):
host_neighbor = self._create_host_neighbor( host_neighbor = self._create_host_neighbor(
self._create_entity_key(entity_event), self._create_entity_key(entity_event),
extract_field_value(entity_event, host_name), extract_field_value(entity_event, host_name),
entity_event[SyncProps.SAMPLE_DATE], entity_event[DSProps.SAMPLE_DATE],
host_transformer) host_transformer)
neighbors.append(host_neighbor) neighbors.append(host_neighbor)
else: else:

View File

@ -25,6 +25,6 @@ OPTS = [
cfg.StrOpt('driver', cfg.StrOpt('driver',
default='vitrage.datasources.nova.zone.driver' default='vitrage.datasources.nova.zone.driver'
'.ZoneDriver', '.ZoneDriver',
help='Nova zone synchronizer class path', help='Nova zone datasource class path',
required=True), required=True),
] ]

View File

@ -14,9 +14,9 @@
from oslo_log import log as logging 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 EdgeLabels
from vitrage.common.constants import EntityCategory 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.constants import VertexProperties as VProps
from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
from vitrage.datasources.nova.zone import NOVA_ZONE_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) 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, update_timestamp = self._format_update_timestamp(None,
sample_timestamp) sample_timestamp)
@ -98,7 +98,7 @@ class ZoneTransformer(ResourceTransformerBase):
zone_vertex_id, zone_vertex_id,
hostname, hostname,
host_state, host_state,
entity_event[SyncProps.SAMPLE_DATE]) entity_event[DSProps.SAMPLE_DATE])
neighbors.append(host_neighbor) neighbors.append(host_neighbor)
else: else:

View File

@ -21,15 +21,15 @@ from vitrage.common.constants import SyncMode
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
class SynchronizerService(os_service.Service): class DatasourceService(os_service.Service):
def __init__(self, conf, registered_datasources, callback_function): def __init__(self, conf, registered_datasources, callback_function):
super(SynchronizerService, self).__init__() super(DatasourceService, self).__init__()
self.conf = conf self.conf = conf
self.registered_datasources = registered_datasources self.registered_datasources = registered_datasources
self.callback_function = callback_function self.callback_function = callback_function
class SnapshotsService(SynchronizerService): class SnapshotsService(DatasourceService):
def __init__(self, conf, registered_datasources, callback_function): def __init__(self, conf, registered_datasources, callback_function):
super(SnapshotsService, self).__init__(conf, super(SnapshotsService, self).__init__(conf,
registered_datasources, registered_datasources,
@ -66,7 +66,7 @@ class SnapshotsService(SynchronizerService):
self.first_time = False self.first_time = False
class ChangesService(SynchronizerService): class ChangesService(DatasourceService):
def __init__(self, conf, def __init__(self, conf,
registered_datasources, registered_datasources,
changes_interval, changes_interval,
@ -77,7 +77,7 @@ class ChangesService(SynchronizerService):
self.changes_interval = changes_interval self.changes_interval = changes_interval
def start(self): 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__) self.registered_datasources[0].__class__.__name__)
super(ChangesService, self).start() super(ChangesService, self).start()
@ -85,16 +85,16 @@ class ChangesService(SynchronizerService):
callback=self._get_changes, callback=self._get_changes,
initial_delay=self.changes_interval) 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__) self.registered_datasources[0].__class__.__name__)
def stop(self, graceful=False): 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__) self.registered_datasources[0].__class__.__name__)
super(ChangesService, self).stop() 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__) self.registered_datasources[0].__class__.__name__)
def _get_changes(self): def _get_changes(self):

View File

@ -15,8 +15,8 @@
import copy import copy
import os import os
from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import EventAction 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.constants import VertexProperties as VProps
from vitrage.common import file_utils from vitrage.common import file_utils
from vitrage.datasources.driver_base import DriverBase from vitrage.datasources.driver_base import DriverBase
@ -130,4 +130,4 @@ class StaticPhysicalDriver(DriverBase):
@staticmethod @staticmethod
def _set_event_type(entity, event_type): def _set_event_type(entity, event_type):
entity[SyncProps.EVENT_TYPE] = event_type entity[DSProps.EVENT_TYPE] = event_type

View File

@ -14,8 +14,8 @@
from oslo_log import log as logging 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 EntityCategory
from vitrage.common.constants import SynchronizerProperties as SyncProps
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
from vitrage.datasources.resource_transformer_base import \ from vitrage.datasources.resource_transformer_base import \
@ -47,7 +47,7 @@ class StaticPhysicalTransformer(ResourceTransformerBase):
sync_type = entity_event[VProps.TYPE] sync_type = entity_event[VProps.TYPE]
entity_id = entity_event[VProps.ID] 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 = self._format_update_timestamp(
update_timestamp=None, update_timestamp=None,
sample_timestamp=sample_timestamp) sample_timestamp=sample_timestamp)
@ -69,7 +69,7 @@ class StaticPhysicalTransformer(ResourceTransformerBase):
neighbors = [] neighbors = []
entity_type = entity_event[VProps.TYPE] entity_type = entity_event[VProps.TYPE]
entity_key = self._create_entity_key(entity_event) 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]: for neighbor_details in entity_event[self.RELATIONSHIPS_SECTION]:
# TODO(alexey): need to decide what to do if one of the entities # TODO(alexey): need to decide what to do if one of the entities

View File

@ -21,8 +21,8 @@ import six
from vitrage.common import datetime_utils from vitrage.common import datetime_utils
import vitrage.common.constants as cons 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 EventAction
from vitrage.common.constants import SynchronizerProperties as SyncProps
from vitrage.common.constants import SyncMode from vitrage.common.constants import SyncMode
from vitrage.common.exception import VitrageTransformerError from vitrage.common.exception import VitrageTransformerError
from vitrage.datasources import OPENSTACK_NODE from vitrage.datasources import OPENSTACK_NODE
@ -83,7 +83,7 @@ def convert_timestamp_format(current_timestamp_format, timestamp):
def is_update_event(event): def is_update_event(event):
return event[SyncProps.SYNC_MODE] == SyncMode.UPDATE return event[DSProps.SYNC_MODE] == SyncMode.UPDATE
@six.add_metaclass(abc.ABCMeta) @six.add_metaclass(abc.ABCMeta)
@ -184,11 +184,11 @@ class TransformerBase(object):
:rtype: str :rtype: str
""" """
sync_mode = entity_event[SyncProps.SYNC_MODE] sync_mode = entity_event[DSProps.SYNC_MODE]
if SyncMode.UPDATE == sync_mode: if SyncMode.UPDATE == sync_mode:
return self.UPDATE_EVENT_TYPES.get( return self.UPDATE_EVENT_TYPES.get(
entity_event.get(SyncProps.EVENT_TYPE, None), entity_event.get(DSProps.EVENT_TYPE, None),
EventAction.UPDATE_ENTITY) EventAction.UPDATE_ENTITY)
if SyncMode.SNAPSHOT == sync_mode: if SyncMode.SNAPSHOT == sync_mode:
@ -212,16 +212,18 @@ class TransformerBase(object):
@staticmethod @staticmethod
def _create_end_vertex(entity_event): 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( return graph_utils.create_vertex(
'END_MESSAGE:' + sync_type, 'END_MESSAGE:' + sync_type,
entity_type=sync_type) entity_type=sync_type)
@staticmethod @staticmethod
def _is_end_message(entity_event): def _is_end_message(entity_event):
return entity_event[SyncProps.SYNC_MODE] == SyncMode.INIT_SNAPSHOT and\
SyncProps.EVENT_TYPE in entity_event and \ sync_mode = entity_event[DSProps.SYNC_MODE]
entity_event[SyncProps.EVENT_TYPE] == EventAction.END_MESSAGE 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 @staticmethod
def _format_update_timestamp(update_timestamp, sample_timestamp): def _format_update_timestamp(update_timestamp, sample_timestamp):

View File

@ -58,7 +58,7 @@ class VitrageGraphService(os_service.Service):
self._process_event_non_blocking() self._process_event_non_blocking()
def _process_event_non_blocking(self): 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) In order that other services (such as graph consistency, api handler)
could get work time as well, the work processing performed for 2 could get work time as well, the work processing performed for 2

View File

@ -16,7 +16,7 @@
from oslo_log import log as logging from oslo_log import log as logging
from oslo_utils import importutils 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.exception import VitrageTransformerError
from vitrage.common.utils import opt_exists from vitrage.common.utils import opt_exists
from vitrage.evaluator.actions.evaluator_event_transformer import \ from vitrage.evaluator.actions.evaluator_event_transformer import \
@ -75,7 +75,7 @@ class TransformerManager(object):
@staticmethod @staticmethod
def get_sync_type(entity_event): def get_sync_type(entity_event):
try: try:
return entity_event[SyncProps.SYNC_TYPE] return entity_event[DSProps.SYNC_TYPE]
except KeyError: except KeyError:
raise VitrageTransformerError( raise VitrageTransformerError(
'Entity Event must contains sync_type field.') 'Entity Event must contains sync_type field.')

View File

@ -17,7 +17,7 @@ import copy
from oslo_log import log as logging from oslo_log import log as logging
from oslo_utils import importutils 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 SyncMode
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.common import datetime_utils from vitrage.common import datetime_utils
@ -115,8 +115,8 @@ class ActionExecutor(object):
@staticmethod @staticmethod
def _add_default_properties(event): def _add_default_properties(event):
event[SyncProps.SYNC_MODE] = SyncMode.UPDATE event[DSProps.SYNC_MODE] = SyncMode.UPDATE
event[SyncProps.SYNC_TYPE] = VITRAGE_TYPE event[DSProps.SYNC_TYPE] = VITRAGE_TYPE
event[VProps.UPDATE_TIMESTAMP] = str(datetime_utils.utcnow(False)) event[VProps.UPDATE_TIMESTAMP] = str(datetime_utils.utcnow(False))
event[VProps.SAMPLE_TIMESTAMP] = str(datetime_utils.utcnow()) event[VProps.SAMPLE_TIMESTAMP] = str(datetime_utils.utcnow())

View File

@ -25,7 +25,7 @@ import vitrage.evaluator
import vitrage.keystone_client import vitrage.keystone_client
import vitrage.rpc import vitrage.rpc
DATASOURCES_MODULE_PATH = 'vitrage.datasources.' DATASOURCES_PATH = 'vitrage.datasources.'
DATASOURCE_FS_PATH = os.path.join('vitrage', 'datasources') DATASOURCE_FS_PATH = os.path.join('vitrage', 'datasources')
DRIVER_FILE = 'driver.py' DRIVER_FILE = 'driver.py'
TRANSFORMER_FILE = 'alarm_transformer_base.py' TRANSFORMER_FILE = 'alarm_transformer_base.py'
@ -44,18 +44,20 @@ def list_opts():
def datasources_opts(): def datasources_opts():
top = os.getcwd() 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 datasources = _normalize_path_to_datasource_name(
for plugin_module in _filter_folders_containing_transformer(_get_datasources_folders(top)),
[importutils.import_module(DATASOURCES_MODULE_PATH + plugin_name)] top)
if 'OPTS' in plugin_module.__dict__]
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)) return [os.path.dirname(os.path.join(root, name))
for root, dirs, files in os.walk(top, topdown=False) for root, dirs, files in os.walk(top, topdown=False)
for name in files if name == DRIVER_FILE] 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] 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)) return [os.path.relpath(path, os.path.join(top, DATASOURCE_FS_PATH))
.replace(os.sep, '.') for path in path_list] .replace(os.sep, '.') for path in path_list]

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # 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.common.constants import SyncMode
from vitrage.entity_graph.initialization_status import InitializationStatus from vitrage.entity_graph.initialization_status import InitializationStatus
from vitrage.entity_graph.processor import processor as proc from vitrage.entity_graph.processor import processor as proc
@ -38,15 +38,15 @@ class TestFunctionalBase(TestEntityGraphUnitBase):
self.NUM_ZONES, self.NUM_ZONES,
self.NUM_HOSTS, self.NUM_HOSTS,
snapshot_events=self.NUM_ZONES, 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( gen_list += mock_driver.simple_host_generators(
self.NUM_ZONES, self.NUM_ZONES,
self.NUM_HOSTS, self.NUM_HOSTS,
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( gen_list += mock_driver.simple_instance_generators(
self.NUM_HOSTS, self.NUM_HOSTS,
self.NUM_INSTANCES, self.NUM_INSTANCES,
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) return mock_driver.generate_sequential_events_list(gen_list)

View File

@ -14,8 +14,8 @@
from oslo_config import cfg from oslo_config import cfg
from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import EntityCategory 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.constants import VertexProperties as VProps
from vitrage.datasources import NAGIOS_DATASOURCE from vitrage.datasources import NAGIOS_DATASOURCE
from vitrage.datasources import NOVA_HOST_DATASOURCE from vitrage.datasources import NOVA_HOST_DATASOURCE
@ -66,7 +66,7 @@ class TestStaticPhysical(TestDataSourcesBase):
snapshot_events=1) snapshot_events=1)
static_events = mock_driver.generate_random_events_list(spec_list) static_events = mock_driver.generate_random_events_list(spec_list)
static_physical_event = static_events[0] 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'] = \ static_physical_event['relationships'][0]['name'] = \
self._find_entity_id_by_type(processor.entity_graph, self._find_entity_id_by_type(processor.entity_graph,
NOVA_HOST_DATASOURCE) NOVA_HOST_DATASOURCE)

View File

@ -29,7 +29,7 @@ def generate_random_events_list(generator_spec_list):
:param generator_spec_list: list of generators :param generator_spec_list: list of generators
:type generator_spec_list: list :type generator_spec_list: list
:return list of synchronizer events :return list of datasource events
:rtype list :rtype list
""" """

View File

@ -57,7 +57,7 @@ def _get_full_path(target_filename, target_folder):
""" """
if target_folder is None: if target_folder is None:
target_folder = '%s/mock_configurations/synchronizer' % \ target_folder = '%s/mock_configurations/driver' % \
get_resources_dir() get_resources_dir()
target = '{0}/{1}'.format(target_folder, target_filename) target = '{0}/{1}'.format(target_folder, target_filename)
return target return target

View File

@ -16,9 +16,9 @@ import datetime
from oslo_log import log as logging 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 EdgeLabels
from vitrage.common.constants import EntityCategory 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.constants import VertexProperties as VProps
from vitrage.datasources.cinder.volume import CINDER_VOLUME_DATASOURCE from vitrage.datasources.cinder.volume import CINDER_VOLUME_DATASOURCE
from vitrage.datasources.cinder.volume.transformer \ from vitrage.datasources.cinder.volume.transformer \
@ -151,14 +151,14 @@ class TestCinderVolumeTransformer(base.BaseTest):
is_update_event = tbase.is_update_event(event) is_update_event = tbase.is_update_event(event)
self.assertEqual(EntityCategory.RESOURCE, vertex[VProps.CATEGORY]) 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' id_field_path = 'volume_id' if is_update_event else 'id'
self.assertEqual( self.assertEqual(
tbase.extract_field_value(event, id_field_path), tbase.extract_field_value(event, id_field_path),
vertex[VProps.ID]) vertex[VProps.ID])
self.assertEqual(event[SyncProps.SAMPLE_DATE], self.assertEqual(event[DSProps.SAMPLE_DATE],
vertex[VProps.SAMPLE_TIMESTAMP]) vertex[VProps.SAMPLE_TIMESTAMP])
name_field_path = 'display_name' name_field_path = 'display_name'

View File

@ -35,7 +35,7 @@ class TestNagiosConfig(base.BaseTest):
required=True), required=True),
cfg.StrOpt('driver', cfg.StrOpt('driver',
default='vitrage.datasources.nagios.driver.NagiosDriver', default='vitrage.datasources.nagios.driver.NagiosDriver',
help='Nagios plugin synchronizer class path', help='Nagios driver class path',
required=True), required=True),
cfg.IntOpt('changes_interval', cfg.IntOpt('changes_interval',
default=30, default=30,

View File

@ -14,10 +14,10 @@
from oslo_log import log as logging 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 EdgeLabels
from vitrage.common.constants import EntityCategory from vitrage.common.constants import EntityCategory
from vitrage.common.constants import EventAction 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 SyncMode
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.datasources.alarm_properties import AlarmProperties as AlarmProps from vitrage.datasources.alarm_properties import AlarmProperties as AlarmProps
@ -62,7 +62,7 @@ class NagiosTransformerTest(base.BaseTest):
TransformerBase.KEY_SEPARATOR) TransformerBase.KEY_SEPARATOR)
self.assertEqual(EntityCategory.ALARM, observed_key_fields[0]) 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], self.assertEqual(event[NagiosProperties.RESOURCE_NAME],
observed_key_fields[2]) observed_key_fields[2])
self.assertEqual(event[NagiosProperties.SERVICE], self.assertEqual(event[NagiosProperties.SERVICE],
@ -92,7 +92,7 @@ class NagiosTransformerTest(base.BaseTest):
self._validate_action(alarm, wrapper) self._validate_action(alarm, wrapper)
def _validate_action(self, 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 sync_mode in (SyncMode.SNAPSHOT, SyncMode.UPDATE):
if alarm[NagiosProperties.STATUS] == 'OK': if alarm[NagiosProperties.STATUS] == 'OK':
self.assertEqual(EventAction.DELETE_ENTITY, wrapper.action) self.assertEqual(EventAction.DELETE_ENTITY, wrapper.action)
@ -104,7 +104,7 @@ class NagiosTransformerTest(base.BaseTest):
def _validate_vertex(self, vertex, event): def _validate_vertex(self, vertex, event):
self.assertEqual(EntityCategory.ALARM, vertex[VProps.CATEGORY]) 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]) self.assertEqual(event[NagiosProperties.SERVICE], vertex[VProps.NAME])
event_status = event[NagiosProperties.STATUS] event_status = event[NagiosProperties.STATUS]

View File

@ -16,10 +16,10 @@ import datetime
from oslo_log import log as logging 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 EdgeLabels
from vitrage.common.constants import EntityCategory from vitrage.common.constants import EntityCategory
from vitrage.common.constants import EventAction 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 SyncMode
from vitrage.common.constants import VertexProperties from vitrage.common.constants import VertexProperties
from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
@ -124,7 +124,7 @@ class NovaHostTransformerTest(base.BaseTest):
self.assertEqual(1, len(neighbors)) self.assertEqual(1, len(neighbors))
self._validate_zone_neighbor(neighbors[0], event) 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) self.assertEqual(EventAction.UPDATE_ENTITY, wrapper.action)
else: else:
self.assertEqual(EventAction.CREATE_ENTITY, wrapper.action) self.assertEqual(EventAction.CREATE_ENTITY, wrapper.action)
@ -132,7 +132,7 @@ class NovaHostTransformerTest(base.BaseTest):
def _validate_zone_neighbor(self, zone, event): def _validate_zone_neighbor(self, zone, event):
zone_name = tbase.extract_field_value(event, 'zone') zone_name = tbase.extract_field_value(event, 'zone')
time = event[SyncProps.SAMPLE_DATE] time = event[DSProps.SAMPLE_DATE]
zt = self.transformers[NOVA_ZONE_DATASOURCE] zt = self.transformers[NOVA_ZONE_DATASOURCE]
properties = { properties = {
@ -169,7 +169,7 @@ class NovaHostTransformerTest(base.BaseTest):
vertex[VertexProperties.TYPE] vertex[VertexProperties.TYPE]
) )
expected_timestamp = event[SyncProps.SAMPLE_DATE] expected_timestamp = event[DSProps.SAMPLE_DATE]
observed_timestamp = vertex[VertexProperties.SAMPLE_TIMESTAMP] observed_timestamp = vertex[VertexProperties.SAMPLE_TIMESTAMP]
self.assertEqual(expected_timestamp, observed_timestamp) self.assertEqual(expected_timestamp, observed_timestamp)
@ -191,7 +191,7 @@ class NovaHostTransformerTest(base.BaseTest):
zone_num=1, zone_num=1,
host_num=1, host_num=1,
snapshot_events=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) hosts_events = mock_sync.generate_random_events_list(spec_list)
host_transformer = HostTransformer(self.transformers) host_transformer = HostTransformer(self.transformers)
@ -207,7 +207,7 @@ class NovaHostTransformerTest(base.BaseTest):
zone_num=1, zone_num=1,
host_num=1, host_num=1,
snapshot_events=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) hosts_events = mock_sync.generate_random_events_list(spec_list)
host_transformer = HostTransformer(self.transformers) host_transformer = HostTransformer(self.transformers)

View File

@ -16,10 +16,10 @@ import datetime
from oslo_log import log as logging 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 EdgeLabels
from vitrage.common.constants import EntityCategory from vitrage.common.constants import EntityCategory
from vitrage.common.constants import EventAction 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 SyncMode
from vitrage.common.constants import VertexProperties from vitrage.common.constants import VertexProperties
from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
@ -109,7 +109,7 @@ class NovaInstanceTransformerTest(base.BaseTest):
host_neighbor = wrapper.neighbors[0] host_neighbor = wrapper.neighbors[0]
self._validate_host_neighbor(host_neighbor, event) 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: if sync_mode == SyncMode.INIT_SNAPSHOT:
self.assertEqual(EventAction.CREATE_ENTITY, wrapper.action) self.assertEqual(EventAction.CREATE_ENTITY, wrapper.action)
elif sync_mode == SyncMode.SNAPSHOT: elif sync_mode == SyncMode.SNAPSHOT:
@ -138,7 +138,7 @@ class NovaInstanceTransformerTest(base.BaseTest):
self.assertEqual(1, len(neighbors)) self.assertEqual(1, len(neighbors))
self._validate_host_neighbor(neighbors[0], event) 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': if event_type == 'compute.instance.delete.end':
self.assertEqual(EventAction.DELETE_ENTITY, wrapper.action) self.assertEqual(EventAction.DELETE_ENTITY, wrapper.action)
elif event_type == 'compute.instance.create.start': elif event_type == 'compute.instance.create.start':
@ -175,7 +175,7 @@ class NovaInstanceTransformerTest(base.BaseTest):
observed_state = vertex[VertexProperties.STATE] observed_state = vertex[VertexProperties.STATE]
self.assertEqual(expected_state, observed_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] observed_timestamp = vertex[VertexProperties.SAMPLE_TIMESTAMP]
self.assertEqual(expected_timestamp, observed_timestamp) self.assertEqual(expected_timestamp, observed_timestamp)
@ -197,7 +197,7 @@ class NovaInstanceTransformerTest(base.BaseTest):
name = 'host' if tbase.is_update_event(event) \ name = 'host' if tbase.is_update_event(event) \
else 'OS-EXT-SRV-ATTR:host' else 'OS-EXT-SRV-ATTR:host'
host_name = tbase.extract_field_value(event, name) host_name = tbase.extract_field_value(event, name)
time = event[SyncProps.SAMPLE_DATE] time = event[DSProps.SAMPLE_DATE]
ht = self.transformers[NOVA_HOST_DATASOURCE] ht = self.transformers[NOVA_HOST_DATASOURCE]
properties = { properties = {

View File

@ -16,9 +16,9 @@ import datetime
from oslo_log import log as logging 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 EdgeLabels
from vitrage.common.constants import EntityCategory from vitrage.common.constants import EntityCategory
from vitrage.common.constants import SynchronizerProperties as SyncProps
from vitrage.common.constants import VertexProperties from vitrage.common.constants import VertexProperties
from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
from vitrage.datasources.nova.host.transformer import HostTransformer from vitrage.datasources.nova.host.transformer import HostTransformer
@ -143,7 +143,7 @@ class NovaZoneTransformerTest(base.BaseTest):
self._validate_host_neighbor(neighbor, self._validate_host_neighbor(neighbor,
zone_vertex_id, zone_vertex_id,
hosts, hosts,
event[SyncProps.SYNC_MODE]) event[DSProps.SYNC_MODE])
self.assertEqual(1, self.assertEqual(1,
node_neighbors_counter, node_neighbors_counter,
@ -218,7 +218,7 @@ class NovaZoneTransformerTest(base.BaseTest):
self.assertEqual(NOVA_ZONE_DATASOURCE, self.assertEqual(NOVA_ZONE_DATASOURCE,
vertex[VertexProperties.TYPE]) vertex[VertexProperties.TYPE])
expected_timestamp = event[SyncProps.SAMPLE_DATE] expected_timestamp = event[DSProps.SAMPLE_DATE]
observed_timestamp = vertex[VertexProperties.SAMPLE_TIMESTAMP] observed_timestamp = vertex[VertexProperties.SAMPLE_TIMESTAMP]
self.assertEqual(expected_timestamp, observed_timestamp) self.assertEqual(expected_timestamp, observed_timestamp)

View File

@ -17,8 +17,8 @@ import os
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging 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 EventAction
from vitrage.common.constants import SynchronizerProperties as SyncProps
from vitrage.common.constants import SyncMode from vitrage.common.constants import SyncMode
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.common import file_utils from vitrage.common import file_utils
@ -119,7 +119,7 @@ class TestStaticPhysicalDriver(base.BaseTest):
status = any(change[VProps.TYPE] == SWITCH and status = any(change[VProps.TYPE] == SWITCH and
change[VProps.ID] == '23456' and change[VProps.ID] == '23456' and
change[SyncProps.EVENT_TYPE] == EventAction.DELETE_ENTITY change[DSProps.EVENT_TYPE] == EventAction.DELETE_ENTITY
for change in changes) for change in changes)
self.assertEqual(True, status) self.assertEqual(True, status)

View File

@ -16,9 +16,9 @@ import datetime
from oslo_log import log as logging 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 EdgeLabels
from vitrage.common.constants import EntityCategory 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.constants import VertexProperties as VProps
from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
from vitrage.datasources.nova.host.transformer import HostTransformer from vitrage.datasources.nova.host.transformer import HostTransformer
@ -166,7 +166,7 @@ class TestStaticPhysicalTransformer(base.BaseTest):
def _validate_switch_vertex_props(self, vertex, event): def _validate_switch_vertex_props(self, vertex, event):
self._validate_common_vertex_props(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]) vertex[VProps.SAMPLE_TIMESTAMP])
self.assertEqual(event[VProps.NAME], vertex[VProps.NAME]) self.assertEqual(event[VProps.NAME], vertex[VProps.NAME])
self.assertEqual(event[VProps.STATE], vertex[VProps.STATE]) self.assertEqual(event[VProps.STATE], vertex[VProps.STATE])

View File

@ -14,8 +14,8 @@
from oslo_config import cfg from oslo_config import cfg
from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import EntityCategory from vitrage.common.constants import EntityCategory
from vitrage.common.constants import SynchronizerProperties as SyncProps
from vitrage.common.constants import SyncMode from vitrage.common.constants import SyncMode
from vitrage.common.datetime_utils import utcnow from vitrage.common.datetime_utils import utcnow
from vitrage.datasources.nagios import NAGIOS_DATASOURCE from vitrage.datasources.nagios import NAGIOS_DATASOURCE
@ -81,17 +81,17 @@ class TestEntityGraphUnitBase(base.BaseTest):
self.NUM_ZONES, self.NUM_ZONES,
self.NUM_HOSTS, self.NUM_HOSTS,
snapshot_events=self.NUM_ZONES, 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( gen_list += mock_sync.simple_host_generators(
self.NUM_ZONES, self.NUM_ZONES,
self.NUM_HOSTS, self.NUM_HOSTS,
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( gen_list += mock_sync.simple_instance_generators(
self.NUM_HOSTS, self.NUM_HOSTS,
self.NUM_INSTANCES, self.NUM_INSTANCES,
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) 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, sync_mode=None,
@ -122,10 +122,10 @@ class TestEntityGraphUnitBase(base.BaseTest):
# update properties # update properties
if sync_mode is not None: 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: 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: if properties is not None:
for key, value in properties.items(): for key, value in properties.items():

View File

@ -16,8 +16,8 @@ import unittest
from oslo_config import cfg from oslo_config import cfg
from vitrage.common.constants import DatasourceProperties as DSProps
from vitrage.common.constants import EventAction 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 SyncMode
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.common.datetime_utils import utcnow from vitrage.common.datetime_utils import utcnow
@ -63,16 +63,16 @@ class TestProcessor(TestEntityGraphUnitBase):
# check update instance even # check update instance even
# TODO(Alexey): Create an event in update event structure # TODO(Alexey): Create an event in update event structure
# (update snapshot fields won't work) # (update snapshot fields won't work)
event[SyncProps.SYNC_MODE] = SyncMode.UPDATE event[DSProps.SYNC_MODE] = SyncMode.UPDATE
event[SyncProps.EVENT_TYPE] = 'compute.instance.volume.attach' event[DSProps.EVENT_TYPE] = 'compute.instance.volume.attach'
event['hostname'] = 'new_host' event['hostname'] = 'new_host'
processor.process_event(event) processor.process_event(event)
self._check_graph(processor, self.NUM_VERTICES_AFTER_CREATION, self._check_graph(processor, self.NUM_VERTICES_AFTER_CREATION,
self.NUM_EDGES_AFTER_CREATION) self.NUM_EDGES_AFTER_CREATION)
# check delete instance event # check delete instance event
event[SyncProps.SYNC_MODE] = SyncMode.UPDATE event[DSProps.SYNC_MODE] = SyncMode.UPDATE
event[SyncProps.EVENT_TYPE] = 'compute.instance.delete.end' event[DSProps.EVENT_TYPE] = 'compute.instance.delete.end'
processor.process_event(event) processor.process_event(event)
self._check_graph(processor, self.NUM_VERTICES_AFTER_DELETION, self._check_graph(processor, self.NUM_VERTICES_AFTER_DELETION,
self.NUM_EDGES_AFTER_DELETION) self.NUM_EDGES_AFTER_DELETION)