Merge "enable external notifiers"
This commit is contained in:
commit
823cc9b0f3
@ -17,4 +17,7 @@ from oslo_config import cfg
|
|||||||
OPTS = [
|
OPTS = [
|
||||||
cfg.ListOpt('notifiers',
|
cfg.ListOpt('notifiers',
|
||||||
help='Names of enabled notifiers (example aodh, nova)'),
|
help='Names of enabled notifiers (example aodh, nova)'),
|
||||||
|
cfg.ListOpt('notifiers_path',
|
||||||
|
default=['vitrage.notifier.plugins'],
|
||||||
|
help='list of base path for notifiers'),
|
||||||
]
|
]
|
||||||
|
@ -12,4 +12,12 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
pass
|
from oslo_config import cfg
|
||||||
|
|
||||||
|
OPTS = [
|
||||||
|
cfg.StrOpt('notifier',
|
||||||
|
default='vitrage.notifier.plugins.aodh.'
|
||||||
|
'aodh_notifier.AodhNotifier',
|
||||||
|
help='aodh notifier class path',
|
||||||
|
required=True),
|
||||||
|
]
|
||||||
|
@ -12,4 +12,12 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
pass
|
from oslo_config import cfg
|
||||||
|
|
||||||
|
OPTS = [
|
||||||
|
cfg.StrOpt('notifier',
|
||||||
|
default='vitrage.notifier.plugins.nova.'
|
||||||
|
'nova_notifier.NovaNotifier',
|
||||||
|
help='nova notifier class path',
|
||||||
|
required=True),
|
||||||
|
]
|
||||||
|
@ -15,11 +15,10 @@
|
|||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
import oslo_messaging
|
import oslo_messaging
|
||||||
from oslo_service import service as os_service
|
from oslo_service import service as os_service
|
||||||
|
from oslo_utils import importutils
|
||||||
|
|
||||||
from vitrage import messaging
|
from vitrage import messaging
|
||||||
from vitrage.notifier.plugins.aodh.aodh_notifier import AodhNotifier
|
from vitrage.opts import register_opts
|
||||||
from vitrage.notifier.plugins.nova.nova_notifier import NovaNotifier
|
|
||||||
|
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
@ -60,11 +59,12 @@ class VitrageNotifierService(os_service.Service):
|
|||||||
if not conf_notifier_names:
|
if not conf_notifier_names:
|
||||||
LOG.info('There are no notifier plugins in configuration')
|
LOG.info('There are no notifier plugins in configuration')
|
||||||
return []
|
return []
|
||||||
for plugin in [AodhNotifier, NovaNotifier]:
|
for notifier_name in conf_notifier_names:
|
||||||
plugin_name = plugin.get_notifier_name()
|
register_opts(conf, notifier_name, conf.notifiers_path)
|
||||||
if plugin_name in conf_notifier_names:
|
LOG.info('Notifier plugin %s started', notifier_name)
|
||||||
LOG.info('Notifier plugin %s started', plugin_name)
|
notifiers.append(importutils.import_object(
|
||||||
notifiers.append(plugin(conf))
|
conf[notifier_name].notifier,
|
||||||
|
conf))
|
||||||
return notifiers
|
return notifiers
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
import os
|
import os
|
||||||
|
from oslo_log import log
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
|
|
||||||
import vitrage.api
|
import vitrage.api
|
||||||
@ -26,6 +27,8 @@ import vitrage.keystone_client
|
|||||||
import vitrage.notifier
|
import vitrage.notifier
|
||||||
import vitrage.rpc
|
import vitrage.rpc
|
||||||
|
|
||||||
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
DATASOURCES_PATH = 'vitrage.datasources.'
|
DATASOURCES_PATH = 'vitrage.datasources.'
|
||||||
DATASOURCE_FS_PATH = os.path.join('vitrage', 'datasources')
|
DATASOURCE_FS_PATH = os.path.join('vitrage', 'datasources')
|
||||||
DRIVER_FILE = 'driver.py'
|
DRIVER_FILE = 'driver.py'
|
||||||
@ -76,3 +79,20 @@ def _filter_folders_containing_transformer(folders):
|
|||||||
def _normalize_path_to_datasource_name(path_list, top=os.getcwd()):
|
def _normalize_path_to_datasource_name(path_list, top=os.getcwd()):
|
||||||
return [os.path.relpath(path, os.path.join(top, DATASOURCE_FS_PATH))
|
return [os.path.relpath(path, os.path.join(top, DATASOURCE_FS_PATH))
|
||||||
.replace(os.sep, '.') for path in path_list]
|
.replace(os.sep, '.') for path in path_list]
|
||||||
|
|
||||||
|
|
||||||
|
def register_opts(conf, package_name, paths):
|
||||||
|
"""register opts of package package_name, with base path in paths"""
|
||||||
|
for path in paths:
|
||||||
|
try:
|
||||||
|
opt = importutils.import_module(
|
||||||
|
"%s.%s" % (path, package_name)).OPTS
|
||||||
|
conf.register_opts(
|
||||||
|
list(opt),
|
||||||
|
group=None if package_name == 'DEFAULT' else package_name
|
||||||
|
)
|
||||||
|
return
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
LOG.error("Failed to register config options for %s" % package_name)
|
||||||
|
@ -16,11 +16,10 @@ import logging
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from oslo_policy import opts as policy_opts
|
from oslo_policy import opts as policy_opts
|
||||||
from oslo_utils import importutils
|
|
||||||
|
|
||||||
from vitrage import keystone_client
|
from vitrage import keystone_client
|
||||||
from vitrage import messaging
|
from vitrage import messaging
|
||||||
from vitrage import opts
|
from vitrage import opts
|
||||||
|
from vitrage.opts import register_opts
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
@ -39,7 +38,7 @@ def prepare_service(args=None, conf=None, config_files=None):
|
|||||||
default_config_files=config_files)
|
default_config_files=config_files)
|
||||||
|
|
||||||
for datasource in conf.datasources.types:
|
for datasource in conf.datasources.types:
|
||||||
load_datasource(conf, datasource, conf.datasources.path)
|
register_opts(conf, datasource, conf.datasources.path)
|
||||||
|
|
||||||
keystone_client.register_keystoneauth_opts(conf)
|
keystone_client.register_keystoneauth_opts(conf)
|
||||||
|
|
||||||
@ -49,16 +48,3 @@ def prepare_service(args=None, conf=None, config_files=None):
|
|||||||
messaging.setup()
|
messaging.setup()
|
||||||
|
|
||||||
return conf
|
return conf
|
||||||
|
|
||||||
|
|
||||||
def load_datasource(conf, name, paths):
|
|
||||||
for path in paths:
|
|
||||||
try:
|
|
||||||
opt = importutils.import_module("%s.%s" % (path, name)).OPTS
|
|
||||||
conf.register_opts(list(opt),
|
|
||||||
group=None if name == 'DEFAULT' else name)
|
|
||||||
return
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
LOG.error("Failed to register config options for plugin %s" % name)
|
|
||||||
|
@ -31,7 +31,7 @@ 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_data import ActionSpecs
|
from vitrage.evaluator.template_data 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_datasource
|
from vitrage.opts import register_opts
|
||||||
from vitrage.tests.functional.base import TestFunctionalBase
|
from vitrage.tests.functional.base import TestFunctionalBase
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@ -47,9 +47,7 @@ class TestActionExecutor(TestFunctionalBase):
|
|||||||
cls.conf.register_opts(cls.DATASOURCES_OPTS, group='datasources')
|
cls.conf.register_opts(cls.DATASOURCES_OPTS, group='datasources')
|
||||||
|
|
||||||
for datasource_name in cls.conf.datasources.types:
|
for datasource_name in cls.conf.datasources.types:
|
||||||
load_datasource(cls.conf,
|
register_opts(cls.conf, datasource_name, cls.conf.datasources.path)
|
||||||
datasource_name,
|
|
||||||
cls.conf.datasources.path)
|
|
||||||
|
|
||||||
def test_execute_update_vertex(self):
|
def test_execute_update_vertex(self):
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ from vitrage.datasources.nova.zone import NOVA_ZONE_DATASOURCE
|
|||||||
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
|
||||||
import vitrage.graph.utils as graph_utils
|
import vitrage.graph.utils as graph_utils
|
||||||
from vitrage.service import load_datasource
|
from vitrage.opts import register_opts
|
||||||
from vitrage.tests import base
|
from vitrage.tests import base
|
||||||
from vitrage.tests.mocks import mock_driver as mock_sync
|
from vitrage.tests.mocks import mock_driver as mock_sync
|
||||||
from vitrage.tests.mocks import utils
|
from vitrage.tests.mocks import utils
|
||||||
@ -63,7 +63,7 @@ class TestEntityGraphUnitBase(base.BaseTest):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def load_datasources(conf):
|
def load_datasources(conf):
|
||||||
for datasource in conf.datasources.types:
|
for datasource in conf.datasources.types:
|
||||||
load_datasource(conf, datasource, conf.datasources.path)
|
register_opts(conf, datasource, conf.datasources.path)
|
||||||
|
|
||||||
def _create_processor_with_graph(self, conf, processor=None):
|
def _create_processor_with_graph(self, conf, processor=None):
|
||||||
events = self._create_mock_events()
|
events = self._create_mock_events()
|
||||||
|
@ -25,7 +25,7 @@ from vitrage.entity_graph.mappings.datasource_info_mapper import \
|
|||||||
from vitrage.entity_graph.mappings.operational_resource_state import \
|
from vitrage.entity_graph.mappings.operational_resource_state import \
|
||||||
OperationalResourceState
|
OperationalResourceState
|
||||||
from vitrage.graph.utils import create_vertex
|
from vitrage.graph.utils import create_vertex
|
||||||
from vitrage.service import load_datasource
|
from vitrage.opts import register_opts
|
||||||
from vitrage.tests import base
|
from vitrage.tests import base
|
||||||
from vitrage.tests.mocks import utils
|
from vitrage.tests.mocks import utils
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ class TestDatasourceInfoMapper(base.BaseTest):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def _load_datasources(conf):
|
def _load_datasources(conf):
|
||||||
for datasource_name in conf.datasources.types:
|
for datasource_name in conf.datasources.types:
|
||||||
load_datasource(conf, datasource_name, conf.datasources.path)
|
register_opts(conf, datasource_name, conf.datasources.path)
|
||||||
|
|
||||||
# noinspection PyAttributeOutsideInit,PyPep8Naming
|
# noinspection PyAttributeOutsideInit,PyPep8Naming
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -24,7 +24,7 @@ from vitrage.datasources.nova.instance.transformer import InstanceTransformer
|
|||||||
from vitrage.datasources.nova.zone import NOVA_ZONE_DATASOURCE
|
from vitrage.datasources.nova.zone import NOVA_ZONE_DATASOURCE
|
||||||
from vitrage.datasources.nova.zone.transformer import ZoneTransformer
|
from vitrage.datasources.nova.zone.transformer import ZoneTransformer
|
||||||
from vitrage.entity_graph.transformer_manager import TransformerManager
|
from vitrage.entity_graph.transformer_manager import TransformerManager
|
||||||
from vitrage.service import load_datasource
|
from vitrage.opts import register_opts
|
||||||
from vitrage.tests import base
|
from vitrage.tests import base
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@ -52,7 +52,7 @@ class TransformerManagerTest(base.BaseTest):
|
|||||||
cls.conf.register_opts(cls.OPTS, group='datasources')
|
cls.conf.register_opts(cls.OPTS, group='datasources')
|
||||||
|
|
||||||
for datasource in cls.conf.datasources.types:
|
for datasource in cls.conf.datasources.types:
|
||||||
load_datasource(cls.conf, datasource, cls.conf.datasources.path)
|
register_opts(cls.conf, datasource, cls.conf.datasources.path)
|
||||||
|
|
||||||
cls.manager = TransformerManager(cls.conf)
|
cls.manager = TransformerManager(cls.conf)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user