本文整理汇总了Python中stevedore.named.NamedExtensionManager方法的典型用法代码示例。如果您正苦于以下问题:Python named.NamedExtensionManager方法的具体用法?Python named.NamedExtensionManager怎么用?Python named.NamedExtensionManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stevedore.named
的用法示例。
在下文中一共展示了named.NamedExtensionManager方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from stevedore import named [as 别名]
# 或者: from stevedore.named import NamedExtensionManager [as 别名]
def __init__(self, storage):
enabled_filters = cfg.CONF['service:central'].scheduler_filters
# Get a storage connection
self.storage = storage
if len(enabled_filters) > 0:
filters = named.NamedExtensionManager(
namespace='designate.scheduler.filters',
names=enabled_filters,
name_order=True)
self.filters = [x.plugin(storage=self.storage) for x in filters]
for filter in self.filters:
LOG.info("Loaded Scheduler Filter: %s", filter.name)
else:
raise exceptions.NoFiltersConfigured('There are no scheduling '
'filters configured')
示例2: test_enabled_before_load
# 需要导入模块: from stevedore import named [as 别名]
# 或者: from stevedore.named import NamedExtensionManager [as 别名]
def test_enabled_before_load(self):
# Set up the constructor for the FauxExtension to cause an
# AssertionError so the test fails if the class is instantiated,
# which should only happen if it is loaded before the name of the
# extension is compared against the names that should be loaded by
# the manager.
init_name = 'stevedore.tests.test_extension.FauxExtension.__init__'
with mock.patch(init_name) as m:
m.side_effect = AssertionError
em = named.NamedExtensionManager(
'stevedore.test.extension',
# Look for an extension that does not exist so the
# __init__ we mocked should never be invoked.
names=['no-such-extension'],
invoke_on_load=True,
invoke_args=('a',),
invoke_kwds={'b': 'B'},
)
actual = em.names()
self.assertEqual(actual, [])
示例3: test_extensions_listed_in_name_order
# 需要导入模块: from stevedore import named [as 别名]
# 或者: from stevedore.named import NamedExtensionManager [as 别名]
def test_extensions_listed_in_name_order(self):
# Since we don't know the "natural" order of the extensions, run
# the test both ways: if the sorting is broken, one of them will
# fail
em = named.NamedExtensionManager(
'stevedore.test.extension',
names=['t1', 't2'],
name_order=True
)
actual = em.names()
self.assertEqual(actual, ['t1', 't2'])
em = named.NamedExtensionManager(
'stevedore.test.extension',
names=['t2', 't1'],
name_order=True
)
actual = em.names()
self.assertEqual(actual, ['t2', 't1'])
示例4: test_load_fail_ignored_when_sorted
# 需要导入模块: from stevedore import named [as 别名]
# 或者: from stevedore.named import NamedExtensionManager [as 别名]
def test_load_fail_ignored_when_sorted(self):
em = named.NamedExtensionManager(
'stevedore.test.extension',
names=['e1', 't2', 'e2', 't1'],
name_order=True,
invoke_on_load=True,
invoke_args=('a',),
invoke_kwds={'b': 'B'},
)
actual = em.names()
self.assertEqual(['t2', 't1'], actual)
em = named.NamedExtensionManager(
'stevedore.test.extension',
names=['e1', 't1'],
name_order=False,
invoke_on_load=True,
invoke_args=('a',),
invoke_kwds={'b': 'B'},
)
actual = em.names()
self.assertEqual(['t1'], actual)
示例5: _load_kuryr_ctrlr_handlers
# 需要导入模块: from stevedore import named [as 别名]
# 或者: from stevedore.named import NamedExtensionManager [as 别名]
def _load_kuryr_ctrlr_handlers():
configured_handlers = CONF.kubernetes.enabled_handlers
LOG.info('Configured handlers: %s', configured_handlers)
handlers = NamedExtensionManager(
'kuryr_kubernetes.controller.handlers',
configured_handlers,
invoke_on_load=True,
on_missing_entrypoints_callback=_handler_not_found,
on_load_failure_callback=_handler_not_loaded)
LOG.info('Loaded handlers: %s', handlers.names())
ctrlr_handlers = []
for handler in handlers.extensions:
ctrlr_handlers.append(handler.obj)
return ctrlr_handlers
示例6: __init__
# 需要导入模块: from stevedore import named [as 别名]
# 或者: from stevedore.named import NamedExtensionManager [as 别名]
def __init__(self):
enabled_ext = cfg.CONF['service:api'].enabled_extensions_admin
if len(enabled_ext) > 0:
self._mgr = named.NamedExtensionManager(
namespace='designate.api.admin.extensions',
names=enabled_ext,
invoke_on_load=True)
for ext in self._mgr:
controller = self
path = ext.obj.get_path()
LOG.info("Registering an API extension at path %s", path)
for p in path.split('.')[:-1]:
if p != '':
controller = getattr(controller, p)
setattr(controller, path.split('.')[-1], ext.obj)
示例7: __init__
# 需要导入模块: from stevedore import named [as 别名]
# 或者: from stevedore.named import NamedExtensionManager [as 别名]
def __init__(self):
enabled_ext = cfg.CONF['service:api'].enabled_extensions_v2
if len(enabled_ext) > 0:
self._mgr = named.NamedExtensionManager(
namespace='designate.api.v2.extensions',
names=enabled_ext,
invoke_on_load=True)
for ext in self._mgr:
controller = self
path = ext.obj.get_path()
for p in path.split('.')[:-1]:
if p != '':
controller = getattr(controller, p)
setattr(controller, path.split('.')[-1], ext.obj)
示例8: get_recovery_flow
# 需要导入模块: from stevedore import named [as 别名]
# 或者: from stevedore.named import NamedExtensionManager [as 别名]
def get_recovery_flow(task_list, **kwargs):
"""This is used create extension object from provided task_list.
This method returns the extension object of the each task provided
in a list using stevedore extension manager.
"""
extensions = named.NamedExtensionManager(
'masakari.task_flow.tasks', names=task_list,
name_order=True, invoke_on_load=True, invoke_kwds=kwargs)
for extension in extensions.extensions:
yield extension.obj
示例9: test_named
# 需要导入模块: from stevedore import named [as 别名]
# 或者: from stevedore.named import NamedExtensionManager [as 别名]
def test_named(self):
em = named.NamedExtensionManager(
'stevedore.test.extension',
names=['t1'],
invoke_on_load=True,
invoke_args=('a',),
invoke_kwds={'b': 'B'},
)
actual = em.names()
self.assertEqual(actual, ['t1'])
示例10: test_missing_entrypoints_callback
# 需要导入模块: from stevedore import named [as 别名]
# 或者: from stevedore.named import NamedExtensionManager [as 别名]
def test_missing_entrypoints_callback(self, load_fn):
errors = set()
def callback(names):
errors.update(names)
load_fn.return_value = [
extension.Extension('foo', None, None, None)
]
named.NamedExtensionManager('stevedore.test.extension',
names=['foo', 'bar'],
invoke_on_load=True,
on_missing_entrypoints_callback=callback)
self.assertEqual(errors, {'bar'})
示例11: init_writing_pipeline
# 需要导入模块: from stevedore import named [as 别名]
# 或者: from stevedore.named import NamedExtensionManager [as 别名]
def init_writing_pipeline(self):
CONF.import_opt('pipeline', 'cloudkitty.config', 'output')
output_pipeline = named.NamedExtensionManager(
WRITERS_NAMESPACE,
CONF.output.pipeline)
for writer in output_pipeline:
self.add_writer(writer.plugin)
示例12: load_dispatcher
# 需要导入模块: from stevedore import named [as 别名]
# 或者: from stevedore.named import NamedExtensionManager [as 别名]
def load_dispatcher():
"""Load dispatchers."""
global dispatchers
LOG.debug("Loading dispatchers")
dispatchers = named.NamedExtensionManager(
namespace="senlin.dispatchers",
names=cfg.CONF.event_dispatchers,
invoke_on_load=True,
propagate_map_exceptions=True)
if not list(dispatchers):
LOG.warning("No dispatchers configured for 'senlin.dispatchers'")
else:
LOG.info("Loaded dispatchers: %s", dispatchers.names())
示例13: __init__
# 需要导入模块: from stevedore import named [as 别名]
# 或者: from stevedore.named import NamedExtensionManager [as 别名]
def __init__(self):
threshold_rules = ('threshold',
'gnocchi_resources_threshold',
'gnocchi_aggregation_by_metrics_threshold',
'gnocchi_aggregation_by_resources_threshold')
CompositeRule.threshold_plugins = named.NamedExtensionManager(
"aodh.alarm.rule", threshold_rules)
super(CompositeRule, self).__init__()