rename refactor - replace 'synchronizer' and 'plugin' to 'datasource' and 'driver'

Change-Id: I582bb6d1ab42c7dd9f38956bc043d09c04edbf88
This commit is contained in:
liathartal 2016-04-06 12:44:58 +00:00
parent f3245ae4cc
commit f6d367b693
144 changed files with 1071 additions and 1213 deletions

View File

@ -100,14 +100,14 @@ function cleanup_vitrage {
fi fi
} }
function disable_vitrage_plugin { function disable_vitrage_datasource {
local enabled_plugins=",${VITRAGE_DEFAULT_PLUGINS}," local enabled_datasources=",${VITRAGE_DEFAULT_DATASOURCES},"
local plugin local datasource
for plugin in $@; do for datasource in $@; do
enabled_plugins=${enabled_plugins//,$plugin,/,} enabled_datasources=${enabled_datasources//,$datasource,/,}
done done
VITRAGE_DEFAULT_PLUGINS=$(_cleanup_service_list "$enabled_plugins") VITRAGE_DEFAULT_DATSOURCES=$(_cleanup_service_list "$enabled_datasources")
} }
@ -134,29 +134,29 @@ function configure_vitrage {
iniset $VITRAGE_CONF service_credentials region_name $REGION_NAME iniset $VITRAGE_CONF service_credentials region_name $REGION_NAME
iniset $VITRAGE_CONF service_credentials auth_url $KEYSTONE_SERVICE_URI iniset $VITRAGE_CONF service_credentials auth_url $KEYSTONE_SERVICE_URI
# add default plugins # add default datasources
iniset $VITRAGE_CONF plugins plugin_type $VITRAGE_DEFAULT_PLUGINS iniset $VITRAGE_CONF datasources types $VITRAGE_DEFAULT_DATASOURCES
# remove neutron vitrage plugin if neutron plugin not installed # remove neutron vitrage datasource if neutron datasource not installed
if ! is_service_enabled neutron; then if ! is_service_enabled neutron; then
disable_vitrage_plugin neutron.network neutron.port disable_vitrage_datasource neutron.network neutron.port
fi fi
# remove aodh vitrage plugin if aodh plugin not installed # remove aodh vitrage datasource if aodh datasource not installed
if ! is_service_enabled aodh; then if ! is_service_enabled aodh; then
disable_vitrage_plugin aodh disable_vitrage_datasource aodh
fi fi
# copy the mock sample files # copy the mock sample files
cp $VITRAGE_DIR/etc/vitrage/*.sample.json $VITRAGE_CONF_DIR cp $VITRAGE_DIR/etc/vitrage/*.sample.json $VITRAGE_CONF_DIR
# create some folders # create some folders
mkdir -p $VITRAGE_CONF_DIR/states_plugins mkdir -p $VITRAGE_CONF_DIR/datasources_states
mkdir -p $VITRAGE_CONF_DIR/static_plugins mkdir -p $VITRAGE_CONF_DIR/static_datasources
mkdir -p $VITRAGE_CONF_DIR/templates mkdir -p $VITRAGE_CONF_DIR/templates
# copy plugins # copy datasources
cp $VITRAGE_DIR/etc/vitrage/states_plugins/*.yaml $VITRAGE_CONF_DIR/states_plugins cp $VITRAGE_DIR/etc/vitrage/datasources_states/*.yaml $VITRAGE_CONF_DIR/datasources_states
configure_auth_token_middleware $VITRAGE_CONF vitrage $VITRAGE_AUTH_CACHE_DIR configure_auth_token_middleware $VITRAGE_CONF vitrage $VITRAGE_AUTH_CACHE_DIR

View File

@ -20,8 +20,7 @@ VITRAGE_SERVICE_PROTOCOL=http
VITRAGE_SERVICE_HOST=$SERVICE_HOST VITRAGE_SERVICE_HOST=$SERVICE_HOST
VITRAGE_SERVICE_PORT=${VITRAGE_SERVICE_PORT:-8999} VITRAGE_SERVICE_PORT=${VITRAGE_SERVICE_PORT:-8999}
VITRAGE_USE_MOD_WSGI=${VITRAGE_USE_MOD_WSGI:-${ENABLE_HTTPD_MOD_WSGI_SERVICES}} VITRAGE_USE_MOD_WSGI=${VITRAGE_USE_MOD_WSGI:-${ENABLE_HTTPD_MOD_WSGI_SERVICES}}
VITRAGE_DEFAULT_PLUGINS=${VITRAGE_DEFAULT_PLUGINS:-nova.host,nova.instance, VITRAGE_DEFAULT_DATASOURCES=${VITRAGE_DEFAULT_DATASOURCES:-nova.host,nova.instance,nova.zone,nagios,static_physical,aodh,cinder.volume,neutron.network,neutron.port}
nova.zone,nagios,static_physical,aodh,cinder.volume,neutron.network,neutron.port}
# Tell Tempest this project is present # Tell Tempest this project is present

View File

@ -2,7 +2,7 @@
output_file = etc/vitrage/vitrage.conf output_file = etc/vitrage/vitrage.conf
wrap_width = 79 wrap_width = 79
namespace = vitrage namespace = vitrage
namespace = plugins namespace = datasources
namespace = oslo.db namespace = oslo.db
namespace = oslo.log namespace = oslo.log
namespace = oslo.middleware namespace = oslo.middleware

View File

@ -112,16 +112,16 @@
[aodh] [aodh]
# #
# From plugins # From datasources
# #
# Aodh plugin transformer class path (string value) # Aodh plugin transformer class path (string value)
#transformer = vitrage.synchronizer.plugins.aodh.transformer.AodhTransformer #transformer = vitrage.datasources.aodh.transformer.AodhTransformer
# Aodh plugin synchronizer class path (string value) # Aodh plugin synchronizer class path (string value)
#synchronizer = vitrage.synchronizer.plugins.aodh.synchronizer.AodhSynchronizer #synchronizer = vitrage.datasources.aodh.driver.AodhDriver
# interval between checking changes in aodh plugin (integer value) # interval between checking changes in aodh datasource (integer value)
# Minimum value: 30 # Minimum value: 30
#changes_interval = 30 #changes_interval = 30
@ -165,12 +165,12 @@
#min_time_to_delete = 60 #min_time_to_delete = 60
# interval between consistency initialization checks for finding if all end # interval between consistency initialization checks for finding if all end
# messages from plugins were received (in seconds) (integer value) # messages from data sources were received (in seconds) (integer value)
# Minimum value: 1 # Minimum value: 1
#initialization_interval = 3 #initialization_interval = 3
# maximum retries for consistency initialization for finding if all end # maximum retries for consistency initialization for finding if all end
# messages from plugins were received (in seconds) (integer value) # messages from data sources were received (in seconds) (integer value)
# Minimum value: 1 # Minimum value: 1
#initialization_max_retries = 30 #initialization_max_retries = 30
@ -237,8 +237,8 @@
# From vitrage # From vitrage
# #
# A path for the configuration files of the plugins states (string value) # A path for the configuration files of the data sources states (string value)
#states_plugins_dir = /etc/vitrage/states_plugins #states_plugins_dir = /etc/vitrage/datasources_states
[evaluator] [evaluator]
@ -392,16 +392,16 @@
[nagios] [nagios]
# #
# From plugins # From datasources
# #
# Nagios plugin transformer class path (string value) # Nagios plugin transformer class path (string value)
#transformer = vitrage.synchronizer.plugins.nagios.transformer.NagiosTransformer #transformer = vitrage.datasources.nagios.transformer.NagiosTransformer
# Nagios plugin synchronizer class path (string value) # Nagios plugin driver class path (string value)
#synchronizer = vitrage.synchronizer.plugins.nagios.synchronizer.NagiosSynchronizer #synchronizer = vitrage.datasources.nagios.driver.NagiosDriver
# interval between checking changes in nagios plugin (integer value) # interval between checking changes in nagios datasource (integer value)
# Minimum value: 30 # Minimum value: 30
#changes_interval = 30 #changes_interval = 30
@ -421,40 +421,40 @@
[nova.host] [nova.host]
# #
# From plugins # From datasources
# #
# Nova host transformer class path (string value) # Nova host transformer class path (string value)
#transformer = vitrage.synchronizer.plugins.nova.host.transformer.HostTransformer #transformer = vitrage.datasources.nova.host.transformer.HostTransformer
# Nova host synchronizer class path (string value) # Nova host driver class path (string value)
#synchronizer = vitrage.synchronizer.plugins.nova.host.synchronizer.HostSynchronizer #synchronizer = vitrage.datasources.nova.host.driver.HostDriver
[nova.instance] [nova.instance]
# #
# From plugins # From datasources
# #
# Nova instance transformer class path (string value) # Nova instance transformer class path (string value)
#transformer = vitrage.synchronizer.plugins.nova.instance.transformer.InstanceTransformer #transformer = vitrage.datasources.nova.instance.transformer.InstanceTransformer
# Nova instance synchronizer class path (string value) # Nova instance driver class path (string value)
#synchronizer = vitrage.synchronizer.plugins.nova.instance.synchronizer.InstanceSynchronizer #synchronizer = vitrage.datasources.nova.instance.driver.InstanceDriver
[nova.zone] [nova.zone]
# #
# From plugins # From datasources
# #
# Nova zone transformer class path (string value) # Nova zone transformer class path (string value)
#transformer = vitrage.synchronizer.plugins.nova.zone.transformer.ZoneTransformer #transformer = vitrage.datasources.nova.zone.transformer.ZoneTransformer
# Nova zone synchronizer class path (string value) # Nova zone driver class path (string value)
#synchronizer = vitrage.synchronizer.plugins.nova.zone.synchronizer.ZoneSynchronizer #synchronizer = vitrage.datasources.nova.zone.driver.ZoneDriver
[oslo_middleware] [oslo_middleware]

View File

@ -20,7 +20,7 @@ import pecan as pecan
from pecan import abort from pecan import abort
from pecan import rest from pecan import rest
from vitrage.synchronizer.plugins import OPENSTACK_NODE from vitrage.datasources import OPENSTACK_NODE
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)

View File

@ -19,6 +19,8 @@ import sys
from oslo_service import service as os_service from oslo_service import service as os_service
from vitrage.common.constants import EntityCategory from vitrage.common.constants import EntityCategory
from vitrage.datasources import launcher as datasource_launcher
from vitrage.datasources import OPENSTACK_NODE
from vitrage.entity_graph.api_handler import service as api_handler_svc from vitrage.entity_graph.api_handler import service as api_handler_svc
from vitrage.entity_graph.consistency import service as consistency_svc from vitrage.entity_graph.consistency import service as consistency_svc
from vitrage.entity_graph.initialization_status import InitializationStatus from vitrage.entity_graph.initialization_status import InitializationStatus
@ -27,8 +29,6 @@ from vitrage.entity_graph import service as entity_graph_svc
from vitrage.evaluator.scenario_evaluator import ScenarioEvaluator from vitrage.evaluator.scenario_evaluator import ScenarioEvaluator
from vitrage.evaluator.scenario_repository import ScenarioRepository from vitrage.evaluator.scenario_repository import ScenarioRepository
from vitrage import service from vitrage import service
from vitrage.synchronizer import launcher as synchronizers_launcher
from vitrage.synchronizer.plugins import OPENSTACK_NODE
def main(): def main():
@ -42,9 +42,9 @@ def main():
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 = synchronizers_launcher.Launcher( synchronizers = datasource_launcher.Launcher(
conf, conf,
synchronizers_launcher.create_send_to_queue_callback(event_queue)) datasource_launcher.create_send_to_queue_callback(event_queue))
launcher.launch_service(entity_graph_svc.VitrageGraphService( launcher.launch_service(entity_graph_svc.VitrageGraphService(
conf, event_queue, evaluator, e_graph, initialization_status)) conf, event_queue, evaluator, e_graph, initialization_status))

View File

@ -0,0 +1,48 @@
# Copyright 2016 - Nokia
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# 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 oslo_config import cfg
from vitrage.datasources.aodh import AODH_DATASOURCE
from vitrage.datasources.cinder.volume import CINDER_VOLUME_DATASOURCE
from vitrage.datasources.nagios import NAGIOS_DATASOURCE
from vitrage.datasources.neutron.network import NEUTRON_NETWORK_DATASOURCE
from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
from vitrage.datasources.nova.instance import NOVA_INSTANCE_DATASOURCE
from vitrage.datasources.nova.zone import NOVA_ZONE_DATASOURCE
from vitrage.datasources.static_physical import STATIC_PHYSICAL_DATASOURCE
OPENSTACK_NODE = 'openstack.node'
# Register options for the service
OPTS = [
cfg.ListOpt('types',
default=[NOVA_HOST_DATASOURCE,
NOVA_INSTANCE_DATASOURCE,
NOVA_ZONE_DATASOURCE,
NAGIOS_DATASOURCE,
STATIC_PHYSICAL_DATASOURCE,
AODH_DATASOURCE,
CINDER_VOLUME_DATASOURCE,
NEUTRON_NETWORK_DATASOURCE],
help='Names of supported data sources'),
cfg.ListOpt('path',
default=['vitrage.datasources'],
help='base path for data sources'),
cfg.IntOpt('snapshots_interval',
default=600,
min=10,
help='interval between full snapshots')
]

View File

@ -13,14 +13,15 @@
# under the License. # under the License.
from oslo_log import log from oslo_log import log
from vitrage.synchronizer.plugins.synchronizer_base import SynchronizerBase
from vitrage.datasources.driver_base import DriverBase
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
class BaseAlarmSynchronizer(SynchronizerBase): class AlarmDriverBase(DriverBase):
def __init__(self): def __init__(self):
super(SynchronizerBase, self).__init__() super(DriverBase, self).__init__()
self.cache = dict() self.cache = dict()
def _sync_type(self): def _sync_type(self):
@ -83,14 +84,14 @@ class BaseAlarmSynchronizer(SynchronizerBase):
self._enrich_alarms(alarms) self._enrich_alarms(alarms)
return self._filter_and_cache_alarms( return self._filter_and_cache_alarms(
alarms, alarms,
BaseAlarmSynchronizer._filter_get_all) AlarmDriverBase._filter_get_all)
def _get_changed_alarms(self): def _get_changed_alarms(self):
alarms = self._get_alarms() alarms = self._get_alarms()
self._enrich_alarms(alarms) self._enrich_alarms(alarms)
return self._filter_and_cache_alarms( return self._filter_and_cache_alarms(
alarms, alarms,
BaseAlarmSynchronizer._filter_get_changes) AlarmDriverBase._filter_get_changes)
def _filter_and_cache_alarms(self, alarms, filter_): def _filter_and_cache_alarms(self, alarms, filter_):
alarms_to_update = [] alarms_to_update = []

View File

@ -19,12 +19,12 @@ from vitrage.common.constants import EventAction
from vitrage.common.constants import SynchronizerProperties as SyncProps 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.synchronizer.plugins import transformer_base as tbase from vitrage.datasources import transformer_base as tbase
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class BaseAlarmTransformer(tbase.TransformerBase): class AlarmTransformerBase(tbase.TransformerBase):
def __init__(self, transformers): def __init__(self, transformers):
self.transformers = transformers self.transformers = transformers

View File

@ -14,22 +14,21 @@
from oslo_config import cfg from oslo_config import cfg
AODH_PLUGIN = 'aodh' AODH_DATASOURCE = 'aodh'
OPTS = [ OPTS = [
cfg.StrOpt('transformer', cfg.StrOpt('transformer',
default='vitrage.synchronizer.plugins.aodh.' default='vitrage.datasources.aodh.'
'transformer.AodhTransformer', 'transformer.AodhTransformer',
help='Aodh plugin transformer class path', help='Aodh transformer class path',
required=True), required=True),
cfg.StrOpt('synchronizer', cfg.StrOpt('driver',
default='vitrage.synchronizer.plugins.aodh.synchronizer' default='vitrage.datasources.aodh.driver.AodhDriver',
'.AodhSynchronizer', help='Aodh driver class path',
help='Aodh plugin synchronizer class path',
required=True), required=True),
cfg.IntOpt('changes_interval', cfg.IntOpt('changes_interval',
default=30, default=30,
min=30, min=30,
help='interval between checking changes in aodh plugin', help='interval between checking changes in aodh data source',
required=True), required=True),
] ]

View File

@ -15,23 +15,21 @@
from oslo_log import log from oslo_log import log
from vitrage import clients from vitrage import clients
from vitrage.synchronizer.plugins.aodh import AODH_PLUGIN from vitrage.datasources.alarm_driver_base import AlarmDriverBase
from vitrage.synchronizer.plugins.aodh.properties import AodhProperties \ from vitrage.datasources.aodh import AODH_DATASOURCE
as AodhProps from vitrage.datasources.aodh.properties import AodhProperties as AodhProps
from vitrage.synchronizer.plugins.aodh.properties import AodhState from vitrage.datasources.aodh.properties import AodhState
from vitrage.synchronizer.plugins.base.alarm.synchronizer \
import BaseAlarmSynchronizer
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
class AodhSynchronizer(BaseAlarmSynchronizer): class AodhDriver(AlarmDriverBase):
def __init__(self, conf): def __init__(self, conf):
super(AodhSynchronizer, self).__init__() super(AodhDriver, self).__init__()
self.client = clients.ceilometer_client(conf) self.client = clients.ceilometer_client(conf)
def _sync_type(self): def _sync_type(self):
return AODH_PLUGIN return AODH_DATASOURCE
def _alarm_key(self, alarm): def _alarm_key(self, alarm):
return alarm[AodhProps.NAME] return alarm[AodhProps.NAME]
@ -60,19 +58,19 @@ class AodhSynchronizer(BaseAlarmSynchronizer):
@staticmethod @staticmethod
def _convert_event_alarm(alarm): def _convert_event_alarm(alarm):
converted_alarm = AodhSynchronizer._convert_base_alarm(alarm) converted_alarm = AodhDriver._convert_base_alarm(alarm)
event_type, resource_id = \ event_type, resource_id = \
AodhSynchronizer._parse_event_rule(alarm.event_rule) AodhDriver._parse_event_rule(alarm.event_rule)
converted_alarm[AodhProps.EVENT_TYPE] = event_type converted_alarm[AodhProps.EVENT_TYPE] = event_type
converted_alarm[AodhProps.RESOURCE_ID] = resource_id converted_alarm[AodhProps.RESOURCE_ID] = resource_id
return converted_alarm return converted_alarm
@staticmethod @staticmethod
def _convert_threshold_alarm(alarm): def _convert_threshold_alarm(alarm):
converted_alarm = AodhSynchronizer._convert_base_alarm(alarm) converted_alarm = AodhDriver._convert_base_alarm(alarm)
converted_alarm[AodhProps.STATE_TIMESTAMP] = alarm.state_timestamp converted_alarm[AodhProps.STATE_TIMESTAMP] = alarm.state_timestamp
converted_alarm[AodhProps.RESOURCE_ID] = \ converted_alarm[AodhProps.RESOURCE_ID] = \
AodhSynchronizer._parse_threshold_rule(alarm.threshold_rule) AodhDriver._parse_threshold_rule(alarm.threshold_rule)
return converted_alarm return converted_alarm
@staticmethod @staticmethod
@ -96,12 +94,12 @@ class AodhSynchronizer(BaseAlarmSynchronizer):
def _parse_event_rule(rule): def _parse_event_rule(rule):
event_type = rule[AodhProps.EVENT_TYPE] event_type = rule[AodhProps.EVENT_TYPE]
resource_id = \ resource_id = \
AodhSynchronizer._parse_resource_id(rule[AodhProps.QUERY]) AodhDriver._parse_resource_id(rule[AodhProps.QUERY])
return event_type, resource_id return event_type, resource_id
@staticmethod @staticmethod
def _parse_threshold_rule(rule): def _parse_threshold_rule(rule):
return AodhSynchronizer._parse_resource_id(rule[AodhProps.QUERY]) return AodhDriver._parse_resource_id(rule[AodhProps.QUERY])
@staticmethod @staticmethod
def _parse_resource_id(query_fields): def _parse_resource_id(query_fields):
@ -116,8 +114,8 @@ class AodhSynchronizer(BaseAlarmSynchronizer):
def _convert_alarm(alarm): def _convert_alarm(alarm):
alarm_type = alarm.type alarm_type = alarm.type
if alarm_type == AodhProps.EVENT: if alarm_type == AodhProps.EVENT:
return AodhSynchronizer._convert_event_alarm(alarm) return AodhDriver._convert_event_alarm(alarm)
elif alarm_type == AodhProps.THRESHOLD: elif alarm_type == AodhProps.THRESHOLD:
return AodhSynchronizer._convert_threshold_alarm(alarm) return AodhDriver._convert_threshold_alarm(alarm)
else: else:
LOG.info('Unsupported Aodh alarm of type %s' % alarm_type) LOG.info('Unsupported Aodh alarm of type %s' % alarm_type)

View File

@ -18,20 +18,17 @@ from vitrage.common.constants import EntityCategory
from vitrage.common.constants import SynchronizerProperties as SyncProps 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_transformer_base import AlarmTransformerBase
from vitrage.datasources.aodh.properties import AodhProperties as AodhProps
from vitrage.datasources import transformer_base as tbase
from vitrage.datasources.transformer_base import Neighbor
import vitrage.graph.utils as graph_utils import vitrage.graph.utils as graph_utils
from vitrage.synchronizer.plugins.aodh.properties import AodhProperties \
as AodhProps
from vitrage.synchronizer.plugins.base.alarm.properties \
import AlarmProperties as AlarmProps
from vitrage.synchronizer.plugins.base.alarm.transformer \
import BaseAlarmTransformer
from vitrage.synchronizer.plugins import transformer_base as tbase
from vitrage.synchronizer.plugins.transformer_base import Neighbor
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class AodhTransformer(BaseAlarmTransformer): class AodhTransformer(AlarmTransformerBase):
STATUS_OK = 'ok' STATUS_OK = 'ok'

View File

@ -14,18 +14,18 @@
from oslo_config import cfg from oslo_config import cfg
CINDER_VOLUME_PLUGIN = 'cinder.volume' CINDER_VOLUME_DATASOURCE = 'cinder.volume'
OPTS = [ OPTS = [
cfg.StrOpt('transformer', cfg.StrOpt('transformer',
default='vitrage.synchronizer.plugins.cinder.volume.' default='vitrage.datasources.cinder.volume.transformer.'
'transformer.CinderVolumeTransformer', 'CinderVolumeTransformer',
help='Nova host transformer class path', help='Nova host transformer class path',
required=True), required=True),
cfg.StrOpt('synchronizer', cfg.StrOpt('driver',
default='vitrage.synchronizer.plugins.cinder.volume.' default='vitrage.datasources.cinder.volume.driver.'
'synchronizer.CinderVolumeSynchronizer', 'CinderVolumeDriver',
help='Nova host synchronizer class path', help='Nova host driver class path',
required=True), required=True),
cfg.StrOpt('notification_topic', cfg.StrOpt('notification_topic',
default='vitrage_notifications', default='vitrage_notifications',

View File

@ -17,16 +17,16 @@ 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 SynchronizerProperties as SyncProps
from vitrage.common.constants import SyncMode from vitrage.common.constants import SyncMode
from vitrage.synchronizer.plugins.cinder.volume import CINDER_VOLUME_PLUGIN from vitrage.datasources.cinder.volume import CINDER_VOLUME_DATASOURCE
from vitrage.synchronizer.plugins.synchronizer_base import SynchronizerBase from vitrage.datasources.driver_base import DriverBase
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class CinderVolumeSynchronizer(SynchronizerBase): class CinderVolumeDriver(DriverBase):
def __init__(self, conf): def __init__(self, conf):
super(CinderVolumeSynchronizer, self).__init__() super(CinderVolumeDriver, self).__init__()
self.client = clients.cinder_client(conf) self.client = clients.cinder_client(conf)
self.conf = conf self.conf = conf
@ -37,15 +37,15 @@ class CinderVolumeSynchronizer(SynchronizerBase):
def get_all(self, sync_mode): def get_all(self, sync_mode):
return self.make_pickleable( return self.make_pickleable(
self.extract_events(self.client.volumes.list()), self.extract_events(self.client.volumes.list()),
CINDER_VOLUME_PLUGIN, CINDER_VOLUME_DATASOURCE,
sync_mode) sync_mode)
@staticmethod @staticmethod
def enrich_event(event, event_type): def enrich_event(event, event_type):
event[SyncProps.EVENT_TYPE] = event_type event[SyncProps.EVENT_TYPE] = event_type
return CinderVolumeSynchronizer.make_pickleable([event], return CinderVolumeDriver.make_pickleable([event],
CINDER_VOLUME_PLUGIN, CINDER_VOLUME_DATASOURCE,
SyncMode.UPDATE)[0] SyncMode.UPDATE)[0]
@staticmethod @staticmethod
@ -54,4 +54,4 @@ class CinderVolumeSynchronizer(SynchronizerBase):
@staticmethod @staticmethod
def get_topic(conf): def get_topic(conf):
return conf[CINDER_VOLUME_PLUGIN].notification_topic return conf[CINDER_VOLUME_DATASOURCE].notification_topic

View File

@ -19,21 +19,21 @@ 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 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.nova.instance import NOVA_INSTANCE_DATASOURCE
from vitrage.datasources.resource_transformer_base import \
ResourceTransformerBase
from vitrage.datasources import transformer_base as tbase
from vitrage.datasources.transformer_base import build_key
from vitrage.datasources.transformer_base import extract_field_value
from vitrage.datasources.transformer_base import Neighbor
import vitrage.graph.utils as graph_utils import vitrage.graph.utils as graph_utils
from vitrage.synchronizer.plugins.base.resource.transformer import \
BaseResourceTransformer
from vitrage.synchronizer.plugins.cinder.volume import CINDER_VOLUME_PLUGIN
from vitrage.synchronizer.plugins.nova.instance import NOVA_INSTANCE_PLUGIN
from vitrage.synchronizer.plugins import transformer_base as tbase
from vitrage.synchronizer.plugins.transformer_base import build_key
from vitrage.synchronizer.plugins.transformer_base import extract_field_value
from vitrage.synchronizer.plugins.transformer_base import Neighbor
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class CinderVolumeTransformer(BaseResourceTransformer): class CinderVolumeTransformer(ResourceTransformerBase):
# Event types which need to refer them differently # Event types which need to refer them differently
UPDATE_EVENT_TYPES = { UPDATE_EVENT_TYPES = {
@ -85,7 +85,7 @@ class CinderVolumeTransformer(BaseResourceTransformer):
entity_key, entity_key,
entity_id=volume_id, entity_id=volume_id,
entity_category=EntityCategory.RESOURCE, entity_category=EntityCategory.RESOURCE,
entity_type=CINDER_VOLUME_PLUGIN, entity_type=CINDER_VOLUME_DATASOURCE,
entity_state=volume_state, entity_state=volume_state,
sample_timestamp=sample_timestamp, sample_timestamp=sample_timestamp,
update_timestamp=update_timestamp, update_timestamp=update_timestamp,
@ -109,14 +109,14 @@ class CinderVolumeTransformer(BaseResourceTransformer):
id_field_path = 'volume_id' if is_update_event else 'id' id_field_path = 'volume_id' if is_update_event else 'id'
volume_id = extract_field_value(entity_event, id_field_path) volume_id = extract_field_value(entity_event, id_field_path)
key_fields = self._key_values(CINDER_VOLUME_PLUGIN, volume_id) key_fields = self._key_values(CINDER_VOLUME_DATASOURCE, volume_id)
return build_key(key_fields) return build_key(key_fields)
def _create_instance_neighbors(self, def _create_instance_neighbors(self,
entity_event, entity_event,
attachments_property, attachments_property,
instance_id_property): instance_id_property):
transformer = self.transformers[NOVA_INSTANCE_PLUGIN] transformer = self.transformers[NOVA_INSTANCE_DATASOURCE]
if transformer: if transformer:
return [self._create_instance_neighbor(entity_event, return [self._create_instance_neighbor(entity_event,
@ -140,7 +140,7 @@ class CinderVolumeTransformer(BaseResourceTransformer):
properties = { properties = {
VProps.ID: instance_id, VProps.ID: instance_id,
VProps.TYPE: NOVA_INSTANCE_PLUGIN, VProps.TYPE: NOVA_INSTANCE_DATASOURCE,
VProps.SAMPLE_TIMESTAMP: sample_timestamp VProps.SAMPLE_TIMESTAMP: sample_timestamp
} }
instance_vertex = \ instance_vertex = \

View File

@ -26,7 +26,7 @@ LOG = log.getLogger(__name__)
@six.add_metaclass(abc.ABCMeta) @six.add_metaclass(abc.ABCMeta)
class SynchronizerBase(object): class DriverBase(object):
def __init__(self): def __init__(self):
pass pass

View File

@ -18,7 +18,7 @@ import itertools
from oslo_log import log from oslo_log import log
from oslo_service import service as os_service from oslo_service import service as os_service
from oslo_utils import importutils as utils from oslo_utils import importutils as utils
from vitrage.synchronizer.plugins.listener_service import ListenerService from vitrage.datasources.listener_service import ListenerService
from services import ChangesService from services import ChangesService
from services import SnapshotsService from services import SnapshotsService
@ -39,7 +39,7 @@ class Launcher(object):
def __init__(self, conf, callback): def __init__(self, conf, callback):
self.conf = conf self.conf = conf
self.callback = callback self.callback = callback
self.snapshot_plugins = self._register_snapshot_plugins() self.snapshot_datasources = self._register_snapshot_datasources()
self.services = self._register_services() self.services = self._register_services()
def launch(self): def launch(self):
@ -47,25 +47,25 @@ class Launcher(object):
for service in self.services: for service in self.services:
launcher.launch_service(service, 1) launcher.launch_service(service, 1)
def _register_snapshot_plugins(self): def _register_snapshot_datasources(self):
return {plugin: utils.import_object(self.conf[plugin].synchronizer, return {plugin: utils.import_object(self.conf[plugin].driver,
self.conf) self.conf)
for plugin in self.conf.plugins.plugin_type} for plugin in self.conf.datasources.types}
def _register_services(self): def _register_services(self):
return itertools.chain( return itertools.chain(
(ChangesService(self.conf, (ChangesService(self.conf,
[self.snapshot_plugins[plugin]], [self.snapshot_datasources[plugin]],
self.conf[plugin].changes_interval, self.conf[plugin].changes_interval,
self.callback) self.callback)
for plugin in self.conf.plugins.plugin_type for plugin in self.conf.datasources.types
if opt_exists(self.conf[plugin], CHANGES_INTERVAL)), if opt_exists(self.conf[plugin], CHANGES_INTERVAL)),
(SnapshotsService(self.conf, (SnapshotsService(self.conf,
self.snapshot_plugins, self.snapshot_datasources,
self.callback),), self.callback),),
(ListenerService(self.conf, (ListenerService(self.conf,
self.snapshot_plugins, self.snapshot_datasources,
self.callback),),) self.callback),),)

View File

@ -26,34 +26,34 @@ LOG = log.getLogger(__name__)
class ListenerService(os_service.Service): class ListenerService(os_service.Service):
def __init__(self, conf, synchronizers, callback): def __init__(self, conf, drivers, callback):
super(ListenerService, self).__init__() super(ListenerService, self).__init__()
# Get the topics of the synchronizers and callbacks # Get the topics of the drivers and callbacks
topics = self._get_topics_set(synchronizers, conf) topics = self._get_topics_set(drivers, conf)
self.enrich_callbacks_by_events = \ self.enrich_callbacks_by_events = \
self._create_callbacks_by_events_dict(synchronizers, conf) self._create_callbacks_by_events_dict(drivers, conf)
self.skipped_event_types = self._get_skipped_event_types(synchronizers) self.skipped_event_types = self._get_skipped_event_types(drivers)
self.listener = self._get_topics_listener(conf, topics, callback) self.listener = self._get_topics_listener(conf, topics, callback)
def start(self): def start(self):
LOG.info("Vitrage Synchronizer Listener Service - Starting...") LOG.info("Vitrage data source Listener Service - Starting...")
super(ListenerService, self).start() super(ListenerService, self).start()
self.listener.start() self.listener.start()
LOG.info("Vitrage Synchronizer Listener Service - Started!") LOG.info("Vitrage data source Listener Service - Started!")
def stop(self, graceful=False): def stop(self, graceful=False):
LOG.info("Vitrage Synchronizer Listener Service - Stopping...") LOG.info("Vitrage data source Listener Service - Stopping...")
super(ListenerService, self).stop(graceful) super(ListenerService, self).stop(graceful)
LOG.info("Vitrage Synchronizer Listener Service - Stopped!") LOG.info("Vitrage data source Listener Service - Stopped!")
@staticmethod @staticmethod
def _get_topics_set(synchronizers, conf): def _get_topics_set(drivers, conf):
topics = {sync.get_topic(conf) for sync in synchronizers.values()} topics = {driver.get_topic(conf) for driver in drivers.values()}
if None in topics: if None in topics:
topics.remove(None) topics.remove(None)
@ -61,12 +61,12 @@ class ListenerService(os_service.Service):
return topics return topics
@staticmethod @staticmethod
def _create_callbacks_by_events_dict(synchronizers, conf): def _create_callbacks_by_events_dict(drivers, conf):
ret = defaultdict(list) ret = defaultdict(list)
for sync in synchronizers.values(): for driver in drivers.values():
for event in sync.get_event_types(conf): for event in driver.get_event_types(conf):
ret[event].append(sync.enrich_event) ret[event].append(driver.enrich_event)
return ret return ret
@ -84,10 +84,11 @@ class ListenerService(os_service.Service):
self.skipped_event_types)]) self.skipped_event_types)])
@staticmethod @staticmethod
def _get_skipped_event_types(synchronizers): def _get_skipped_event_types(drivers):
skipped_events = [] skipped_events = []
for synchronizer in synchronizers.values(): for driver in drivers.values():
skipped_events += synchronizer.get_skipped_event_types() skipped_events += driver.get_skipped_event_types()
return set(skipped_events) return set(skipped_events)
@ -104,8 +105,7 @@ class NotificationsEndpoint(object):
def info(self, ctxt, publisher_id, event_type, payload, metadata): def info(self, ctxt, publisher_id, event_type, payload, metadata):
# TODO(Alexey): improve skipped implementation because we need to skip # TODO(Alexey): improve skipped implementation because we need to skip
# event depending on the synchronizer and not for all # event depending on the drivers and not for all drivers
# synchronizers
if event_type in self.skipped_event_types: if event_type in self.skipped_event_types:
LOG.info('EVENT SKIPPED: ' + str(event_type)) LOG.info('EVENT SKIPPED: ' + str(event_type))
return return

View File

@ -14,23 +14,22 @@
from oslo_config import cfg from oslo_config import cfg
NAGIOS_PLUGIN = 'nagios' NAGIOS_DATASOURCE = 'nagios'
OPTS = [ OPTS = [
cfg.StrOpt('transformer', cfg.StrOpt('transformer',
default='vitrage.synchronizer.plugins.nagios.' default='vitrage.datasources.nagios.transformer.'
'transformer.NagiosTransformer', 'NagiosTransformer',
help='Nagios plugin transformer class path', help='Nagios transformer class path',
required=True), required=True),
cfg.StrOpt('synchronizer', cfg.StrOpt('driver',
default='vitrage.synchronizer.plugins.nagios.synchronizer' default='vitrage.datasources.nagios.driver.NagiosDriver',
'.NagiosSynchronizer', help='Nagios driver class path',
help='Nagios plugin synchronizer class path',
required=True), required=True),
cfg.IntOpt('changes_interval', cfg.IntOpt('changes_interval',
default=30, default=30,
min=30, min=30,
help='interval between checking changes in nagios plugin', help='interval between checking changes in nagios data source',
required=True), required=True),
cfg.StrOpt('user', default='nagiosadmin', cfg.StrOpt('user', default='nagiosadmin',
help='Nagios user name'), help='Nagios user name'),

View File

@ -18,32 +18,31 @@ from oslo_log import log
import requests import requests
from vitrage.common.constants import SynchronizerProperties as SyncProps from vitrage.common.constants import SynchronizerProperties as SyncProps
from vitrage.datasources.alarm_driver_base import AlarmDriverBase
from vitrage.datasources.nagios.config import NagiosConfig
from vitrage.datasources.nagios import NAGIOS_DATASOURCE
from vitrage.datasources.nagios.parser import NagiosParser
from vitrage.datasources.nagios.properties import NagiosProperties\
as NagiosProps
from vitrage.datasources.nagios.properties import NagiosStatus
# noinspection PyProtectedMember # noinspection PyProtectedMember
from vitrage.i18n import _LE from vitrage.i18n import _LE
# noinspection PyProtectedMember # noinspection PyProtectedMember
from vitrage.i18n import _LW from vitrage.i18n import _LW
from vitrage.synchronizer.plugins.base.alarm.synchronizer \
import BaseAlarmSynchronizer
from vitrage.synchronizer.plugins.nagios.config import NagiosConfig
from vitrage.synchronizer.plugins.nagios import NAGIOS_PLUGIN
from vitrage.synchronizer.plugins.nagios.parser import NagiosParser
from vitrage.synchronizer.plugins.nagios.properties import NagiosProperties \
as NagiosProps
from vitrage.synchronizer.plugins.nagios.properties import NagiosStatus
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
class NagiosSynchronizer(BaseAlarmSynchronizer): class NagiosDriver(AlarmDriverBase):
ServiceKey = namedtuple('ServiceKey', ['host_name', 'service']) ServiceKey = namedtuple('ServiceKey', ['host_name', 'service'])
def __init__(self, conf): def __init__(self, conf):
super(NagiosSynchronizer, self).__init__() super(NagiosDriver, self).__init__()
self.conf = conf self.conf = conf
self.config = NagiosConfig(conf) self.config = NagiosConfig(conf)
def _sync_type(self): def _sync_type(self):
return NAGIOS_PLUGIN return NAGIOS_DATASOURCE
def _alarm_key(self, alarm): def _alarm_key(self, alarm):
return self.ServiceKey(host_name=alarm[NagiosProps.RESOURCE_NAME], return self.ServiceKey(host_name=alarm[NagiosProps.RESOURCE_NAME],

View File

@ -14,8 +14,9 @@
from lxml import etree from lxml import etree
from oslo_log import log from oslo_log import log
from six.moves import StringIO from six.moves import StringIO
from vitrage.synchronizer.plugins.nagios.properties import NagiosProperties from vitrage.datasources.nagios.properties import NagiosProperties
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)

View File

@ -19,22 +19,20 @@ from vitrage.common.constants import EntityCategory
from vitrage.common.constants import SynchronizerProperties as SyncProps 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_transformer_base import AlarmTransformerBase
from vitrage.datasources.nagios.properties import NagiosProperties
from vitrage.datasources.nagios.properties import NagiosStatus
from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
from vitrage.datasources.static_physical import SWITCH
from vitrage.datasources import transformer_base as tbase
from vitrage.datasources.transformer_base import Neighbor
import vitrage.graph.utils as graph_utils import vitrage.graph.utils as graph_utils
from vitrage.synchronizer.plugins.base.alarm.properties \
import AlarmProperties as AlarmProps
from vitrage.synchronizer.plugins.base.alarm.transformer \
import BaseAlarmTransformer
from vitrage.synchronizer.plugins.nagios.properties import NagiosProperties
from vitrage.synchronizer.plugins.nagios.properties import NagiosStatus
from vitrage.synchronizer.plugins.nova.host import NOVA_HOST_PLUGIN
from vitrage.synchronizer.plugins.static_physical import SWITCH
from vitrage.synchronizer.plugins import transformer_base as tbase
from vitrage.synchronizer.plugins.transformer_base import Neighbor
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class NagiosTransformer(BaseAlarmTransformer): class NagiosTransformer(AlarmTransformerBase):
STATUS_OK = 'OK' STATUS_OK = 'OK'
@ -87,7 +85,7 @@ class NagiosTransformer(BaseAlarmTransformer):
tbase.TIMESTAMP_FORMAT) tbase.TIMESTAMP_FORMAT)
resource_type = entity_event[NagiosProperties.RESOURCE_TYPE] resource_type = entity_event[NagiosProperties.RESOURCE_TYPE]
if resource_type == NOVA_HOST_PLUGIN or resource_type == SWITCH: if resource_type == NOVA_HOST_DATASOURCE or resource_type == SWITCH:
return [self._create_neighbor( return [self._create_neighbor(
vitrage_id, vitrage_id,
timestamp, timestamp,

View File

@ -14,10 +14,10 @@
from vitrage import clients from vitrage import clients
from vitrage.synchronizer.plugins.synchronizer_base import SynchronizerBase from vitrage.datasources.driver_base import DriverBase
class NeutronBase(SynchronizerBase): class NeutronBase(DriverBase):
def __init__(self, conf): def __init__(self, conf):
super(NeutronBase, self).__init__() super(NeutronBase, self).__init__()
self.client = clients.neutron_client(conf) self.client = clients.neutron_client(conf)

View File

@ -14,17 +14,17 @@
from oslo_config import cfg from oslo_config import cfg
NEUTRON_NETWORK_PLUGIN = 'neutron.network' NEUTRON_NETWORK_DATASOURCE = 'neutron.network'
OPTS = [ OPTS = [
cfg.StrOpt('transformer', cfg.StrOpt('transformer',
default='vitrage.synchronizer.plugins.neutron.network.' default='vitrage.datasources.neutron.network.transformer.'
'transformer.NetworkTransformer', 'NetworkTransformer',
help='Neutron network transformer class path', help='Neutron network transformer class path',
required=True), required=True),
cfg.StrOpt('synchronizer', cfg.StrOpt('driver',
default='vitrage.synchronizer.plugins.neutron.network.' default='vitrage.datasources.neutron.network.driver.'
'synchronizer.NetworkSynchronizer', 'NetworkDriver',
help='Neutron network synchronizer class path', help='Neutron network driver class path',
required=True), required=True),
] ]

View File

@ -12,11 +12,11 @@
# 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.synchronizer.plugins.neutron.base import NeutronBase from vitrage.datasources.neutron.base import NeutronBase
from vitrage.synchronizer.plugins.neutron.network import NEUTRON_NETWORK_PLUGIN from vitrage.datasources.neutron.network import NEUTRON_NETWORK_DATASOURCE
class NetworkSynchronizer(NeutronBase): class NetworkDriver(NeutronBase):
@staticmethod @staticmethod
def get_skipped_event_types(): def get_skipped_event_types():
@ -37,5 +37,5 @@ class NetworkSynchronizer(NeutronBase):
def get_all(self, sync_mode): def get_all(self, sync_mode):
return self.make_pickleable( return self.make_pickleable(
self.client.list_networks()['networks'], self.client.list_networks()['networks'],
NEUTRON_NETWORK_PLUGIN, NEUTRON_NETWORK_DATASOURCE,
sync_mode) sync_mode)

View File

@ -15,16 +15,15 @@
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 SynchronizerProperties as SyncProps
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.synchronizer.plugins.base.resource.transformer import \ from vitrage.datasources.neutron.network import NEUTRON_NETWORK_DATASOURCE
BaseResourceTransformer from vitrage.datasources.resource_transformer_base import \
from vitrage.synchronizer.plugins.neutron.network import NEUTRON_NETWORK_PLUGIN ResourceTransformerBase
from vitrage.synchronizer.plugins import transformer_base as tbase from vitrage.datasources import transformer_base as tbase
from vitrage.synchronizer.plugins.transformer_base import extract_field_value from vitrage.datasources.transformer_base import extract_field_value
import vitrage.graph.utils as graph_utils import vitrage.graph.utils as graph_utils
class NetworkTransformer(BaseResourceTransformer): class NetworkTransformer(ResourceTransformerBase):
UPDATE_EVENT_TYPES = {} UPDATE_EVENT_TYPES = {}
@ -34,7 +33,7 @@ class NetworkTransformer(BaseResourceTransformer):
def _create_entity_key(self, entity_event): def _create_entity_key(self, entity_event):
network_id = 'network_id' if tbase.is_update_event(entity_event) \ network_id = 'network_id' if tbase.is_update_event(entity_event) \
else 'id' else 'id'
key_fields = self._key_values(NEUTRON_NETWORK_PLUGIN, key_fields = self._key_values(NEUTRON_NETWORK_DATASOURCE,
extract_field_value(entity_event, extract_field_value(entity_event,
network_id)) network_id))
return tbase.build_key(key_fields) return tbase.build_key(key_fields)
@ -64,7 +63,7 @@ class NetworkTransformer(BaseResourceTransformer):
self._create_entity_key(entity_event), self._create_entity_key(entity_event),
entity_id=entity_id, entity_id=entity_id,
entity_category=EntityCategory.RESOURCE, entity_category=EntityCategory.RESOURCE,
entity_type=NEUTRON_NETWORK_PLUGIN, entity_type=NEUTRON_NETWORK_DATASOURCE,
entity_state=state, entity_state=state,
sample_timestamp=sample_timestamp, sample_timestamp=sample_timestamp,
update_timestamp=update_timestamp, update_timestamp=update_timestamp,

View File

@ -14,17 +14,16 @@
from oslo_config import cfg from oslo_config import cfg
NEUTRON_PORT_PLUGIN = 'neutron.port' NEUTRON_PORT_DATASOURCE = 'neutron.port'
OPTS = [ OPTS = [
cfg.StrOpt('transformer', cfg.StrOpt('transformer',
default='vitrage.synchronizer.plugins.neutron.port.' default='vitrage.datasources.neutron.port.'
'transformer.PortTransformer', 'transformer.PortTransformer',
help='Neutron port transformer class path', help='Neutron port transformer class path',
required=True), required=True),
cfg.StrOpt('synchronizer', cfg.StrOpt('driver',
default='vitrage.synchronizer.plugins.neutron.port.' default='vitrage.datasources.neutron.port.driver.PortDriver',
'synchronizer.PortSynchronizer', help='Neutron port driver class path',
help='Neutron port synchronizer class path',
required=True), required=True),
] ]

View File

@ -12,11 +12,11 @@
# 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.synchronizer.plugins.neutron.base import NeutronBase from vitrage.datasources.neutron.base import NeutronBase
from vitrage.synchronizer.plugins.neutron.port import NEUTRON_PORT_PLUGIN from vitrage.datasources.neutron.port import NEUTRON_PORT_DATASOURCE
class PortSynchronizer(NeutronBase): class PortDriver(NeutronBase):
@staticmethod @staticmethod
def get_skipped_event_types(): def get_skipped_event_types():
@ -37,5 +37,5 @@ class PortSynchronizer(NeutronBase):
def get_all(self, sync_mode): def get_all(self, sync_mode):
return self.make_pickleable( return self.make_pickleable(
self.client.list_ports()['ports'], self.client.list_ports()['ports'],
NEUTRON_PORT_PLUGIN, NEUTRON_PORT_DATASOURCE,
sync_mode) sync_mode)

View File

@ -11,6 +11,8 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# 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.datasources.resource_transformer_base import \
ResourceTransformerBase
from oslo_log import log as logging from oslo_log import log as logging
@ -18,28 +20,26 @@ 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 SynchronizerProperties as SyncProps
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.synchronizer.plugins.base.resource.transformer import \ from vitrage.datasources.neutron.network import NEUTRON_NETWORK_DATASOURCE
BaseResourceTransformer from vitrage.datasources.neutron.port import NEUTRON_PORT_DATASOURCE
from vitrage.synchronizer.plugins.neutron.network import NEUTRON_NETWORK_PLUGIN from vitrage.datasources.nova.instance import NOVA_INSTANCE_DATASOURCE
from vitrage.synchronizer.plugins.neutron.port import NEUTRON_PORT_PLUGIN from vitrage.datasources import transformer_base as tbase
from vitrage.synchronizer.plugins.nova.instance import NOVA_INSTANCE_PLUGIN from vitrage.datasources.transformer_base import extract_field_value
from vitrage.synchronizer.plugins import transformer_base as tbase from vitrage.datasources.transformer_base import Neighbor
from vitrage.synchronizer.plugins.transformer_base import extract_field_value
from vitrage.synchronizer.plugins.transformer_base import Neighbor
import vitrage.graph.utils as graph_utils import vitrage.graph.utils as graph_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class PortTransformer(BaseResourceTransformer): class PortTransformer(ResourceTransformerBase):
def __init__(self, transformers): def __init__(self, transformers):
super(PortTransformer, self).__init__(transformers) super(PortTransformer, self).__init__(transformers)
def _create_entity_key(self, entity_event): def _create_entity_key(self, entity_event):
port_id = 'port_id' if tbase.is_update_event(entity_event) \ port_id = 'port_id' if tbase.is_update_event(entity_event) \
else 'id' else 'id'
key_fields = self._key_values(NEUTRON_PORT_PLUGIN, key_fields = self._key_values(NEUTRON_PORT_DATASOURCE,
extract_field_value(entity_event, extract_field_value(entity_event,
port_id)) port_id))
return tbase.build_key(key_fields) return tbase.build_key(key_fields)
@ -70,7 +70,7 @@ class PortTransformer(BaseResourceTransformer):
self._create_entity_key(entity_event), self._create_entity_key(entity_event),
entity_id=entity_id, entity_id=entity_id,
entity_category=EntityCategory.RESOURCE, entity_category=EntityCategory.RESOURCE,
entity_type=NEUTRON_PORT_PLUGIN, entity_type=NEUTRON_PORT_DATASOURCE,
entity_state=state, entity_state=state,
sample_timestamp=sample_timestamp, sample_timestamp=sample_timestamp,
update_timestamp=update_timestamp, update_timestamp=update_timestamp,
@ -122,7 +122,7 @@ class PortTransformer(BaseResourceTransformer):
properties = { properties = {
VProps.ID: instance_id, VProps.ID: instance_id,
VProps.TYPE: NOVA_INSTANCE_PLUGIN, VProps.TYPE: NOVA_INSTANCE_DATASOURCE,
VProps.SAMPLE_TIMESTAMP: sample_timestamp VProps.SAMPLE_TIMESTAMP: sample_timestamp
} }
instance_vertex = self.create_placeholder_vertex(**properties) instance_vertex = self.create_placeholder_vertex(**properties)
@ -143,7 +143,7 @@ class PortTransformer(BaseResourceTransformer):
properties = { properties = {
VProps.ID: net_id, VProps.ID: net_id,
VProps.TYPE: NEUTRON_NETWORK_PLUGIN, VProps.TYPE: NEUTRON_NETWORK_DATASOURCE,
VProps.SAMPLE_TIMESTAMP: sample_timestamp VProps.SAMPLE_TIMESTAMP: sample_timestamp
} }

View File

@ -0,0 +1 @@
__author__ = 'stack'

View File

@ -14,17 +14,16 @@
from oslo_config import cfg from oslo_config import cfg
NOVA_HOST_PLUGIN = 'nova.host' NOVA_HOST_DATASOURCE = 'nova.host'
OPTS = [ OPTS = [
cfg.StrOpt('transformer', cfg.StrOpt('transformer',
default='vitrage.synchronizer.plugins.nova.host.' default='vitrage.datasources.nova.host.'
'transformer.HostTransformer', 'transformer.HostTransformer',
help='Nova host transformer class path', help='Nova host transformer class path',
required=True), required=True),
cfg.StrOpt('synchronizer', cfg.StrOpt('driver',
default='vitrage.synchronizer.plugins.nova.host.synchronizer' default='vitrage.datasources.nova.host.driver.HostDriver',
'.HostSynchronizer', help='Nova host driver class path',
help='Nova host synchronizer class path',
required=True), required=True),
] ]

View File

@ -12,11 +12,11 @@
# 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.synchronizer.plugins.nova.base import NovaBase from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
from vitrage.synchronizer.plugins.nova.host import NOVA_HOST_PLUGIN from vitrage.datasources.nova.nova_driver_base import NovaDriverBase
class HostSynchronizer(NovaBase): class HostDriver(NovaDriverBase):
@staticmethod @staticmethod
def filter_none_compute_hosts(entities): def filter_none_compute_hosts(entities):
@ -30,6 +30,6 @@ class HostSynchronizer(NovaBase):
def get_all(self, sync_mode): def get_all(self, sync_mode):
return self.make_pickleable( return self.make_pickleable(
self.filter_none_compute_hosts(self.client.hosts.list()), self.filter_none_compute_hosts(self.client.hosts.list()),
NOVA_HOST_PLUGIN, NOVA_HOST_DATASOURCE,
sync_mode, sync_mode,
'manager') 'manager')

View File

@ -18,20 +18,20 @@ 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 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.zone import NOVA_ZONE_DATASOURCE
from vitrage.datasources.resource_transformer_base import \
ResourceTransformerBase
from vitrage.datasources import transformer_base
from vitrage.datasources.transformer_base import extract_field_value
from vitrage.datasources.transformer_base import Neighbor
import vitrage.graph.utils as graph_utils import vitrage.graph.utils as graph_utils
from vitrage.synchronizer.plugins.base.resource.transformer import \
BaseResourceTransformer
from vitrage.synchronizer.plugins.nova.host import NOVA_HOST_PLUGIN
from vitrage.synchronizer.plugins.nova.zone import NOVA_ZONE_PLUGIN
from vitrage.synchronizer.plugins import transformer_base
from vitrage.synchronizer.plugins.transformer_base import extract_field_value
from vitrage.synchronizer.plugins.transformer_base import Neighbor
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class HostTransformer(BaseResourceTransformer): class HostTransformer(ResourceTransformerBase):
def __init__(self, transformers): def __init__(self, transformers):
super(HostTransformer, self).__init__(transformers) super(HostTransformer, self).__init__(transformers)
@ -57,7 +57,7 @@ class HostTransformer(BaseResourceTransformer):
entity_key, entity_key,
entity_id=host_name, entity_id=host_name,
entity_category=EntityCategory.RESOURCE, entity_category=EntityCategory.RESOURCE,
entity_type=NOVA_HOST_PLUGIN, entity_type=NOVA_HOST_DATASOURCE,
sample_timestamp=sample_timestamp, sample_timestamp=sample_timestamp,
update_timestamp=update_timestamp, update_timestamp=update_timestamp,
metadata=metadata) metadata=metadata)
@ -84,7 +84,7 @@ class HostTransformer(BaseResourceTransformer):
host_vertex_id, host_vertex_id,
zone_name_path): zone_name_path):
zone_transformer = self.transformers[NOVA_ZONE_PLUGIN] zone_transformer = self.transformers[NOVA_ZONE_DATASOURCE]
if zone_transformer: if zone_transformer:
@ -92,7 +92,7 @@ class HostTransformer(BaseResourceTransformer):
properties = { properties = {
VProps.ID: zone_name, VProps.ID: zone_name,
VProps.TYPE: NOVA_ZONE_PLUGIN, VProps.TYPE: NOVA_ZONE_DATASOURCE,
VProps.SAMPLE_TIMESTAMP: sample_timestamp VProps.SAMPLE_TIMESTAMP: sample_timestamp
} }
zone_neighbor = zone_transformer.create_placeholder_vertex( zone_neighbor = zone_transformer.create_placeholder_vertex(
@ -112,5 +112,5 @@ class HostTransformer(BaseResourceTransformer):
host_name = extract_field_value(entity_event, '_info', 'host_name') host_name = extract_field_value(entity_event, '_info', 'host_name')
key_fields = self._key_values(NOVA_HOST_PLUGIN, host_name) key_fields = self._key_values(NOVA_HOST_DATASOURCE, host_name)
return transformer_base.build_key(key_fields) return transformer_base.build_key(key_fields)

View File

@ -14,18 +14,18 @@
from oslo_config import cfg from oslo_config import cfg
NOVA_INSTANCE_PLUGIN = 'nova.instance' NOVA_INSTANCE_DATASOURCE = 'nova.instance'
OPTS = [ OPTS = [
cfg.StrOpt('transformer', cfg.StrOpt('transformer',
default='vitrage.synchronizer.plugins.nova.instance.' default='vitrage.datasources.nova.instance.transformer.'
'transformer.InstanceTransformer', 'InstanceTransformer',
help='Nova instance transformer class path', help='Nova instance transformer class path',
required=True), required=True),
cfg.StrOpt('synchronizer', cfg.StrOpt('driver',
default='vitrage.synchronizer.plugins.nova.instance.' default='vitrage.datasources.nova.instance.driver.'
'synchronizer.InstanceSynchronizer', 'InstanceDriver',
help='Nova instance synchronizer class path', help='Nova instance driver class path',
required=True), required=True),
cfg.StrOpt('notification_topic', cfg.StrOpt('notification_topic',
default='vitrage_notifications', default='vitrage_notifications',

View File

@ -16,13 +16,13 @@ from oslo_log import log as logging
from vitrage.common.constants import SynchronizerProperties as SyncProps from vitrage.common.constants import SynchronizerProperties as SyncProps
from vitrage.common.constants import SyncMode from vitrage.common.constants import SyncMode
from vitrage.synchronizer.plugins.nova.base import NovaBase from vitrage.datasources.nova.instance import NOVA_INSTANCE_DATASOURCE
from vitrage.synchronizer.plugins.nova.instance import NOVA_INSTANCE_PLUGIN from vitrage.datasources.nova.nova_driver_base import NovaDriverBase
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class InstanceSynchronizer(NovaBase): class InstanceDriver(NovaDriverBase):
@staticmethod @staticmethod
def extract_events(instances): def extract_events(instances):
@ -31,7 +31,7 @@ class InstanceSynchronizer(NovaBase):
def get_all(self, sync_mode): def get_all(self, sync_mode):
return self.make_pickleable( return self.make_pickleable(
self.extract_events(self.client.servers.list()), self.extract_events(self.client.servers.list()),
NOVA_INSTANCE_PLUGIN, NOVA_INSTANCE_DATASOURCE,
sync_mode, sync_mode,
'manager') 'manager')
@ -39,8 +39,8 @@ class InstanceSynchronizer(NovaBase):
def enrich_event(event, event_type): def enrich_event(event, event_type):
event[SyncProps.EVENT_TYPE] = event_type event[SyncProps.EVENT_TYPE] = event_type
return InstanceSynchronizer.make_pickleable([event], return InstanceDriver.make_pickleable([event],
NOVA_INSTANCE_PLUGIN, NOVA_INSTANCE_DATASOURCE,
SyncMode.UPDATE)[0] SyncMode.UPDATE)[0]
@staticmethod @staticmethod
@ -53,4 +53,4 @@ class InstanceSynchronizer(NovaBase):
@staticmethod @staticmethod
def get_topic(conf): def get_topic(conf):
return conf[NOVA_INSTANCE_PLUGIN].notification_topic return conf[NOVA_INSTANCE_DATASOURCE].notification_topic

View File

@ -19,19 +19,20 @@ 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 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.instance import NOVA_INSTANCE_DATASOURCE
from vitrage.datasources.resource_transformer_base import \
ResourceTransformerBase
from vitrage.datasources import transformer_base as tbase
from vitrage.datasources.transformer_base import extract_field_value
from vitrage.datasources.transformer_base import Neighbor
import vitrage.graph.utils as graph_utils import vitrage.graph.utils as graph_utils
from vitrage.synchronizer.plugins.base.resource.transformer import \
BaseResourceTransformer
from vitrage.synchronizer.plugins.nova.host import NOVA_HOST_PLUGIN
from vitrage.synchronizer.plugins.nova.instance import NOVA_INSTANCE_PLUGIN
from vitrage.synchronizer.plugins import transformer_base as tbase
from vitrage.synchronizer.plugins.transformer_base import extract_field_value
from vitrage.synchronizer.plugins.transformer_base import Neighbor
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class InstanceTransformer(BaseResourceTransformer): class InstanceTransformer(ResourceTransformerBase):
# Event types which need to refer them differently # Event types which need to refer them differently
UPDATE_EVENT_TYPES = { UPDATE_EVENT_TYPES = {
@ -78,7 +79,7 @@ class InstanceTransformer(BaseResourceTransformer):
self._create_entity_key(entity_event), self._create_entity_key(entity_event),
entity_id=entity_id, entity_id=entity_id,
entity_category=EntityCategory.RESOURCE, entity_category=EntityCategory.RESOURCE,
entity_type=NOVA_INSTANCE_PLUGIN, entity_type=NOVA_INSTANCE_DATASOURCE,
entity_state=state, entity_state=state,
sample_timestamp=sample_timestamp, sample_timestamp=sample_timestamp,
update_timestamp=update_timestamp, update_timestamp=update_timestamp,
@ -87,7 +88,7 @@ class InstanceTransformer(BaseResourceTransformer):
def _create_neighbors(self, entity_event): def _create_neighbors(self, entity_event):
neighbors = [] neighbors = []
host_transformer = self.transformers[NOVA_HOST_PLUGIN] host_transformer = self.transformers[NOVA_HOST_DATASOURCE]
host_name = 'host' if tbase.is_update_event(entity_event) \ host_name = 'host' if tbase.is_update_event(entity_event) \
else 'OS-EXT-SRV-ATTR:host' else 'OS-EXT-SRV-ATTR:host'
@ -107,7 +108,7 @@ class InstanceTransformer(BaseResourceTransformer):
def _create_entity_key(self, event): def _create_entity_key(self, event):
instance_id = 'instance_id' if tbase.is_update_event(event) else 'id' instance_id = 'instance_id' if tbase.is_update_event(event) else 'id'
key_fields = self._key_values(NOVA_INSTANCE_PLUGIN, key_fields = self._key_values(NOVA_INSTANCE_DATASOURCE,
extract_field_value(event, extract_field_value(event,
instance_id)) instance_id))
return tbase.build_key(key_fields) return tbase.build_key(key_fields)
@ -119,7 +120,7 @@ class InstanceTransformer(BaseResourceTransformer):
host_transformer): host_transformer):
properties = { properties = {
VProps.ID: host_name, VProps.ID: host_name,
VProps.TYPE: NOVA_HOST_PLUGIN, VProps.TYPE: NOVA_HOST_DATASOURCE,
VProps.SAMPLE_TIMESTAMP: sample_timestamp VProps.SAMPLE_TIMESTAMP: sample_timestamp
} }
host_vertex = host_transformer.create_placeholder_vertex(**properties) host_vertex = host_transformer.create_placeholder_vertex(**properties)

View File

@ -14,12 +14,12 @@
from vitrage import clients from vitrage import clients
from vitrage.synchronizer.plugins.synchronizer_base import SynchronizerBase from vitrage.datasources.driver_base import DriverBase
class NovaBase(SynchronizerBase): class NovaDriverBase(DriverBase):
def __init__(self, conf): def __init__(self, conf):
super(NovaBase, self).__init__() super(NovaDriverBase, self).__init__()
self.client = clients.nova_client(conf) self.client = clients.nova_client(conf)
self.conf = conf self.conf = conf

View File

@ -14,17 +14,17 @@
from oslo_config import cfg from oslo_config import cfg
NOVA_ZONE_PLUGIN = 'nova.zone' NOVA_ZONE_DATASOURCE = 'nova.zone'
OPTS = [ OPTS = [
cfg.StrOpt('transformer', cfg.StrOpt('transformer',
default='vitrage.synchronizer.plugins.nova.zone.' default='vitrage.datasources.nova.zone.transformer.'
'transformer.ZoneTransformer', 'ZoneTransformer',
help='Nova zone transformer class path', help='Nova zone transformer class path',
required=True), required=True),
cfg.StrOpt('synchronizer', cfg.StrOpt('driver',
default='vitrage.synchronizer.plugins.nova.zone.synchronizer' default='vitrage.datasources.nova.zone.driver'
'.ZoneSynchronizer', '.ZoneDriver',
help='Nova zone synchronizer class path', help='Nova zone synchronizer class path',
required=True), required=True),
] ]

View File

@ -10,13 +10,13 @@
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# 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.datasources.nova.nova_driver_base import NovaDriverBase
from vitrage.synchronizer.plugins.nova.base import NovaBase from vitrage.datasources.nova.zone import NOVA_ZONE_DATASOURCE
from vitrage.synchronizer.plugins.nova.zone import NOVA_ZONE_PLUGIN
class ZoneSynchronizer(NovaBase): class ZoneDriver(NovaDriverBase):
@staticmethod @staticmethod
def filter_internal_zone(zones): def filter_internal_zone(zones):
@ -30,6 +30,6 @@ class ZoneSynchronizer(NovaBase):
def get_all(self, sync_mode): def get_all(self, sync_mode):
return self.make_pickleable(self.filter_internal_zone( return self.make_pickleable(self.filter_internal_zone(
self.client.availability_zones.list()), self.client.availability_zones.list()),
NOVA_ZONE_PLUGIN, NOVA_ZONE_DATASOURCE,
sync_mode, sync_mode,
'manager') 'manager')

View File

@ -18,19 +18,19 @@ 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 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.zone import NOVA_ZONE_DATASOURCE
from vitrage.datasources.resource_transformer_base import \
ResourceTransformerBase
from vitrage.datasources import transformer_base as tbase
from vitrage.datasources.transformer_base import extract_field_value
import vitrage.graph.utils as graph_utils import vitrage.graph.utils as graph_utils
from vitrage.synchronizer.plugins.base.resource.transformer import \
BaseResourceTransformer
from vitrage.synchronizer.plugins.nova.host import NOVA_HOST_PLUGIN
from vitrage.synchronizer.plugins.nova.zone import NOVA_ZONE_PLUGIN
from vitrage.synchronizer.plugins import transformer_base as tbase
from vitrage.synchronizer.plugins.transformer_base import extract_field_value
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class ZoneTransformer(BaseResourceTransformer): class ZoneTransformer(ResourceTransformerBase):
STATE_AVAILABLE = 'available' STATE_AVAILABLE = 'available'
STATE_UNAVAILABLE = 'unavailable' STATE_UNAVAILABLE = 'unavailable'
@ -67,7 +67,7 @@ class ZoneTransformer(BaseResourceTransformer):
entity_key, entity_key,
entity_id=zone_name, entity_id=zone_name,
entity_category=EntityCategory.RESOURCE, entity_category=EntityCategory.RESOURCE,
entity_type=NOVA_ZONE_PLUGIN, entity_type=NOVA_ZONE_DATASOURCE,
entity_state=state, entity_state=state,
sample_timestamp=sample_timestamp, sample_timestamp=sample_timestamp,
update_timestamp=update_timestamp, update_timestamp=update_timestamp,
@ -78,7 +78,7 @@ class ZoneTransformer(BaseResourceTransformer):
zone_vertex_id = self._create_entity_key(entity_event) zone_vertex_id = self._create_entity_key(entity_event)
neighbors = [self._create_node_neighbor(zone_vertex_id)] neighbors = [self._create_node_neighbor(zone_vertex_id)]
hosts = extract_field_value(entity_event, 'hosts') hosts = extract_field_value(entity_event, 'hosts')
host_transformer = self.transformers[NOVA_HOST_PLUGIN] host_transformer = self.transformers[NOVA_HOST_DATASOURCE]
if host_transformer: if host_transformer:
for hostname, host_data in hosts.items(): for hostname, host_data in hosts.items():
@ -120,12 +120,12 @@ class ZoneTransformer(BaseResourceTransformer):
def _create_host_neighbor(self, zone_id, host_name, def _create_host_neighbor(self, zone_id, host_name,
host_state, sample_timestamp): host_state, sample_timestamp):
host_transformer = self.transformers[NOVA_HOST_PLUGIN] host_transformer = self.transformers[NOVA_HOST_DATASOURCE]
properties = { properties = {
VProps.ID: host_name, VProps.ID: host_name,
VProps.SAMPLE_TIMESTAMP: sample_timestamp, VProps.SAMPLE_TIMESTAMP: sample_timestamp,
VProps.TYPE: NOVA_HOST_PLUGIN VProps.TYPE: NOVA_HOST_DATASOURCE
} }
host_neighbor = \ host_neighbor = \
host_transformer.create_placeholder_vertex(**properties) host_transformer.create_placeholder_vertex(**properties)
@ -143,5 +143,5 @@ class ZoneTransformer(BaseResourceTransformer):
zone_name = extract_field_value(entity_event, 'zoneName') zone_name = extract_field_value(entity_event, 'zoneName')
key_fields = self._key_values(NOVA_ZONE_PLUGIN, zone_name) key_fields = self._key_values(NOVA_ZONE_DATASOURCE, zone_name)
return tbase.build_key(key_fields) return tbase.build_key(key_fields)

View File

@ -16,15 +16,14 @@ from oslo_log import log as logging
from vitrage.common.constants import EntityCategory from vitrage.common.constants import EntityCategory
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.datasources import transformer_base as tbase
import vitrage.graph.utils as graph_utils import vitrage.graph.utils as graph_utils
from vitrage.synchronizer.plugins import transformer_base as tbase
from vitrage.synchronizer.plugins import transformer_base
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class BaseResourceTransformer(tbase.TransformerBase): class ResourceTransformerBase(tbase.TransformerBase):
def __init__(self, transformers): def __init__(self, transformers):
self.transformers = transformers self.transformers = transformers
@ -44,7 +43,7 @@ class BaseResourceTransformer(tbase.TransformerBase):
key_fields = self._key_values(kwargs[VProps.TYPE], kwargs[VProps.ID]) key_fields = self._key_values(kwargs[VProps.TYPE], kwargs[VProps.ID])
return graph_utils.create_vertex( return graph_utils.create_vertex(
transformer_base.build_key(key_fields), tbase.build_key(key_fields),
entity_id=kwargs[VProps.ID], entity_id=kwargs[VProps.ID],
entity_category=EntityCategory.RESOURCE, entity_category=EntityCategory.RESOURCE,
entity_type=kwargs[VProps.TYPE], entity_type=kwargs[VProps.TYPE],

View File

@ -22,42 +22,42 @@ LOG = log.getLogger(__name__)
class SynchronizerService(os_service.Service): class SynchronizerService(os_service.Service):
def __init__(self, conf, registered_plugins, callback_function): def __init__(self, conf, registered_datasources, callback_function):
super(SynchronizerService, self).__init__() super(SynchronizerService, self).__init__()
self.conf = conf self.conf = conf
self.registered_plugins = registered_plugins self.registered_datasources = registered_datasources
self.callback_function = callback_function self.callback_function = callback_function
class SnapshotsService(SynchronizerService): class SnapshotsService(SynchronizerService):
def __init__(self, conf, registered_plugins, callback_function): def __init__(self, conf, registered_datasources, callback_function):
super(SnapshotsService, self).__init__(conf, super(SnapshotsService, self).__init__(conf,
registered_plugins, registered_datasources,
callback_function) callback_function)
self.first_time = True self.first_time = True
def start(self): def start(self):
LOG.info("Vitrage Synchronizer Snapshot Service - Starting...") LOG.info("Vitrage datasources Snapshot Service - Starting...")
super(SnapshotsService, self).start() super(SnapshotsService, self).start()
interval = self.conf.synchronizer.snapshots_interval interval = self.conf.datasources.snapshots_interval
self.tg.add_timer(interval, self._get_all) self.tg.add_timer(interval, self._get_all)
LOG.info("Vitrage Synchronizer Snapshot Service - Started!") LOG.info("Vitrage datasources Snapshot Service - Started!")
def stop(self, graceful=False): def stop(self, graceful=False):
LOG.info("Vitrage Synchronizer Snapshot Service - Stopping...") LOG.info("Vitrage datasources Snapshot Service - Stopping...")
super(SnapshotsService, self).stop() super(SnapshotsService, self).stop()
LOG.info("Vitrage Synchronizer Snapshot Service - Stopped!") LOG.info("Vitrage datasources Snapshot Service - Stopped!")
def _get_all(self): def _get_all(self):
sync_mode = SyncMode.INIT_SNAPSHOT \ sync_mode = SyncMode.INIT_SNAPSHOT \
if self.first_time else SyncMode.SNAPSHOT if self.first_time else SyncMode.SNAPSHOT
LOG.debug("start get all with sync mode %s" % sync_mode) LOG.debug("start get all with sync mode %s" % sync_mode)
for plugin in self.registered_plugins.values(): for plugin in self.registered_datasources.values():
entities_dictionaries = plugin.get_all(sync_mode) entities_dictionaries = plugin.get_all(sync_mode)
for entity in entities_dictionaries: for entity in entities_dictionaries:
self.callback_function(entity) self.callback_function(entity)
@ -68,17 +68,17 @@ class SnapshotsService(SynchronizerService):
class ChangesService(SynchronizerService): class ChangesService(SynchronizerService):
def __init__(self, conf, def __init__(self, conf,
registered_plugins, registered_datasources,
changes_interval, changes_interval,
callback_function): callback_function):
super(ChangesService, self).__init__(conf, super(ChangesService, self).__init__(conf,
registered_plugins, registered_datasources,
callback_function) callback_function)
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 Synchronizer Changes Service For: %s - Starting...",
self.registered_plugins[0].__class__.__name__) self.registered_datasources[0].__class__.__name__)
super(ChangesService, self).start() super(ChangesService, self).start()
self.tg.add_timer(interval=self.changes_interval, self.tg.add_timer(interval=self.changes_interval,
@ -86,22 +86,22 @@ class ChangesService(SynchronizerService):
initial_delay=self.changes_interval) initial_delay=self.changes_interval)
LOG.info("Vitrage Synchronizer Changes Service For: %s - Started!", LOG.info("Vitrage Synchronizer Changes Service For: %s - Started!",
self.registered_plugins[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 Synchronizer Changes Service For: %s - Stopping...",
self.registered_plugins[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 Synchronizer Changes Service For: %s - Stopped!",
self.registered_plugins[0].__class__.__name__) self.registered_datasources[0].__class__.__name__)
def _get_changes(self): def _get_changes(self):
LOG.debug("start get changes") LOG.debug("start get changes")
for plugin in self.registered_plugins: for datasource in self.registered_datasources:
for entity in plugin.get_changes(SyncMode.UPDATE): for entity in datasource.get_changes(SyncMode.UPDATE):
self.callback_function(entity) self.callback_function(entity)
LOG.debug("end get changes") LOG.debug("end get changes")

View File

@ -14,28 +14,28 @@
from oslo_config import cfg from oslo_config import cfg
STATIC_PHYSICAL_PLUGIN = 'static_physical' STATIC_PHYSICAL_DATASOURCE = 'static_physical'
SWITCH = 'switch' SWITCH = 'switch'
OPTS = [ OPTS = [
cfg.StrOpt('transformer', cfg.StrOpt('transformer',
default='vitrage.synchronizer.plugins.static_physical.' default='vitrage.datasources.static_physical.transformer.'
'transformer.StaticPhysicalTransformer', 'StaticPhysicalTransformer',
help='Static physical transformer class path', help='Static physical transformer class path',
required=True), required=True),
cfg.StrOpt('synchronizer', cfg.StrOpt('driver',
default='vitrage.synchronizer.plugins.static_physical' default='vitrage.datasources.static_physical.driver.'
'.synchronizer.StaticPhysicalSynchronizer', 'StaticPhysicalDriver',
help='Static physical synchronizer class path', help='Static physical driver class path',
required=True), required=True),
cfg.IntOpt('changes_interval', cfg.IntOpt('changes_interval',
default=30, default=30,
min=30, min=30,
help='interval between checking changes in the configuration ' help='interval between checking changes in the configuration '
'files of the physical topology plugin', 'files of the physical topology data sources',
required=True), required=True),
cfg.StrOpt('directory', default='/etc/vitrage/static_plugins', cfg.StrOpt('directory', default='/etc/vitrage/static_datasources',
help='Static physical plugins directory'), help='Static physical data sources directory'),
cfg.ListOpt('entities', cfg.ListOpt('entities',
default=[SWITCH], default=[SWITCH],
help='Static physical entity types list') help='Static physical entity types list')

View File

@ -19,26 +19,26 @@ from vitrage.common.constants import EventAction
from vitrage.common.constants import SynchronizerProperties as SyncProps 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.synchronizer.plugins.static_physical import STATIC_PHYSICAL_PLUGIN from vitrage.datasources.driver_base import DriverBase
from vitrage.synchronizer.plugins.synchronizer_base import SynchronizerBase from vitrage.datasources.static_physical import STATIC_PHYSICAL_DATASOURCE
class StaticPhysicalSynchronizer(SynchronizerBase): class StaticPhysicalDriver(DriverBase):
ENTITIES_SECTION = 'entities' ENTITIES_SECTION = 'entities'
def __init__(self, conf): def __init__(self, conf):
super(StaticPhysicalSynchronizer, self).__init__() super(StaticPhysicalDriver, self).__init__()
self.cfg = conf self.cfg = conf
self.cache = {} self.cache = {}
def get_all(self, sync_mode): def get_all(self, sync_mode):
return self.make_pickleable(self._get_all_entities(), return self.make_pickleable(self._get_all_entities(),
STATIC_PHYSICAL_PLUGIN, STATIC_PHYSICAL_DATASOURCE,
sync_mode) sync_mode)
def get_changes(self, sync_mode): def get_changes(self, sync_mode):
return self.make_pickleable(self._get_changes_entities(), return self.make_pickleable(self._get_changes_entities(),
STATIC_PHYSICAL_PLUGIN, STATIC_PHYSICAL_DATASOURCE,
sync_mode) sync_mode)
def _get_all_entities(self): def _get_all_entities(self):

View File

@ -17,18 +17,18 @@ from oslo_log import log as logging
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 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.resource_transformer_base import \
ResourceTransformerBase
from vitrage.datasources.static_physical import SWITCH
from vitrage.datasources import transformer_base
from vitrage.datasources.transformer_base import Neighbor
import vitrage.graph.utils as graph_utils import vitrage.graph.utils as graph_utils
from vitrage.synchronizer.plugins.base.resource.transformer import \
BaseResourceTransformer
from vitrage.synchronizer.plugins.nova.host import NOVA_HOST_PLUGIN
from vitrage.synchronizer.plugins.static_physical import SWITCH
from vitrage.synchronizer.plugins import transformer_base
from vitrage.synchronizer.plugins.transformer_base import Neighbor
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class StaticPhysicalTransformer(BaseResourceTransformer): class StaticPhysicalTransformer(ResourceTransformerBase):
RELATION_TYPE = 'relation_type' RELATION_TYPE = 'relation_type'
RELATIONSHIPS_SECTION = 'relationships' RELATIONSHIPS_SECTION = 'relationships'
@ -129,7 +129,7 @@ class StaticPhysicalTransformer(BaseResourceTransformer):
def _register_relations_direction(self): def _register_relations_direction(self):
self.relation_direction = {} self.relation_direction = {}
relationship = (SWITCH, NOVA_HOST_PLUGIN) relationship = (SWITCH, NOVA_HOST_DATASOURCE)
self.relation_direction[relationship] = True self.relation_direction[relationship] = True
relationship = (SWITCH, SWITCH) relationship = (SWITCH, SWITCH)

View File

@ -25,8 +25,8 @@ from vitrage.common.constants import EventAction
from vitrage.common.constants import SynchronizerProperties as SyncProps 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
import vitrage.graph.utils as graph_utils import vitrage.graph.utils as graph_utils
from vitrage.synchronizer.plugins import OPENSTACK_NODE
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -97,13 +97,13 @@ class TransformerBase(object):
def transform(self, entity_event): def transform(self, entity_event):
"""Transform an entity event into entity wrapper. """Transform an entity event into entity wrapper.
Entity event is received from synchronizer it need to be Entity event is received from driver and it need to be
transformed into entity wrapper. The wrapper contains: transformed into entity wrapper. The wrapper contains:
1. Entity Vertex - The vertex itself with all fields 1. Entity Vertex - The vertex itself with all fields
2. Neighbor list - neighbor placeholder vertex and an edge 2. Neighbor list - neighbor placeholder vertex and an edge
3. Action type - CREATE/UPDATE/DELETE 3. Action type - CREATE/UPDATE/DELETE
:param entity_event: a general event from the synchronizer :param entity_event: a general event from the driver
:return: entity wrapper :return: entity wrapper
:rtype:EntityWrapper :rtype:EntityWrapper
""" """
@ -139,9 +139,9 @@ class TransformerBase(object):
"""Extracts entity neighbors received from a given entity event. """Extracts entity neighbors received from a given entity event.
Extracting entity neighbors from a given event provided Extracting entity neighbors from a given event provided
by synchronizer by driver
:param entity_event: an event provided by synchronizer :param entity_event: an event provided by driver
:return: neighbors - a list of neighbors where each item in the list :return: neighbors - a list of neighbors where each item in the list
is a tuple of (vertex, edge) is a tuple of (vertex, edge)
:rtype: list :rtype: list
@ -154,7 +154,7 @@ class TransformerBase(object):
By given an entity event, return a entity key which By given an entity event, return a entity key which
consisting key fields consisting key fields
:param entity_event: event that returns from the synchronizer :param entity_event: event that returns from the driver
:return: key :return: key
""" """
pass pass
@ -164,7 +164,7 @@ class TransformerBase(object):
"""Creates placeholder vertex. """Creates placeholder vertex.
Placeholder vertex contains only mandatory fields of this entity. Placeholder vertex contains only mandatory fields of this entity.
This way other plugins can create placeholder vertices of those This way other datasources can create placeholder vertices of those
entities entities
:param kwargs: the properties for the placeholder vertex :param kwargs: the properties for the placeholder vertex
@ -179,7 +179,7 @@ class TransformerBase(object):
Decides what action (from constants.EventAction) the processor need Decides what action (from constants.EventAction) the processor need
to perform according to the data received from the event. to perform according to the data received from the event.
:param entity_event: event that returns from the synchronizer :param entity_event: event that returns from the driver
:return: the action that the processor needs to perform :return: the action that the processor needs to perform
:rtype: str :rtype: str
""" """

View File

@ -17,8 +17,9 @@ from oslo_config import cfg
OPTS = [ OPTS = [
cfg.StrOpt('states_plugins_dir', cfg.StrOpt('datasources_states_dir',
default='/etc/vitrage/states_plugins', default='/etc/vitrage/datasources_states',
help='A path for the configuration files of the plugins states' help='A path for the configuration files of the data sources'
' states'
), ),
] ]

View File

@ -19,12 +19,12 @@ from vitrage.common.constants import EdgeLabels
from vitrage.common.constants import EdgeProperties as EProps from vitrage.common.constants import EdgeProperties as EProps
from vitrage.common.constants import EntityCategory from vitrage.common.constants import EntityCategory
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.instance import NOVA_INSTANCE_DATASOURCE
from vitrage.datasources.nova.zone import NOVA_ZONE_DATASOURCE
from vitrage.datasources import OPENSTACK_NODE
from vitrage.graph import create_algorithm from vitrage.graph import create_algorithm
from vitrage.graph import Direction from vitrage.graph import Direction
from vitrage.synchronizer.plugins.nova.host import NOVA_HOST_PLUGIN
from vitrage.synchronizer.plugins.nova.instance import NOVA_INSTANCE_PLUGIN
from vitrage.synchronizer.plugins.nova.zone import NOVA_ZONE_PLUGIN
from vitrage.synchronizer.plugins import OPENSTACK_NODE
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
@ -37,9 +37,9 @@ TREE_TOPOLOGY_QUERY = {
{ {
'or': [ 'or': [
{'==': {VProps.TYPE: OPENSTACK_NODE}}, {'==': {VProps.TYPE: OPENSTACK_NODE}},
{'==': {VProps.TYPE: NOVA_INSTANCE_PLUGIN}}, {'==': {VProps.TYPE: NOVA_INSTANCE_DATASOURCE}},
{'==': {VProps.TYPE: NOVA_HOST_PLUGIN}}, {'==': {VProps.TYPE: NOVA_HOST_DATASOURCE}},
{'==': {VProps.TYPE: NOVA_ZONE_PLUGIN}} {'==': {VProps.TYPE: NOVA_ZONE_DATASOURCE}}
] ]
} }
] ]

View File

@ -24,12 +24,12 @@ OPTS = [
default=3, default=3,
min=1, min=1,
help='interval between consistency initialization checks for ' help='interval between consistency initialization checks for '
'finding if all end messages from plugins were ' 'finding if all end messages from datasources were '
'received (in seconds)'), 'received (in seconds)'),
cfg.IntOpt('initialization_max_retries', cfg.IntOpt('initialization_max_retries',
default=30, default=30,
min=1, min=1,
help='maximum retries for consistency initialization ' help='maximum retries for consistency initialization '
'for finding if all end messages from plugins were ' 'for finding if all end messages from datasources were '
'received (in seconds)'), 'received (in seconds)'),
] ]

View File

@ -20,8 +20,8 @@ from oslo_log import log
from vitrage.common.constants import EntityCategory from vitrage.common.constants import EntityCategory
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
from vitrage.datasources import OPENSTACK_NODE
from vitrage.evaluator.actions.evaluator_event_transformer import VITRAGE_TYPE from vitrage.evaluator.actions.evaluator_event_transformer import VITRAGE_TYPE
from vitrage.synchronizer.plugins import OPENSTACK_NODE
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
@ -94,7 +94,7 @@ class ConsistencyEnforcer(object):
'and': [ 'and': [
{'!=': {VProps.TYPE: VITRAGE_TYPE}}, {'!=': {VProps.TYPE: VITRAGE_TYPE}},
{'<': {VProps.SAMPLE_TIMESTAMP: str(utcnow() - timedelta( {'<': {VProps.SAMPLE_TIMESTAMP: str(utcnow() - timedelta(
seconds=2 * self.conf.synchronizer.snapshots_interval))}} seconds=2 * self.conf.datasources.snapshots_interval))}}
] ]
} }

View File

@ -47,10 +47,10 @@ class VitrageGraphConsistencyService(os_service.Service):
self.evaluator, self.evaluator,
self.entity_graph, self.entity_graph,
self.initialization_status) self.initialization_status)
self.tg.add_timer(self.conf.synchronizer.snapshots_interval, self.tg.add_timer(self.conf.datasources.snapshots_interval,
consistency_enf.periodic_process, consistency_enf.periodic_process,
initial_delay=60 + initial_delay=60 +
self.conf.synchronizer.snapshots_interval) self.conf.datasources.snapshots_interval)
initializing_process_thread = \ initializing_process_thread = \
threading.Thread(target=consistency_enf.initializing_process) threading.Thread(target=consistency_enf.initializing_process)

View File

@ -17,12 +17,12 @@ from oslo_log import log
from vitrage.common.constants import EventAction from vitrage.common.constants import EventAction
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.datasources.transformer_base import TransformerBase
from vitrage.entity_graph.processor import base as processor from vitrage.entity_graph.processor import base as processor
from vitrage.entity_graph.processor import entity_graph from vitrage.entity_graph.processor import entity_graph
from vitrage.entity_graph.states.state_manager import StateManager from vitrage.entity_graph.states.state_manager import StateManager
from vitrage.entity_graph.transformer_manager import TransformerManager from vitrage.entity_graph.transformer_manager import TransformerManager
from vitrage.graph import Direction from vitrage.graph import Direction
from vitrage.synchronizer.plugins.transformer_base import TransformerBase
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
@ -156,7 +156,7 @@ class Processor(processor.ProcessorBase):
self.initialization_status.end_messages[vertex[VProps.TYPE]] = True self.initialization_status.end_messages[vertex[VProps.TYPE]] = True
if len(self.initialization_status.end_messages) == \ if len(self.initialization_status.end_messages) == \
len(self.conf.plugins.plugin_type): len(self.conf.datasources.types):
self.initialization_status.status = \ self.initialization_status.status = \
self.initialization_status.RECEIVED_ALL_END_MESSAGES self.initialization_status.RECEIVED_ALL_END_MESSAGES

View File

@ -35,40 +35,45 @@ class StateManager(object):
def __init__(self, conf): def __init__(self, conf):
self.conf = conf self.conf = conf
self.category_normalizator = self._init_category_normalizator() self.category_normalizator = self._init_category_normalizator()
self.states_plugins = self._load_state_configurations() self.datasources_state_confs = self._load_state_configurations()
def normalize_state(self, category, plugin_name, state): def normalize_state(self, category, datasource_name, state):
upper_state = state if not state else state.upper() upper_state = state if not state else state.upper()
important_states = \ important_states = \
self.category_normalizator[category].important_states() self.category_normalizator[category].important_states()
if plugin_name in self.states_plugins: if datasource_name in self.datasources_state_confs:
return self.states_plugins[plugin_name][self.STATES][upper_state] \
if upper_state in \ states_conf = self.datasources_state_confs[datasource_name]
self.states_plugins[plugin_name][self.STATES] else \
self.states_plugins[plugin_name][important_states.unknown] return states_conf[self.STATES][upper_state] \
if upper_state in states_conf[self.STATES] \
else states_conf[important_states.unknown]
else: else:
return important_states.undefined return important_states.undefined
def state_priority(self, plugin_name, normalized_state): def state_priority(self, datasource_name, normalized_state):
# no need to check if normalized_state exists, cause it exists for sure # no need to check if normalized_state exists, cause it exists for sure
upper_state = normalized_state if not normalized_state else \ upper_state = normalized_state if not normalized_state else \
normalized_state.upper() normalized_state.upper()
if plugin_name in self.states_plugins: if datasource_name in self.datasources_state_confs:
return \ states_conf = self.datasources_state_confs[datasource_name]
self.states_plugins[plugin_name][self.PRIORITIES][upper_state] return states_conf[self.PRIORITIES][upper_state]
else: else:
# default UNDEFINED priority # default UNDEFINED priority
return 0 return 0
def aggregated_state(self, new_vertex, graph_vertex, is_normalized=False): def aggregated_state(self, new_vertex, graph_vertex, is_normalized=False):
plugin_name = new_vertex[VProps.TYPE] if VProps.TYPE in \ datasource_name = new_vertex[VProps.TYPE] if \
new_vertex.properties else graph_vertex[VProps.TYPE] VProps.TYPE in new_vertex.properties else \
category = new_vertex[VProps.CATEGORY] if VProps.CATEGORY in \ graph_vertex[VProps.TYPE]
new_vertex.properties else graph_vertex[VProps.CATEGORY]
if plugin_name in self.states_plugins: category = new_vertex[VProps.CATEGORY] if \
VProps.CATEGORY in new_vertex.properties else \
graph_vertex[VProps.CATEGORY]
if datasource_name in self.datasources_state_confs:
state_properties = \ state_properties = \
self.category_normalizator[category].state_properties() self.category_normalizator[category].state_properties()
normalized_state, state_priority = \ normalized_state, state_priority = \
@ -76,7 +81,7 @@ class StateManager(object):
graph_vertex, graph_vertex,
state_properties[0], state_properties[0],
category, category,
plugin_name, datasource_name,
is_normalized) is_normalized)
state_properties.pop(0) state_properties.pop(0)
@ -86,7 +91,7 @@ class StateManager(object):
graph_vertex, graph_vertex,
property_, property_,
category, category,
plugin_name, datasource_name,
is_normalized) is_normalized)
if tmp_state_priority > state_priority: if tmp_state_priority > state_priority:
normalized_state = tmp_normalized_state normalized_state = tmp_normalized_state
@ -106,33 +111,33 @@ class StateManager(object):
} }
def _load_state_configurations(self): def _load_state_configurations(self):
states_plugins = {} ok_datasources = {}
erroneous_plugins = [] erroneous_datasources = []
files = file_utils.load_files( files = file_utils.load_files(
self.conf.entity_graph.states_plugins_dir, '.yaml') self.conf.entity_graph.datasources_states_dir, '.yaml')
for file_name in files: for file_name in files:
try: try:
full_path = self.conf.entity_graph.states_plugins_dir + '/' \ full_path = self.conf.entity_graph.datasources_states_dir \
+ file_name + '/' + file_name
states, priorities = \ states, priorities = \
self._retrieve_states_and_priorities_from_file(full_path) self._retrieve_states_and_priorities_from_file(full_path)
states_plugins[os.path.splitext(file_name)[0]] = { ok_datasources[os.path.splitext(file_name)[0]] = {
self.STATES: states, self.STATES: states,
self.PRIORITIES: priorities self.PRIORITIES: priorities
} }
except Exception as e: except Exception as e:
LOG.exception("Exception: %s", e) LOG.exception("Exception: %s", e)
plugin = os.path.splitext(file_name)[0] datasource = os.path.splitext(file_name)[0]
LOG.error('erroneous plugins is %s', LOG.error('erroneous data sources is %s',
erroneous_plugins.append(plugin)) erroneous_datasources.append(datasource))
self._is_all_plugins_states_exists( self._check_state_confs_exists(
[key for key in states_plugins.keys()], [key for key in ok_datasources.keys()],
erroneous_plugins) erroneous_datasources)
return states_plugins return ok_datasources
def _retrieve_states_and_priorities_from_file(self, full_path): def _retrieve_states_and_priorities_from_file(self, full_path):
states = {} states = {}
@ -154,7 +159,7 @@ class StateManager(object):
priorities[normalized_state_name] = \ priorities[normalized_state_name] = \
int(normalized_state['priority']) int(normalized_state['priority'])
self.check_validity(category, states, priorities, full_path) self.check_validity(category, priorities, full_path)
return states, priorities return states, priorities
@ -164,7 +169,7 @@ class StateManager(object):
states[None] = state states[None] = state
priorities[NormalizedResourceState.UNDEFINED] = priority priorities[NormalizedResourceState.UNDEFINED] = priority
def check_validity(self, category, states, priorities, full_path): def check_validity(self, category, priorities, full_path):
important_states = \ important_states = \
self.category_normalizator[category].important_states() self.category_normalizator[category].important_states()
if important_states.unknown not in priorities: if important_states.unknown not in priorities:
@ -187,7 +192,7 @@ class StateManager(object):
graph_vertex, graph_vertex,
property_, property_,
category, category,
plugin_name, datasource_name,
is_normalized=False): is_normalized=False):
state = self._get_updated_property(new_vertex, state = self._get_updated_property(new_vertex,
graph_vertex, graph_vertex,
@ -196,9 +201,10 @@ class StateManager(object):
upper_state1 = state if not state else state.upper() upper_state1 = state if not state else state.upper()
normalized_state = upper_state1 if is_normalized else \ normalized_state = upper_state1 if is_normalized else \
self.normalize_state(category, plugin_name, upper_state1) self.normalize_state(category, datasource_name, upper_state1)
state_priority = self.state_priority(plugin_name, normalized_state) state_priority = self.state_priority(datasource_name,
normalized_state)
return normalized_state, state_priority return normalized_state, state_priority
@ -207,13 +213,17 @@ class StateManager(object):
return [attr for attr in dir(class_instance) if not callable(attr) and return [attr for attr in dir(class_instance) if not callable(attr) and
not attr.startswith("__")] not attr.startswith("__")]
def _is_all_plugins_states_exists(self, states_plugins, error_plugins): def _check_state_confs_exists(self,
plugin_types = self.conf.plugins.plugin_type ok_datasources,
all_state_loaded_plugins = states_plugins + error_plugins error_datasources):
for plugin_type in plugin_types: datasource_types = self.conf.datasources.types
if plugin_type not in all_state_loaded_plugins: datasources_with_state_conf = ok_datasources + error_datasources
LOG.error("No state configuration file for: %s", plugin_type)
for datasource_type in datasource_types:
if datasource_type not in datasources_with_state_conf:
LOG.error("No state configuration file for: %s",
datasource_type)
@staticmethod @staticmethod
def _get_updated_property(new_vertex, graph_vertex, prop): def _get_updated_property(new_vertex, graph_vertex, prop):

View File

@ -36,14 +36,14 @@ class TransformerManager(object):
def register_transformer_classes(conf): def register_transformer_classes(conf):
transformers = {} transformers = {}
for plugin in conf.plugins.plugin_type: for datasource_type in conf.datasources.types:
transformers[plugin] = importutils.import_object( transformers[datasource_type] = importutils.import_object(
conf[plugin].transformer, conf[datasource_type].transformer,
transformers) transformers)
if opt_exists(conf[plugin], ENTITIES): if opt_exists(conf[datasource_type], ENTITIES):
for entity in conf[plugin].entities: for entity in conf[datasource_type].entities:
transformers[entity] = importutils.import_object( transformers[entity] = importutils.import_object(
conf[plugin].transformer, transformers) conf[datasource_type].transformer, transformers)
transformers[VITRAGE_TYPE] = importutils.import_object( transformers[VITRAGE_TYPE] = importutils.import_object(
"%s.%s" % (EvaluatorEventTransformer.__module__, "%s.%s" % (EvaluatorEventTransformer.__module__,

View File

@ -20,6 +20,8 @@ from vitrage.common.constants import EntityCategory
from vitrage.common.constants import EventAction from vitrage.common.constants import EventAction
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.common.exception import VitrageTransformerError from vitrage.common.exception import VitrageTransformerError
from vitrage.datasources import transformer_base
from vitrage.datasources.transformer_base import Neighbor
from vitrage.evaluator.actions.recipes.action_steps import ADD_EDGE from vitrage.evaluator.actions.recipes.action_steps import ADD_EDGE
from vitrage.evaluator.actions.recipes.action_steps import ADD_VERTEX from vitrage.evaluator.actions.recipes.action_steps import ADD_VERTEX
from vitrage.evaluator.actions.recipes.action_steps import REMOVE_EDGE from vitrage.evaluator.actions.recipes.action_steps import REMOVE_EDGE
@ -29,8 +31,6 @@ from vitrage.evaluator.actions.recipes.base import EVALUATOR_EVENT_TYPE
from vitrage.evaluator.template_fields import TemplateFields as TFields from vitrage.evaluator.template_fields import TemplateFields as TFields
import vitrage.graph.utils as graph_utils import vitrage.graph.utils as graph_utils
from vitrage.graph import Vertex from vitrage.graph import Vertex
from vitrage.synchronizer.plugins import transformer_base
from vitrage.synchronizer.plugins.transformer_base import Neighbor
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -14,14 +14,13 @@
from vitrage.common.constants import NotifierEventTypes from vitrage.common.constants import NotifierEventTypes
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.evaluator.actions.recipes.action_steps import ADD_VERTEX from vitrage.evaluator.actions.recipes.action_steps import ADD_VERTEX
from vitrage.evaluator.actions.recipes.action_steps import NOTIFY from vitrage.evaluator.actions.recipes.action_steps import NOTIFY
from vitrage.evaluator.actions.recipes.action_steps import REMOVE_VERTEX from vitrage.evaluator.actions.recipes.action_steps import REMOVE_VERTEX
from vitrage.evaluator.actions.recipes import base from vitrage.evaluator.actions.recipes import base
from vitrage.evaluator.actions.recipes.base import ActionStepWrapper from vitrage.evaluator.actions.recipes.base import ActionStepWrapper
from vitrage.evaluator.template_fields import TemplateFields as TFields from vitrage.evaluator.template_fields import TemplateFields as TFields
from vitrage.synchronizer.plugins.base.alarm.properties \
import AlarmProperties as AlarmProps
class RaiseAlarm(base.Recipe): class RaiseAlarm(base.Recipe):

View File

@ -19,36 +19,31 @@ from oslo_utils import importutils
import vitrage.api import vitrage.api
import vitrage.clients import vitrage.clients
import vitrage.datasources
import vitrage.entity_graph.consistency import vitrage.entity_graph.consistency
import vitrage.evaluator import vitrage.evaluator
import vitrage.keystone_client import vitrage.keystone_client
import vitrage.rpc import vitrage.rpc
import vitrage.synchronizer
import vitrage.synchronizer.plugins
PLUGINS_MODULE_PATH = 'vitrage.synchronizer.plugins.' DATASOURCES_MODULE_PATH = 'vitrage.datasources.'
PLUGINS_FS_PATH = os.path.join('vitrage', 'synchronizer', 'plugins') DATASOURCE_FS_PATH = os.path.join('vitrage', 'datasources')
SYNCHRONIZER_FILE = 'synchronizer.py' DRIVER_FILE = 'driver.py'
TRANSFORMER_FILE = 'transformer.py' TRANSFORMER_FILE = 'alarm_transformer_base.py'
def list_opts(): def list_opts():
return [ return [
('api', vitrage.api.OPTS), ('api', vitrage.api.OPTS),
('synchronizer', vitrage.synchronizer.OPTS), ('datasources', vitrage.datasources.OPTS),
('evaluator', vitrage.evaluator.OPTS), ('evaluator', vitrage.evaluator.OPTS),
('plugins', vitrage.synchronizer.plugins.OPTS),
('consistency', vitrage.entity_graph.consistency.OPTS), ('consistency', vitrage.entity_graph.consistency.OPTS),
('entity_graph', vitrage.entity_graph.OPTS), ('entity_graph', vitrage.entity_graph.OPTS),
('service_credentials', vitrage.keystone_client.OPTS), ('service_credentials', vitrage.keystone_client.OPTS),
('DEFAULT', ('DEFAULT', itertools.chain(vitrage.clients.OPTS, vitrage.rpc.OPTS))
itertools.chain(
vitrage.clients.OPTS,
vitrage.rpc.OPTS))
] ]
def plugins_opts(): def datasources_opts():
top = os.getcwd() top = os.getcwd()
plugin_names = _normalize_path_to_plugin_name( plugin_names = _normalize_path_to_plugin_name(
_filter_folders_containing_transformer( _filter_folders_containing_transformer(
@ -56,14 +51,14 @@ def plugins_opts():
return [(plugin_name, plugin_module.OPTS) for plugin_name in plugin_names return [(plugin_name, plugin_module.OPTS) for plugin_name in plugin_names
for plugin_module in for plugin_module in
[importutils.import_module(PLUGINS_MODULE_PATH + plugin_name)] [importutils.import_module(DATASOURCES_MODULE_PATH + plugin_name)]
if 'OPTS' in plugin_module.__dict__] if 'OPTS' in plugin_module.__dict__]
def _get_folders_containing_synchronizer(top=os.getcwd()): def _get_folders_containing_synchronizer(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 == SYNCHRONIZER_FILE] for name in files if name == DRIVER_FILE]
def _filter_folders_containing_transformer(folders): def _filter_folders_containing_transformer(folders):
@ -73,5 +68,5 @@ def _filter_folders_containing_transformer(folders):
def _normalize_path_to_plugin_name(path_list, top=os.getcwd()): def _normalize_path_to_plugin_name(path_list, top=os.getcwd()):
return [os.path.relpath(path, os.path.join(top, PLUGINS_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

@ -38,8 +38,8 @@ def prepare_service(args=None, conf=None, config_files=None):
conf(args, project='vitrage', validate_default_values=True, conf(args, project='vitrage', validate_default_values=True,
default_config_files=config_files) default_config_files=config_files)
for plugin_name in conf.plugins.plugin_type: for datasource in conf.datasources.types:
load_plugin(conf, plugin_name, conf.plugins.plugin_path) load_datasource(conf, datasource, conf.datasources.path)
keystone_client.register_keystoneauth_opts(conf) keystone_client.register_keystoneauth_opts(conf)
@ -51,7 +51,7 @@ def prepare_service(args=None, conf=None, config_files=None):
return conf return conf
def load_plugin(conf, name, paths): def load_datasource(conf, name, paths):
for path in paths: for path in paths:
try: try:
opt = importutils.import_module("%s.%s" % (path, name)).OPTS opt = importutils.import_module("%s.%s" % (path, name)).OPTS

View File

@ -1,22 +0,0 @@
# Copyright 2016 - Alcatel-Lucent
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# 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 oslo_config import cfg
OPTS = [
cfg.IntOpt('snapshots_interval',
default=600,
min=10,
help='interval between full snapshots'),
]

View File

@ -1,46 +0,0 @@
# Copyright 2016 - Nokia
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# 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 oslo_config import cfg
from vitrage.synchronizer.plugins.aodh import AODH_PLUGIN
from vitrage.synchronizer.plugins.cinder.volume import CINDER_VOLUME_PLUGIN
from vitrage.synchronizer.plugins.nagios import NAGIOS_PLUGIN
from vitrage.synchronizer.plugins.neutron.network import NEUTRON_NETWORK_PLUGIN
from vitrage.synchronizer.plugins.neutron.port import NEUTRON_PORT_PLUGIN
from vitrage.synchronizer.plugins.nova.host import NOVA_HOST_PLUGIN
from vitrage.synchronizer.plugins.nova.instance import NOVA_INSTANCE_PLUGIN
from vitrage.synchronizer.plugins.nova.zone import NOVA_ZONE_PLUGIN
from vitrage.synchronizer.plugins.static_physical import STATIC_PHYSICAL_PLUGIN
OPENSTACK_NODE = 'openstack.node'
# Register options for the service
OPTS = [
cfg.ListOpt('plugin_type',
default=[NOVA_HOST_PLUGIN,
NOVA_INSTANCE_PLUGIN,
NOVA_ZONE_PLUGIN,
NAGIOS_PLUGIN,
STATIC_PHYSICAL_PLUGIN,
AODH_PLUGIN,
CINDER_VOLUME_PLUGIN,
NEUTRON_NETWORK_PLUGIN,
NEUTRON_PORT_PLUGIN],
help='Names of supported plugins'),
cfg.ListOpt('plugin_path',
default=['vitrage.synchronizer.plugins'],
help='base path for plugins')
]

View File

@ -1,43 +0,0 @@
# Copyright 2015 - Alcatel-Lucent
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# 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.
import multiprocessing
from vitrage.synchronizer.synchronizer import Synchronizer
class TestClient(object):
def queue_callback_function(self, output):
for entity in output:
self.queue.put(entity)
def print_queue(self):
while True:
entity = self.queue.get()
print(entity)
def __init__(self):
self.queue = multiprocessing.Queue()
self.synchronizer = Synchronizer(self.queue)
self.worker = multiprocessing.Process(target=self.print_queue)
def get_all(self):
self.synchronizer.get_all()
if __name__ == '__main__':
client = TestClient()
client.get_all()
client.worker.start()
client.worker.join()

View File

@ -16,7 +16,7 @@ from vitrage.common.constants import SynchronizerProperties as SyncProps
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
from vitrage.tests.mocks import mock_syncronizer as mock_sync from vitrage.tests.mocks import mock_driver
from vitrage.tests.unit.entity_graph.base import TestEntityGraphUnitBase from vitrage.tests.unit.entity_graph.base import TestEntityGraphUnitBase
@ -34,19 +34,19 @@ class TestFunctionalBase(TestEntityGraphUnitBase):
return processor return processor
def _create_mock_events(self): def _create_mock_events(self):
gen_list = mock_sync.simple_zone_generators( gen_list = mock_driver.simple_zone_generators(
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={SyncProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT})
gen_list += mock_sync.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={SyncProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT})
gen_list += mock_sync.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={SyncProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT})
return mock_sync.generate_sequential_events_list(gen_list) return mock_driver.generate_sequential_events_list(gen_list)

View File

@ -16,29 +16,28 @@ from oslo_config import cfg
from vitrage.common.constants import EntityCategory from vitrage.common.constants import EntityCategory
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.synchronizer.plugins import CINDER_VOLUME_PLUGIN from vitrage.datasources import CINDER_VOLUME_DATASOURCE
from vitrage.synchronizer.plugins import NAGIOS_PLUGIN from vitrage.datasources import NAGIOS_DATASOURCE
from vitrage.synchronizer.plugins import NOVA_HOST_PLUGIN from vitrage.datasources import NOVA_HOST_DATASOURCE
from vitrage.synchronizer.plugins import NOVA_INSTANCE_PLUGIN from vitrage.datasources import NOVA_INSTANCE_DATASOURCE
from vitrage.synchronizer.plugins import NOVA_ZONE_PLUGIN from vitrage.datasources import NOVA_ZONE_DATASOURCE
from vitrage.tests.functional.data_sources.base import \ from vitrage.tests.functional.datasources.base import TestDataSourcesBase
TestDataSourcesBase from vitrage.tests.mocks import mock_driver
from vitrage.tests.mocks import mock_syncronizer as mock_sync
class TestCinderVolume(TestDataSourcesBase): class TestCinderVolume(TestDataSourcesBase):
PLUGINS_OPTS = [ DATASOURCES_OPTS = [
cfg.ListOpt('plugin_type', cfg.ListOpt('types',
default=[NAGIOS_PLUGIN, default=[NAGIOS_DATASOURCE,
NOVA_HOST_PLUGIN, NOVA_HOST_DATASOURCE,
NOVA_INSTANCE_PLUGIN, NOVA_INSTANCE_DATASOURCE,
NOVA_ZONE_PLUGIN, NOVA_ZONE_DATASOURCE,
CINDER_VOLUME_PLUGIN], CINDER_VOLUME_DATASOURCE],
help='Names of supported driver data sources'), help='Names of supported driver data sources'),
cfg.ListOpt('plugin_path', cfg.ListOpt('path',
default=['vitrage.synchronizer.plugins'], default=['vitrage.datasources'],
help='base path for data sources') help='base path for data sources')
] ]
@ -47,8 +46,8 @@ class TestCinderVolume(TestDataSourcesBase):
super(TestCinderVolume, cls).setUpClass() super(TestCinderVolume, cls).setUpClass()
cls.conf = cfg.ConfigOpts() cls.conf = cfg.ConfigOpts()
cls.conf.register_opts(cls.PROCESSOR_OPTS, group='entity_graph') cls.conf.register_opts(cls.PROCESSOR_OPTS, group='entity_graph')
cls.conf.register_opts(cls.PLUGINS_OPTS, group='plugins') cls.conf.register_opts(cls.DATASOURCES_OPTS, group='datasources')
cls.load_plugins(cls.conf) cls.load_datasources(cls.conf)
def test_cinder_volume_validity(self): def test_cinder_volume_validity(self):
# Setup # Setup
@ -56,15 +55,15 @@ class TestCinderVolume(TestDataSourcesBase):
self.assertEqual(self._num_total_expected_vertices(), self.assertEqual(self._num_total_expected_vertices(),
len(processor.entity_graph)) len(processor.entity_graph))
spec_list = mock_sync.simple_volume_generators( spec_list = mock_driver.simple_volume_generators(
volume_num=1, volume_num=1,
instance_num=1, instance_num=1,
snapshot_events=1) snapshot_events=1)
static_events = mock_sync.generate_random_events_list(spec_list) static_events = mock_driver.generate_random_events_list(spec_list)
cinder_volume_event = static_events[0] cinder_volume_event = static_events[0]
cinder_volume_event['attachments'][0]['server_id'] = \ cinder_volume_event['attachments'][0]['server_id'] = \
self._find_entity_id_by_type(processor.entity_graph, self._find_entity_id_by_type(processor.entity_graph,
NOVA_INSTANCE_PLUGIN) NOVA_INSTANCE_DATASOURCE)
# Action # Action
processor.process_event(cinder_volume_event) processor.process_event(cinder_volume_event)
@ -76,7 +75,7 @@ class TestCinderVolume(TestDataSourcesBase):
cinder_vertices = processor.entity_graph.get_vertices( cinder_vertices = processor.entity_graph.get_vertices(
vertex_attr_filter={ vertex_attr_filter={
VProps.CATEGORY: EntityCategory.RESOURCE, VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.TYPE: CINDER_VOLUME_PLUGIN VProps.TYPE: CINDER_VOLUME_DATASOURCE
}) })
self.assertEqual(1, len(cinder_vertices)) self.assertEqual(1, len(cinder_vertices))
@ -84,5 +83,5 @@ class TestCinderVolume(TestDataSourcesBase):
cinder_vertices[0].vertex_id) cinder_vertices[0].vertex_id)
self.assertEqual(1, len(cinder_neighbors)) self.assertEqual(1, len(cinder_neighbors))
self.assertEqual(NOVA_INSTANCE_PLUGIN, self.assertEqual(NOVA_INSTANCE_DATASOURCE,
cinder_neighbors[0][VProps.TYPE]) cinder_neighbors[0][VProps.TYPE])

View File

@ -16,28 +16,28 @@ from oslo_config import cfg
from vitrage.common.constants import EntityCategory from vitrage.common.constants import EntityCategory
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.synchronizer.plugins import NAGIOS_PLUGIN from vitrage.datasources import NAGIOS_DATASOURCE
from vitrage.synchronizer.plugins import NOVA_HOST_PLUGIN from vitrage.datasources import NOVA_HOST_DATASOURCE
from vitrage.synchronizer.plugins import NOVA_INSTANCE_PLUGIN from vitrage.datasources import NOVA_INSTANCE_DATASOURCE
from vitrage.synchronizer.plugins import NOVA_ZONE_PLUGIN from vitrage.datasources import NOVA_ZONE_DATASOURCE
from vitrage.tests.functional.data_sources.base import \ from vitrage.tests.functional.datasources.base import \
TestDataSourcesBase TestDataSourcesBase
from vitrage.tests.mocks import mock_syncronizer as mock_sync from vitrage.tests.mocks import mock_driver
class TestNagios(TestDataSourcesBase): class TestNagios(TestDataSourcesBase):
PLUGINS_OPTS = [ DATASOURCES_OPTS = [
cfg.ListOpt('plugin_type', cfg.ListOpt('types',
default=[NAGIOS_PLUGIN, default=[NAGIOS_DATASOURCE,
NOVA_HOST_PLUGIN, NOVA_HOST_DATASOURCE,
NOVA_INSTANCE_PLUGIN, NOVA_INSTANCE_DATASOURCE,
NOVA_ZONE_PLUGIN, NOVA_ZONE_DATASOURCE,
NAGIOS_PLUGIN], NAGIOS_DATASOURCE],
help='Names of supported driver data sources'), help='Names of supported driver data sources'),
cfg.ListOpt('plugin_path', cfg.ListOpt('path',
default=['vitrage.synchronizer.plugins'], default=['vitrage.datasources'],
help='base path for data sources') help='base path for data sources')
] ]
@ -46,8 +46,8 @@ class TestNagios(TestDataSourcesBase):
super(TestNagios, cls).setUpClass() super(TestNagios, cls).setUpClass()
cls.conf = cfg.ConfigOpts() cls.conf = cfg.ConfigOpts()
cls.conf.register_opts(cls.PROCESSOR_OPTS, group='entity_graph') cls.conf.register_opts(cls.PROCESSOR_OPTS, group='entity_graph')
cls.conf.register_opts(cls.PLUGINS_OPTS, group='plugins') cls.conf.register_opts(cls.DATASOURCES_OPTS, group='datasources')
cls.load_plugins(cls.conf) cls.load_datasources(cls.conf)
def test_nagios_validity(self): def test_nagios_validity(self):
# Setup # Setup
@ -55,14 +55,14 @@ class TestNagios(TestDataSourcesBase):
self.assertEqual(self._num_total_expected_vertices(), self.assertEqual(self._num_total_expected_vertices(),
len(processor.entity_graph)) len(processor.entity_graph))
spec_list = mock_sync.simple_nagios_alarm_generators( spec_list = mock_driver.simple_nagios_alarm_generators(
host_num=1, host_num=1,
events_num=1) events_num=1)
static_events = mock_sync.generate_random_events_list(spec_list) static_events = mock_driver.generate_random_events_list(spec_list)
nagios_event = static_events[0] nagios_event = static_events[0]
nagios_event['resource_name'] = \ nagios_event['resource_name'] = \
self._find_entity_id_by_type(processor.entity_graph, self._find_entity_id_by_type(processor.entity_graph,
NOVA_HOST_PLUGIN) NOVA_HOST_DATASOURCE)
nagios_event['status'] = 'critical' nagios_event['status'] = 'critical'
# Action # Action
@ -75,7 +75,7 @@ class TestNagios(TestDataSourcesBase):
nagios_vertices = processor.entity_graph.get_vertices( nagios_vertices = processor.entity_graph.get_vertices(
vertex_attr_filter={ vertex_attr_filter={
VProps.CATEGORY: EntityCategory.ALARM, VProps.CATEGORY: EntityCategory.ALARM,
VProps.TYPE: NAGIOS_PLUGIN VProps.TYPE: NAGIOS_DATASOURCE
}) })
self.assertEqual(1, len(nagios_vertices)) self.assertEqual(1, len(nagios_vertices))
@ -83,5 +83,5 @@ class TestNagios(TestDataSourcesBase):
nagios_vertices[0].vertex_id) nagios_vertices[0].vertex_id)
self.assertEqual(1, len(nagios_neighbors)) self.assertEqual(1, len(nagios_neighbors))
self.assertEqual(NOVA_HOST_PLUGIN, self.assertEqual(NOVA_HOST_DATASOURCE,
nagios_neighbors[0][VProps.TYPE]) nagios_neighbors[0][VProps.TYPE])

View File

@ -14,21 +14,21 @@
from oslo_config import cfg from oslo_config import cfg
from vitrage.tests.functional.data_sources.base import \ from vitrage.tests.functional.datasources.base import \
TestDataSourcesBase TestDataSourcesBase
class TestNovaPlugins(TestDataSourcesBase): class TestNovaDatasources(TestDataSourcesBase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
super(TestNovaPlugins, cls).setUpClass() super(TestNovaDatasources, cls).setUpClass()
cls.conf = cfg.ConfigOpts() cls.conf = cfg.ConfigOpts()
cls.conf.register_opts(cls.PROCESSOR_OPTS, group='entity_graph') cls.conf.register_opts(cls.PROCESSOR_OPTS, group='entity_graph')
cls.conf.register_opts(cls.PLUGINS_OPTS, group='plugins') cls.conf.register_opts(cls.DATASOURCES_OPTS, group='datasources')
cls.load_plugins(cls.conf) cls.load_datasources(cls.conf)
def test_nova_plugins(self): def test_nova_datasources(self):
processor = self._create_processor_with_graph(self.conf) processor = self._create_processor_with_graph(self.conf)
self.assertEqual(self._num_total_expected_vertices(), self.assertEqual(self._num_total_expected_vertices(),

View File

@ -17,30 +17,30 @@ from oslo_config import cfg
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 SynchronizerProperties as SyncProps
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.synchronizer.plugins import NAGIOS_PLUGIN from vitrage.datasources import NAGIOS_DATASOURCE
from vitrage.synchronizer.plugins import NOVA_HOST_PLUGIN from vitrage.datasources import NOVA_HOST_DATASOURCE
from vitrage.synchronizer.plugins import NOVA_INSTANCE_PLUGIN from vitrage.datasources import NOVA_INSTANCE_DATASOURCE
from vitrage.synchronizer.plugins import NOVA_ZONE_PLUGIN from vitrage.datasources import NOVA_ZONE_DATASOURCE
from vitrage.synchronizer.plugins.static_physical import STATIC_PHYSICAL_PLUGIN from vitrage.datasources.static_physical import STATIC_PHYSICAL_DATASOURCE
from vitrage.synchronizer.plugins.static_physical import SWITCH from vitrage.datasources.static_physical import SWITCH
from vitrage.tests.functional.data_sources.base import \ from vitrage.tests.functional.datasources.base import \
TestDataSourcesBase TestDataSourcesBase
from vitrage.tests.mocks import mock_syncronizer as mock_sync from vitrage.tests.mocks import mock_driver
class TestStaticPhysical(TestDataSourcesBase): class TestStaticPhysical(TestDataSourcesBase):
PLUGINS_OPTS = [ DATASOURCES_OPTS = [
cfg.ListOpt('plugin_type', cfg.ListOpt('types',
default=[NAGIOS_PLUGIN, default=[NAGIOS_DATASOURCE,
NOVA_HOST_PLUGIN, NOVA_HOST_DATASOURCE,
NOVA_INSTANCE_PLUGIN, NOVA_INSTANCE_DATASOURCE,
NOVA_ZONE_PLUGIN, NOVA_ZONE_DATASOURCE,
STATIC_PHYSICAL_PLUGIN], STATIC_PHYSICAL_DATASOURCE],
help='Names of supported driver data sources'), help='Names of supported driver data sources'),
cfg.ListOpt('plugin_path', cfg.ListOpt('path',
default=['vitrage.synchronizer.plugins'], default=['vitrage.datasources'],
help='base path for data sources') help='base path for data sources')
] ]
@ -49,27 +49,27 @@ class TestStaticPhysical(TestDataSourcesBase):
super(TestStaticPhysical, cls).setUpClass() super(TestStaticPhysical, cls).setUpClass()
cls.conf = cfg.ConfigOpts() cls.conf = cfg.ConfigOpts()
cls.conf.register_opts(cls.PROCESSOR_OPTS, group='entity_graph') cls.conf.register_opts(cls.PROCESSOR_OPTS, group='entity_graph')
cls.conf.register_opts(cls.PLUGINS_OPTS, group='plugins') cls.conf.register_opts(cls.DATASOURCES_OPTS, group='datasources')
cls.load_plugins(cls.conf) cls.load_datasources(cls.conf)
def test_static_physical_validity(self): def test_static_physical_validity(self):
# Setup # Setup
processor = self._create_processor_with_graph(self.conf) processor = self._create_processor_with_graph(self.conf)
processor.transformer_manager.transformers[SWITCH] = \ transformers = processor.transformer_manager.transformers
processor.transformer_manager.transformers[STATIC_PHYSICAL_PLUGIN] transformers[SWITCH] = transformers[STATIC_PHYSICAL_DATASOURCE]
self.assertEqual(self._num_total_expected_vertices(), self.assertEqual(self._num_total_expected_vertices(),
len(processor.entity_graph)) len(processor.entity_graph))
spec_list = mock_sync.simple_switch_generators( spec_list = mock_driver.simple_switch_generators(
switch_num=1, switch_num=1,
host_num=1, host_num=1,
snapshot_events=1) snapshot_events=1)
static_events = mock_sync.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[SyncProps.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_PLUGIN) NOVA_HOST_DATASOURCE)
# Action # Action
processor.process_event(static_physical_event) processor.process_event(static_physical_event)
@ -89,5 +89,5 @@ class TestStaticPhysical(TestDataSourcesBase):
static_physical_vertices[0].vertex_id) static_physical_vertices[0].vertex_id)
self.assertEqual(1, len(static_physical_neighbors)) self.assertEqual(1, len(static_physical_neighbors))
self.assertEqual(NOVA_HOST_PLUGIN, self.assertEqual(NOVA_HOST_DATASOURCE,
static_physical_neighbors[0][VProps.TYPE]) static_physical_neighbors[0][VProps.TYPE])

View File

@ -24,6 +24,10 @@ from vitrage.common.constants import EdgeLabels
from vitrage.common.constants import EntityCategory from vitrage.common.constants import EntityCategory
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
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
from vitrage.datasources.nova.zone import NOVA_ZONE_DATASOURCE
from vitrage.entity_graph.consistency.consistency_enforcer \ from vitrage.entity_graph.consistency.consistency_enforcer \
import ConsistencyEnforcer import ConsistencyEnforcer
from vitrage.entity_graph.initialization_status import InitializationStatus from vitrage.entity_graph.initialization_status import InitializationStatus
@ -32,12 +36,7 @@ from vitrage.evaluator.actions.evaluator_event_transformer import VITRAGE_TYPE
from vitrage.evaluator.scenario_evaluator import ScenarioEvaluator from vitrage.evaluator.scenario_evaluator import ScenarioEvaluator
from vitrage.evaluator.scenario_repository import ScenarioRepository from vitrage.evaluator.scenario_repository import ScenarioRepository
import vitrage.graph.utils as graph_utils import vitrage.graph.utils as graph_utils
from vitrage.synchronizer.plugins.nagios import NAGIOS_PLUGIN from vitrage.tests.functional.base import TestFunctionalBase
from vitrage.synchronizer.plugins.nova.host import NOVA_HOST_PLUGIN
from vitrage.synchronizer.plugins.nova.instance import NOVA_INSTANCE_PLUGIN
from vitrage.synchronizer.plugins.nova.zone import NOVA_ZONE_PLUGIN
from vitrage.tests.functional.base import \
TestFunctionalBase
from vitrage.tests.mocks import utils from vitrage.tests.mocks import utils
@ -54,12 +53,6 @@ class TestConsistencyFunctional(TestFunctionalBase):
default=10), default=10),
] ]
SYNCHRONIZER_OPTS = [
cfg.IntOpt('snapshots_interval',
default=1,
min=1),
]
EVALUATOR_OPTS = [ EVALUATOR_OPTS = [
cfg.StrOpt('templates_dir', cfg.StrOpt('templates_dir',
default=utils.get_resources_dir() + default=utils.get_resources_dir() +
@ -79,9 +72,8 @@ class TestConsistencyFunctional(TestFunctionalBase):
cls.conf.register_opts(cls.CONSISTENCY_OPTS, group='consistency') cls.conf.register_opts(cls.CONSISTENCY_OPTS, group='consistency')
cls.conf.register_opts(cls.PROCESSOR_OPTS, group='entity_graph') cls.conf.register_opts(cls.PROCESSOR_OPTS, group='entity_graph')
cls.conf.register_opts(cls.EVALUATOR_OPTS, group='evaluator') cls.conf.register_opts(cls.EVALUATOR_OPTS, group='evaluator')
cls.conf.register_opts(cls.SYNCHRONIZER_OPTS, group='synchronizer') cls.conf.register_opts(cls.DATASOURCES_OPTS, group='datasources')
cls.conf.register_opts(cls.PLUGINS_OPTS, group='plugins') cls.load_datasources(cls.conf)
cls.load_plugins(cls.conf)
cls.processor = Processor(cls.conf, cls.initialization_status) cls.processor = Processor(cls.conf, cls.initialization_status)
cls.event_queue = queue.Queue() cls.event_queue = queue.Queue()
@ -150,7 +142,7 @@ class TestConsistencyFunctional(TestFunctionalBase):
def test_periodic_process(self): def test_periodic_process(self):
# Setup # Setup
consistency_interval = self.conf.synchronizer.snapshots_interval consistency_interval = self.conf.datasources.snapshots_interval
self._periodic_process_setup_stage(consistency_interval) self._periodic_process_setup_stage(consistency_interval)
# Action # Action
@ -160,18 +152,18 @@ class TestConsistencyFunctional(TestFunctionalBase):
# Test Assertions # Test Assertions
instance_vertices = self.processor.entity_graph.get_vertices({ instance_vertices = self.processor.entity_graph.get_vertices({
VProps.CATEGORY: EntityCategory.RESOURCE, VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.TYPE: NOVA_INSTANCE_PLUGIN VProps.TYPE: NOVA_INSTANCE_DATASOURCE
}) })
is_deleted_instance_vertices = \ deleted_instance_vertices = \
self.processor.entity_graph.get_vertices({ self.processor.entity_graph.get_vertices({
VProps.CATEGORY: EntityCategory.RESOURCE, VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.TYPE: NOVA_INSTANCE_PLUGIN, VProps.TYPE: NOVA_INSTANCE_DATASOURCE,
VProps.IS_DELETED: True VProps.IS_DELETED: True
}) })
self.assertEqual(self.NUM_INSTANCES - 3, len(instance_vertices)) self.assertEqual(self.NUM_INSTANCES - 3, len(instance_vertices))
self.assertEqual(self._num_total_expected_vertices() - 3, self.assertEqual(self._num_total_expected_vertices() - 3,
len(self.processor.entity_graph.get_vertices())) len(self.processor.entity_graph.get_vertices()))
self.assertEqual(6, len(is_deleted_instance_vertices)) self.assertEqual(6, len(deleted_instance_vertices))
def _periodic_process_setup_stage(self, consistency_interval): def _periodic_process_setup_stage(self, consistency_interval):
self._create_processor_with_graph(self.conf, processor=self.processor) self._create_processor_with_graph(self.conf, processor=self.processor)
@ -185,7 +177,7 @@ class TestConsistencyFunctional(TestFunctionalBase):
# check number of instances in graph # check number of instances in graph
instance_vertices = self.processor.entity_graph.get_vertices({ instance_vertices = self.processor.entity_graph.get_vertices({
VProps.CATEGORY: EntityCategory.RESOURCE, VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.TYPE: NOVA_INSTANCE_PLUGIN VProps.TYPE: NOVA_INSTANCE_DATASOURCE
}) })
self.assertEqual(self.NUM_INSTANCES, len(instance_vertices)) self.assertEqual(self.NUM_INSTANCES, len(instance_vertices))
@ -205,11 +197,11 @@ class TestConsistencyFunctional(TestFunctionalBase):
self.processor.entity_graph.update_vertex(instance_vertices[i]) self.processor.entity_graph.update_vertex(instance_vertices[i])
def _set_end_messages(self): def _set_end_messages(self):
self.initialization_status.end_messages[NOVA_ZONE_PLUGIN] = True self.initialization_status.end_messages[NOVA_ZONE_DATASOURCE] = True
self.initialization_status.end_messages[NOVA_HOST_PLUGIN] = True self.initialization_status.end_messages[NOVA_HOST_DATASOURCE] = True
self.initialization_status.end_messages[NOVA_INSTANCE_PLUGIN] = \ self.initialization_status.end_messages[NOVA_INSTANCE_DATASOURCE] = \
True True
self.initialization_status.end_messages[NAGIOS_PLUGIN] = True self.initialization_status.end_messages[NAGIOS_DATASOURCE] = True
self.initialization_status.status = \ self.initialization_status.status = \
self.initialization_status.RECEIVED_ALL_END_MESSAGES self.initialization_status.RECEIVED_ALL_END_MESSAGES
@ -217,7 +209,7 @@ class TestConsistencyFunctional(TestFunctionalBase):
# find hosts and instances # find hosts and instances
host_vertices = self.processor.entity_graph.get_vertices({ host_vertices = self.processor.entity_graph.get_vertices({
VProps.CATEGORY: EntityCategory.RESOURCE, VProps.CATEGORY: EntityCategory.RESOURCE,
VProps.TYPE: NOVA_HOST_PLUGIN VProps.TYPE: NOVA_HOST_DATASOURCE
}) })
# add host alarms + deduced alarms # add host alarms + deduced alarms
@ -227,7 +219,7 @@ class TestConsistencyFunctional(TestFunctionalBase):
alarm_name = '%s:%s' % ('nagios_alarm_on_host_', alarm_name = '%s:%s' % ('nagios_alarm_on_host_',
host_vertex[VProps.NAME]) host_vertex[VProps.NAME])
alarms_on_hosts_list.append( alarms_on_hosts_list.append(
self._create_alarm(alarm_name, NAGIOS_PLUGIN)) self._create_alarm(alarm_name, NAGIOS_DATASOURCE))
self.processor.entity_graph.add_vertex(alarms_on_hosts_list[index]) self.processor.entity_graph.add_vertex(alarms_on_hosts_list[index])
edge = graph_utils.create_edge( edge = graph_utils.create_edge(
alarms_on_hosts_list[index].vertex_id, alarms_on_hosts_list[index].vertex_id,

View File

@ -30,8 +30,8 @@ class TestProcessorFunctional(TestFunctionalBase):
super(TestProcessorFunctional, cls).setUpClass() super(TestProcessorFunctional, cls).setUpClass()
cls.conf = cfg.ConfigOpts() cls.conf = cfg.ConfigOpts()
cls.conf.register_opts(cls.PROCESSOR_OPTS, group='entity_graph') cls.conf.register_opts(cls.PROCESSOR_OPTS, group='entity_graph')
cls.conf.register_opts(cls.PLUGINS_OPTS, group='plugins') cls.conf.register_opts(cls.DATASOURCES_OPTS, group='datasources')
cls.load_plugins(cls.conf) cls.load_datasources(cls.conf)
def test_create_entity_graph(self): def test_create_entity_graph(self):
processor = self._create_processor_with_graph(self.conf) processor = self._create_processor_with_graph(self.conf)

View File

@ -17,14 +17,12 @@ from oslo_config import cfg
from vitrage.common.constants import EventAction from vitrage.common.constants import EventAction
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.nova.instance.transformer import InstanceTransformer
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
from vitrage.entity_graph.states.normalized_resource_state import \ from vitrage.entity_graph.states.normalized_resource_state import \
NormalizedResourceState NormalizedResourceState
from vitrage.synchronizer.plugins.nova.instance.transformer import \ from vitrage.tests.functional.base import TestFunctionalBase
InstanceTransformer
from vitrage.tests.functional.base import \
TestFunctionalBase
class TestStateManagerFunctional(TestFunctionalBase): class TestStateManagerFunctional(TestFunctionalBase):
@ -35,8 +33,8 @@ class TestStateManagerFunctional(TestFunctionalBase):
super(TestStateManagerFunctional, cls).setUpClass() super(TestStateManagerFunctional, cls).setUpClass()
cls.conf = cfg.ConfigOpts() cls.conf = cfg.ConfigOpts()
cls.conf.register_opts(cls.PROCESSOR_OPTS, group='entity_graph') cls.conf.register_opts(cls.PROCESSOR_OPTS, group='entity_graph')
cls.conf.register_opts(cls.PLUGINS_OPTS, group='plugins') cls.conf.register_opts(cls.DATASOURCES_OPTS, group='datasources')
cls.load_plugins(cls.conf) cls.load_datasources(cls.conf)
def test_state_on_update(self): def test_state_on_update(self):
# setup # setup

View File

@ -20,6 +20,9 @@ from six.moves import queue
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 VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.datasources.alarm_properties import AlarmProperties as AlarmProps
from vitrage.datasources.nagios import NAGIOS_DATASOURCE
from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
from vitrage.entity_graph.states.normalized_resource_state import \ from vitrage.entity_graph.states.normalized_resource_state import \
NormalizedResourceState NormalizedResourceState
from vitrage.evaluator.actions.action_executor import ActionExecutor from vitrage.evaluator.actions.action_executor import ActionExecutor
@ -28,13 +31,8 @@ from vitrage.evaluator.actions.base import ActionType
from vitrage.evaluator.actions.evaluator_event_transformer import VITRAGE_TYPE from vitrage.evaluator.actions.evaluator_event_transformer import VITRAGE_TYPE
from vitrage.evaluator.template import ActionSpecs from vitrage.evaluator.template import ActionSpecs
from vitrage.evaluator.template_fields import TemplateFields as TFields from vitrage.evaluator.template_fields import TemplateFields as TFields
from vitrage.service import load_plugin from vitrage.service import load_datasource
from vitrage.synchronizer.plugins.base.alarm.properties \ from vitrage.tests.functional.base import TestFunctionalBase
import AlarmProperties as AlarmProps
from vitrage.synchronizer.plugins.nagios import NAGIOS_PLUGIN
from vitrage.synchronizer.plugins.nova.host import NOVA_HOST_PLUGIN
from vitrage.tests.functional.base import \
TestFunctionalBase
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -46,16 +44,19 @@ class TestActionExecutor(TestFunctionalBase):
def setUpClass(cls): def setUpClass(cls):
cls.conf = cfg.ConfigOpts() cls.conf = cfg.ConfigOpts()
cls.conf.register_opts(cls.PROCESSOR_OPTS, group='entity_graph') cls.conf.register_opts(cls.PROCESSOR_OPTS, group='entity_graph')
cls.conf.register_opts(cls.PLUGINS_OPTS, group='plugins') cls.conf.register_opts(cls.DATASOURCES_OPTS, group='datasources')
for plugin_name in cls.conf.plugins.plugin_type:
load_plugin(cls.conf, plugin_name, cls.conf.plugins.plugin_path) for datasource_name in cls.conf.datasources.types:
load_datasource(cls.conf,
datasource_name,
cls.conf.datasources.path)
def test_execute_update_vertex(self): def test_execute_update_vertex(self):
# Test Setup # Test Setup
processor = self._create_processor_with_graph(self.conf) processor = self._create_processor_with_graph(self.conf)
vertex_attrs = {VProps.TYPE: NOVA_HOST_PLUGIN} vertex_attrs = {VProps.TYPE: NOVA_HOST_DATASOURCE}
host_vertices = processor.entity_graph.get_vertices( host_vertices = processor.entity_graph.get_vertices(
vertex_attr_filter=vertex_attrs) vertex_attr_filter=vertex_attrs)
host_vertex_before = host_vertices[0] host_vertex_before = host_vertices[0]
@ -102,21 +103,21 @@ class TestActionExecutor(TestFunctionalBase):
# Test Setup # Test Setup
processor = self._create_processor_with_graph(self.conf) processor = self._create_processor_with_graph(self.conf)
vertex_attrs = {VProps.TYPE: NOVA_HOST_PLUGIN} vertex_attrs = {VProps.TYPE: NOVA_HOST_DATASOURCE}
host_vertices = processor.entity_graph.get_vertices( host_vertices = processor.entity_graph.get_vertices(
vertex_attr_filter=vertex_attrs) vertex_attr_filter=vertex_attrs)
host_1 = host_vertices[0] host_1 = host_vertices[0]
nagios_event1 = TestActionExecutor._get_nagios_event( nagios_event1 = TestActionExecutor._get_nagios_event(
host_1.get(VProps.ID), NOVA_HOST_PLUGIN) host_1.get(VProps.ID), NOVA_HOST_DATASOURCE)
processor.process_event(nagios_event1) processor.process_event(nagios_event1)
host_2 = host_vertices[1] host_2 = host_vertices[1]
nagios_event2 = TestActionExecutor._get_nagios_event( nagios_event2 = TestActionExecutor._get_nagios_event(
host_2.get(VProps.ID), NOVA_HOST_PLUGIN) host_2.get(VProps.ID), NOVA_HOST_DATASOURCE)
processor.process_event(nagios_event2) processor.process_event(nagios_event2)
alarms_attrs = {VProps.TYPE: NAGIOS_PLUGIN} alarms_attrs = {VProps.TYPE: NAGIOS_DATASOURCE}
alarms_vertices = processor.entity_graph.get_vertices( alarms_vertices = processor.entity_graph.get_vertices(
vertex_attr_filter=alarms_attrs) vertex_attr_filter=alarms_attrs)
@ -152,7 +153,7 @@ class TestActionExecutor(TestFunctionalBase):
# Test Setup # Test Setup
processor = self._create_processor_with_graph(self.conf) processor = self._create_processor_with_graph(self.conf)
vertex_attrs = {VProps.TYPE: NOVA_HOST_PLUGIN} vertex_attrs = {VProps.TYPE: NOVA_HOST_DATASOURCE}
host_vertices = processor.entity_graph.get_vertices( host_vertices = processor.entity_graph.get_vertices(
vertex_attr_filter=vertex_attrs) vertex_attr_filter=vertex_attrs)
@ -209,7 +210,7 @@ class TestActionExecutor(TestFunctionalBase):
# Test Setup # Test Setup
processor = self._create_processor_with_graph(self.conf) processor = self._create_processor_with_graph(self.conf)
vertex_attrs = {VProps.TYPE: NOVA_HOST_PLUGIN} vertex_attrs = {VProps.TYPE: NOVA_HOST_DATASOURCE}
host_vertices = processor.entity_graph.get_vertices( host_vertices = processor.entity_graph.get_vertices(
vertex_attr_filter=vertex_attrs) vertex_attr_filter=vertex_attrs)

View File

@ -17,9 +17,9 @@ from oslo_log import log as logging
from six.moves import queue from six.moves import queue
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.evaluator.scenario_evaluator import ScenarioEvaluator from vitrage.evaluator.scenario_evaluator import ScenarioEvaluator
from vitrage.evaluator.scenario_repository import ScenarioRepository from vitrage.evaluator.scenario_repository import ScenarioRepository
from vitrage.synchronizer.plugins.nova.host import NOVA_HOST_PLUGIN
from vitrage.tests.functional.base import \ from vitrage.tests.functional.base import \
TestFunctionalBase TestFunctionalBase
from vitrage.tests.mocks import utils from vitrage.tests.mocks import utils
@ -45,8 +45,8 @@ class TestScenarioEvaluator(TestFunctionalBase):
cls.conf = cfg.ConfigOpts() cls.conf = cfg.ConfigOpts()
cls.conf.register_opts(cls.PROCESSOR_OPTS, group='entity_graph') cls.conf.register_opts(cls.PROCESSOR_OPTS, group='entity_graph')
cls.conf.register_opts(cls.EVALUATOR_OPTS, group='evaluator') cls.conf.register_opts(cls.EVALUATOR_OPTS, group='evaluator')
cls.conf.register_opts(cls.PLUGINS_OPTS, group='plugins') cls.conf.register_opts(cls.DATASOURCES_OPTS, group='datasources')
TestScenarioEvaluator.load_plugins(cls.conf) TestScenarioEvaluator.load_datasources(cls.conf)
cls.scenario_repository = ScenarioRepository(cls.conf) cls.scenario_repository = ScenarioRepository(cls.conf)
def test_deduced_state(self): def test_deduced_state(self):
@ -67,7 +67,7 @@ class TestScenarioEvaluator(TestFunctionalBase):
nagios_event = {'last_check': '2016-02-07 15:26:04', nagios_event = {'last_check': '2016-02-07 15:26:04',
'resource_name': target_host, 'resource_name': target_host,
'resource_type': NOVA_HOST_PLUGIN, 'resource_type': NOVA_HOST_DATASOURCE,
'service': 'Check_MK', 'service': 'Check_MK',
'status': 'CRITICAL', 'status': 'CRITICAL',
'status_info': 'ok', 'status_info': 'ok',
@ -94,7 +94,7 @@ class TestScenarioEvaluator(TestFunctionalBase):
@staticmethod @staticmethod
def _get_host_from_graph(host_name, entity_graph): def _get_host_from_graph(host_name, entity_graph):
vertex_attrs = {VProps.TYPE: NOVA_HOST_PLUGIN, vertex_attrs = {VProps.TYPE: NOVA_HOST_DATASOURCE,
VProps.NAME: host_name} VProps.NAME: host_name}
host_vertices = entity_graph.get_vertices( host_vertices = entity_graph.get_vertices(
vertex_attr_filter=vertex_attrs) vertex_attr_filter=vertex_attrs)

View File

@ -13,15 +13,15 @@
# under the License. # under the License.
"""Methods for generating synchronizer events """Methods for generating driver events
For each type of entity, need to supply configuration files that specify (a For each type of entity, need to supply configuration files that specify (a
regex of) what can be returned, which will be used to generate sync events regex of) what can be returned, which will be used to generate driver events
usage example: usage example:
test_entity_spec_list = [ test_entity_spec_list = [
{mg.DYNAMIC_INFO_FKEY: 'sync_inst_snapshot_dynamic.json', {mg.DYNAMIC_INFO_FKEY: 'driver_inst_snapshot_dynamic.json',
mg.STATIC_INFO_FKEY: 'sync_inst_snapshot_static.json', mg.STATIC_INFO_FKEY: 'driver_inst_snapshot_static.json',
mg.MAPPING_KEY: [('vm1', 'host1'), ('vm2', 'host1'), ('vm3','host2')], mg.MAPPING_KEY: [('vm1', 'host1'), ('vm2', 'host1'), ('vm3','host2')],
mg.NAME_KEY: 'Instance (vm) generator', mg.NAME_KEY: 'Instance (vm) generator',
NUM_EVENTS_KEY: 10 NUM_EVENTS_KEY: 10
@ -47,7 +47,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 driver events
:rtype list :rtype list
""" """
@ -69,7 +69,7 @@ def generate_sequential_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 driver events
:rtype list :rtype list
""" """
@ -106,8 +106,8 @@ def simple_instance_generators(host_num, vm_num,
test_entity_spec_list = [] test_entity_spec_list = []
if snapshot_events: if snapshot_events:
test_entity_spec_list.append( test_entity_spec_list.append(
{tg.DYNAMIC_INFO_FKEY: tg.SYNC_INST_SNAPSHOT_D, {tg.DYNAMIC_INFO_FKEY: tg.DRIVER_INST_SNAPSHOT_D,
tg.STATIC_INFO_FKEY: tg.SYNC_INST_SNAPSHOT_S, tg.STATIC_INFO_FKEY: tg.DRIVER_INST_SNAPSHOT_S,
tg.EXTERNAL_INFO_KEY: snap_vals, tg.EXTERNAL_INFO_KEY: snap_vals,
tg.MAPPING_KEY: mapping, tg.MAPPING_KEY: mapping,
tg.NAME_KEY: 'Instance (vm) snapshot generator', tg.NAME_KEY: 'Instance (vm) snapshot generator',
@ -116,7 +116,7 @@ def simple_instance_generators(host_num, vm_num,
) )
if update_events: if update_events:
test_entity_spec_list.append( test_entity_spec_list.append(
{tg.DYNAMIC_INFO_FKEY: tg.SYNC_INST_UPDATE_D, {tg.DYNAMIC_INFO_FKEY: tg.DRIVER_INST_UPDATE_D,
tg.STATIC_INFO_FKEY: None, tg.STATIC_INFO_FKEY: None,
tg.EXTERNAL_INFO_KEY: update_vals, tg.EXTERNAL_INFO_KEY: update_vals,
tg.MAPPING_KEY: mapping, tg.MAPPING_KEY: mapping,
@ -148,7 +148,7 @@ def simple_host_generators(zone_num, host_num, snapshot_events=0,
test_entity_spec_list = [] test_entity_spec_list = []
if snapshot_events: if snapshot_events:
test_entity_spec_list.append( test_entity_spec_list.append(
{tg.DYNAMIC_INFO_FKEY: tg.SYNC_HOST_SNAPSHOT_D, {tg.DYNAMIC_INFO_FKEY: tg.DRIVER_HOST_SNAPSHOT_D,
tg.STATIC_INFO_FKEY: None, tg.STATIC_INFO_FKEY: None,
tg.EXTERNAL_INFO_KEY: snap_vals, tg.EXTERNAL_INFO_KEY: snap_vals,
tg.MAPPING_KEY: mapping, tg.MAPPING_KEY: mapping,
@ -180,7 +180,7 @@ def simple_zone_generators(zone_num, host_num, snapshot_events=0,
test_entity_spec_list = [] test_entity_spec_list = []
if snapshot_events: if snapshot_events:
test_entity_spec_list.append( test_entity_spec_list.append(
{tg.DYNAMIC_INFO_FKEY: tg.SYNC_ZONE_SNAPSHOT_D, {tg.DYNAMIC_INFO_FKEY: tg.DRIVER_ZONE_SNAPSHOT_D,
tg.STATIC_INFO_FKEY: None, tg.STATIC_INFO_FKEY: None,
tg.EXTERNAL_INFO_KEY: snap_vals, tg.EXTERNAL_INFO_KEY: snap_vals,
tg.MAPPING_KEY: mapping, tg.MAPPING_KEY: mapping,
@ -214,7 +214,7 @@ def simple_volume_generators(volume_num, instance_num,
test_entity_spec_list = [] test_entity_spec_list = []
if snapshot_events: if snapshot_events:
test_entity_spec_list.append( test_entity_spec_list.append(
{tg.DYNAMIC_INFO_FKEY: tg.SYNC_VOLUME_SNAPSHOT_D, {tg.DYNAMIC_INFO_FKEY: tg.DRIVER_VOLUME_SNAPSHOT_D,
tg.STATIC_INFO_FKEY: None, tg.STATIC_INFO_FKEY: None,
tg.EXTERNAL_INFO_KEY: snap_vals, tg.EXTERNAL_INFO_KEY: snap_vals,
tg.MAPPING_KEY: mapping, tg.MAPPING_KEY: mapping,
@ -224,7 +224,7 @@ def simple_volume_generators(volume_num, instance_num,
) )
if update_events: if update_events:
test_entity_spec_list.append( test_entity_spec_list.append(
{tg.DYNAMIC_INFO_FKEY: tg.SYNC_VOLUME_UPDATE_D, {tg.DYNAMIC_INFO_FKEY: tg.DRIVER_VOLUME_UPDATE_D,
tg.STATIC_INFO_FKEY: None, tg.STATIC_INFO_FKEY: None,
tg.EXTERNAL_INFO_KEY: update_vals, tg.EXTERNAL_INFO_KEY: update_vals,
tg.MAPPING_KEY: mapping, tg.MAPPING_KEY: mapping,
@ -259,7 +259,7 @@ def simple_switch_generators(switch_num, host_num,
test_entity_spec_list = [] test_entity_spec_list = []
if snapshot_events: if snapshot_events:
test_entity_spec_list.append( test_entity_spec_list.append(
{tg.DYNAMIC_INFO_FKEY: tg.SYNC_SWITCH_SNAPSHOT_D, {tg.DYNAMIC_INFO_FKEY: tg.DRIVER_SWITCH_SNAPSHOT_D,
tg.STATIC_INFO_FKEY: None, tg.STATIC_INFO_FKEY: None,
tg.EXTERNAL_INFO_KEY: snap_vals, tg.EXTERNAL_INFO_KEY: snap_vals,
tg.MAPPING_KEY: mapping, tg.MAPPING_KEY: mapping,
@ -271,7 +271,7 @@ def simple_switch_generators(switch_num, host_num,
update_vals = {} if not update_vals else update_vals update_vals = {} if not update_vals else update_vals
update_vals['sync_mode'] = 'update' update_vals['sync_mode'] = 'update'
test_entity_spec_list.append( test_entity_spec_list.append(
{tg.DYNAMIC_INFO_FKEY: tg.SYNC_SWITCH_SNAPSHOT_D, {tg.DYNAMIC_INFO_FKEY: tg.DRIVER_SWITCH_SNAPSHOT_D,
tg.STATIC_INFO_FKEY: None, tg.STATIC_INFO_FKEY: None,
tg.EXTERNAL_INFO_KEY: update_vals, tg.EXTERNAL_INFO_KEY: update_vals,
tg.MAPPING_KEY: mapping, tg.MAPPING_KEY: mapping,
@ -300,7 +300,7 @@ def simple_nagios_alarm_generators(host_num,
test_entity_spec_list = [] test_entity_spec_list = []
if events_num: if events_num:
test_entity_spec_list.append({ test_entity_spec_list.append({
tg.DYNAMIC_INFO_FKEY: tg.SYNC_NAGIOS_SNAPSHOT_D, tg.DYNAMIC_INFO_FKEY: tg.DRIVER_NAGIOS_SNAPSHOT_D,
tg.STATIC_INFO_FKEY: None, tg.STATIC_INFO_FKEY: None,
tg.EXTERNAL_INFO_KEY: snap_vals, tg.EXTERNAL_INFO_KEY: snap_vals,
tg.MAPPING_KEY: hosts, tg.MAPPING_KEY: hosts,
@ -308,8 +308,8 @@ def simple_nagios_alarm_generators(host_num,
tg.NUM_EVENTS: max(events_num - len(hosts), 0) tg.NUM_EVENTS: max(events_num - len(hosts), 0)
}) })
test_entity_spec_list.append({ test_entity_spec_list.append({
tg.DYNAMIC_INFO_FKEY: tg.SYNC_NAGIOS_SNAPSHOT_D, tg.DYNAMIC_INFO_FKEY: tg.DRIVER_NAGIOS_SNAPSHOT_D,
tg.STATIC_INFO_FKEY: tg.SYNC_NAGIOS_SNAPSHOT_S, tg.STATIC_INFO_FKEY: tg.DRIVER_NAGIOS_SNAPSHOT_S,
tg.EXTERNAL_INFO_KEY: snap_vals, tg.EXTERNAL_INFO_KEY: snap_vals,
tg.MAPPING_KEY: hosts, tg.MAPPING_KEY: hosts,
tg.NAME_KEY: 'Nagios alarm generator (alarm off)', tg.NAME_KEY: 'Nagios alarm generator (alarm off)',

View File

@ -27,7 +27,7 @@ from random import randint
import exrex import exrex
# noinspection PyPep8Naming # noinspection PyPep8Naming
from vitrage.synchronizer.plugins.nova.host import NOVA_HOST_PLUGIN from vitrage.datasources.nova.host import NOVA_HOST_DATASOURCE
from vitrage.tests.mocks.entity_model import BasicEntityModel as Bem from vitrage.tests.mocks.entity_model import BasicEntityModel as Bem
import vitrage.tests.mocks.utils as utils import vitrage.tests.mocks.utils as utils
@ -42,17 +42,18 @@ GENERATOR = 'generator'
# specification files for input types # specification files for input types
# Mock synchronizer specs # Mock driver specs
SYNC_INST_SNAPSHOT_D = 'sync_inst_snapshot_dynamic.json' DRIVER_HOST_SNAPSHOT_D = 'driver_host_snapshot_dynamic.json'
SYNC_INST_SNAPSHOT_S = 'sync_inst_snapshot_static.json' DRIVER_INST_SNAPSHOT_D = 'driver_inst_snapshot_dynamic.json'
SYNC_INST_UPDATE_D = 'sync_inst_update_dynamic.json' DRIVER_INST_SNAPSHOT_S = 'driver_inst_snapshot_static.json'
SYNC_HOST_SNAPSHOT_D = 'sync_host_snapshot_dynamic.json' DRIVER_INST_UPDATE_D = 'driver_inst_update_dynamic.json'
SYNC_ZONE_SNAPSHOT_D = 'sync_zone_snapshot_dynamic.json' DRIVER_NAGIOS_SNAPSHOT_D = 'driver_nagios_snapshot_dynamic.json'
SYNC_VOLUME_SNAPSHOT_D = 'sync_volume_snapshot_dynamic.json' DRIVER_NAGIOS_SNAPSHOT_S = 'driver_nagios_snapshot_static.json'
SYNC_VOLUME_UPDATE_D = 'sync_volume_update_dynamic.json' DRIVER_SWITCH_SNAPSHOT_D = 'driver_switch_snapshot_dynamic.json'
SYNC_SWITCH_SNAPSHOT_D = 'sync_switch_snapshot_dynamic.json' DRIVER_VOLUME_UPDATE_D = 'driver_volume_update_dynamic.json'
SYNC_NAGIOS_SNAPSHOT_D = 'sync_nagios_snapshot_dynamic.json' DRIVER_VOLUME_SNAPSHOT_D = 'driver_volume_snapshot_dynamic.json'
SYNC_NAGIOS_SNAPSHOT_S = 'sync_nagios_snapshot_static.json' DRIVER_ZONE_SNAPSHOT_D = 'driver_zone_snapshot_dynamic.json'
# Mock transformer Specs (i.e., what the transformer outputs) # Mock transformer Specs (i.e., what the transformer outputs)
TRANS_INST_SNAPSHOT_D = 'transformer_inst_snapshot_dynamic.json' TRANS_INST_SNAPSHOT_D = 'transformer_inst_snapshot_dynamic.json'
@ -96,14 +97,14 @@ class EventTraceGenerator(object):
""" """
static_info_parsers = \ static_info_parsers = \
{SYNC_INST_SNAPSHOT_D: _get_sync_vm_snapshot_values, {DRIVER_INST_SNAPSHOT_D: _get_vm_snapshot_driver_values,
SYNC_INST_UPDATE_D: _get_sync_vm_update_values, DRIVER_INST_UPDATE_D: _get_vm_update_driver_values,
SYNC_HOST_SNAPSHOT_D: _get_sync_host_snapshot_values, DRIVER_HOST_SNAPSHOT_D: _get_host_snapshot_driver_values,
SYNC_ZONE_SNAPSHOT_D: _get_sync_zone_snapshot_values, DRIVER_ZONE_SNAPSHOT_D: _get_zone_snapshot_driver_values,
SYNC_VOLUME_SNAPSHOT_D: _get_sync_volume_snapshot_values, DRIVER_VOLUME_SNAPSHOT_D: _get_volume_snapshot_driver_values,
SYNC_VOLUME_UPDATE_D: _get_sync_volume_update_values, DRIVER_VOLUME_UPDATE_D: _get_volume_update_driver_values,
SYNC_SWITCH_SNAPSHOT_D: _get_sync_switch_snapshot_values, DRIVER_SWITCH_SNAPSHOT_D: _get_switch_snapshot_driver_values,
SYNC_NAGIOS_SNAPSHOT_D: _get_sync_nagios_alarm_values, DRIVER_NAGIOS_SNAPSHOT_D: _get_nagios_alarm_driver_values,
TRANS_INST_SNAPSHOT_D: _get_trans_vm_snapshot_values, TRANS_INST_SNAPSHOT_D: _get_trans_vm_snapshot_values,
TRANS_HOST_SNAPSHOT_D: _get_trans_host_snapshot_values, TRANS_HOST_SNAPSHOT_D: _get_trans_host_snapshot_values,
@ -163,12 +164,12 @@ def generate_round_robin_data_stream(models, event_num=100):
return data_stream return data_stream
def _get_sync_vm_snapshot_values(spec): def _get_vm_snapshot_driver_values(spec):
"""Generates the static synchronizer values for each vm. """Generates the static driver values for each vm.
:param spec: specification of event generation. :param spec: specification of event generation.
:type spec: dict :type spec: dict
:return: list of static synchronizer values for each vm. :return: list of static driver values for each vm.
:rtype: list :rtype: list
""" """
@ -193,12 +194,12 @@ def _get_sync_vm_snapshot_values(spec):
return static_values return static_values
def _get_sync_host_snapshot_values(spec): def _get_host_snapshot_driver_values(spec):
"""Generates the static synchronizer values for each host. """Generates the static driver values for each host.
:param spec: specification of event generation. :param spec: specification of event generation.
:type spec: dict :type spec: dict
:return: list of static synchronizer values for each host. :return: list of static driver values for each host.
:rtype: list :rtype: list
""" """
@ -219,12 +220,12 @@ def _get_sync_host_snapshot_values(spec):
return static_values return static_values
def _get_sync_zone_snapshot_values(spec): def _get_zone_snapshot_driver_values(spec):
"""Generates the static synchronizer values for each zone. """Generates the static driver values for each zone.
:param spec: specification of event generation. :param spec: specification of event generation.
:type spec: dict :type spec: dict
:return: list of static synchronizer values for each host. :return: list of static driver values for each host.
:rtype: list :rtype: list
""" """
@ -261,12 +262,12 @@ def _get_sync_zone_snapshot_values(spec):
return static_values return static_values
def _get_sync_volume_snapshot_values(spec): def _get_volume_snapshot_driver_values(spec):
"""Generates the static synchronizer values for each volume. """Generates the static driver values for each volume.
:param spec: specification of event generation. :param spec: specification of event generation.
:type spec: dict :type spec: dict
:return: list of static synchronizer values for each volume. :return: list of static driver values for each volume.
:rtype: list :rtype: list
""" """
@ -286,12 +287,12 @@ def _get_sync_volume_snapshot_values(spec):
return static_values return static_values
def _get_sync_volume_update_values(spec): def _get_volume_update_driver_values(spec):
"""Generates the static synchronizer values for each volume. """Generates the static driver values for each volume.
:param spec: specification of event generation. :param spec: specification of event generation.
:type spec: dict :type spec: dict
:return: list of static synchronizer values for each volume. :return: list of static driver values for each volume.
:rtype: list :rtype: list
""" """
@ -336,12 +337,12 @@ def _get_trans_vm_snapshot_values(spec):
return static_values return static_values
def _get_sync_vm_update_values(spec): def _get_vm_update_driver_values(spec):
"""Generates the static synchronizer values for each vm, for updates. """Generates the static driver values for each vm, for updates.
:param spec: specification of event generation. :param spec: specification of event generation.
:type spec: dict :type spec: dict
:return: list of static synchronizer values for each vm updates. :return: list of static driver values for each vm updates.
:rtype: list :rtype: list
""" """
@ -360,12 +361,12 @@ def _get_sync_vm_update_values(spec):
return static_values return static_values
def _get_sync_switch_snapshot_values(spec): def _get_switch_snapshot_driver_values(spec):
"""Generates the static synchronizer values for each zone. """Generates the static driver values for each zone.
:param spec: specification of event generation. :param spec: specification of event generation.
:type spec: dict :type spec: dict
:return: list of static synchronizer values for each zone. :return: list of static driver values for each zone.
:rtype: list :rtype: list
""" """
@ -380,7 +381,7 @@ def _get_sync_switch_snapshot_values(spec):
for host_name, switch_name in host_switch_mapping: for host_name, switch_name in host_switch_mapping:
switch_info = switches_info.get(switch_name, []) switch_info = switches_info.get(switch_name, [])
relationship_info = {"type": NOVA_HOST_PLUGIN, relationship_info = {"type": NOVA_HOST_DATASOURCE,
"name": host_name, "name": host_name,
"id": host_name, "id": host_name,
"relation_type": "contains" "relation_type": "contains"
@ -400,7 +401,7 @@ def _get_sync_switch_snapshot_values(spec):
return static_values return static_values
def _get_sync_nagios_alarm_values(spec): def _get_nagios_alarm_driver_values(spec):
hosts = spec[MAPPING_KEY] hosts = spec[MAPPING_KEY]
static_info_re = None static_info_re = None
if spec[STATIC_INFO_FKEY] is not None: if spec[STATIC_INFO_FKEY] is not None:
@ -416,11 +417,11 @@ def _get_sync_nagios_alarm_values(spec):
def _get_trans_host_snapshot_values(spec): def _get_trans_host_snapshot_values(spec):
"""Generates the static synchronizer values for each host. """Generates the static driver values for each host.
:param spec: specification of event generation. :param spec: specification of event generation.
:type spec: dict :type spec: dict
:return: list of static synchronizer values for each host. :return: list of static driver values for each host.
:rtype: list :rtype: list
""" """
@ -441,11 +442,11 @@ def _get_trans_host_snapshot_values(spec):
def _get_trans_zone_snapshot_values(spec): def _get_trans_zone_snapshot_values(spec):
"""Generates the static synchronizer values for each zone. """Generates the static driver values for each zone.
:param spec: specification of event generation. :param spec: specification of event generation.
:type spec: dict :type spec: dict
:return: list of static synchronizer values for each zone. :return: list of static driver values for each zone.
:rtype: list :rtype: list
""" """

Some files were not shown because too many files have changed in this diff Show More