本文整理汇总了Python中stevedore.driver.DriverManager方法的典型用法代码示例。如果您正苦于以下问题:Python driver.DriverManager方法的具体用法?Python driver.DriverManager怎么用?Python driver.DriverManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stevedore.driver
的用法示例。
在下文中一共展示了driver.DriverManager方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: neutron_to_osvif_vif
# 需要导入模块: from stevedore import driver [as 别名]
# 或者: from stevedore.driver import DriverManager [as 别名]
def neutron_to_osvif_vif(vif_translator, neutron_port, network, subnets):
"""Converts Neutron port to os-vif VIF object.
:param vif_translator: name of the traslator for the os-vif plugin to use
:param neutron_port: dict containing port information as returned by
neutron client
:param subnets: subnet mapping
:return: os-vif VIF object
"""
try:
mgr = _VIF_MANAGERS[vif_translator]
except KeyError:
mgr = stv_driver.DriverManager(
namespace=_VIF_TRANSLATOR_NAMESPACE,
name=vif_translator, invoke_on_load=False)
_VIF_MANAGERS[vif_translator] = mgr
return mgr.driver(vif_translator, neutron_port, network, subnets)
示例2: neutron_to_osvif_vif
# 需要导入模块: from stevedore import driver [as 别名]
# 或者: from stevedore.driver import DriverManager [as 别名]
def neutron_to_osvif_vif(vif_translator, os_port, subnets):
"""Converts Neutron port to os-vif VIF object.
:param vif_translator: name of the traslator for the os-vif plugin to use
:param os_port: openstack.network.v2.port.Port object
:param subnets: subnet mapping as returned by PodSubnetsDriver.get_subnets
:return: os-vif VIF object
"""
try:
mgr = _VIF_MANAGERS[vif_translator]
except KeyError:
mgr = stv_driver.DriverManager(
namespace=_VIF_TRANSLATOR_NAMESPACE,
name=vif_translator, invoke_on_load=False)
_VIF_MANAGERS[vif_translator] = mgr
return mgr.driver(vif_translator, os_port, subnets)
示例3: API
# 需要导入模块: from stevedore import driver [as 别名]
# 或者: from stevedore.driver import DriverManager [as 别名]
def API(configuration=None):
conf = configuration or cfg.CONF
conf.register_opts(key_manager_opts, group='key_manager')
try:
mgr = driver.DriverManager("castellan.drivers",
conf.key_manager.backend,
invoke_on_load=True,
invoke_args=[conf])
key_mgr = mgr.driver
except exception.NoMatches:
LOG.warning("Deprecation Warning : %s is not a stevedore based driver,"
" trying to load it as a class", conf.key_manager.backend)
cls = importutils.import_class(conf.key_manager.backend)
key_mgr = cls(configuration=conf)
return migration.handle_migration(conf, key_mgr)
示例4: __init__
# 需要导入模块: from stevedore import driver [as 别名]
# 或者: from stevedore.driver import DriverManager [as 别名]
def __init__(self):
super(VirtualMachineManager, self).__init__()
# Must initialize nova api
self._nova_client = clients.NovaAuth.get_nova_client(
endpoint=CONF.nova.endpoint,
region=CONF.nova.region_name,
endpoint_type=CONF.nova.endpoint_type,
insecure=CONF.nova.insecure,
cacert=CONF.nova.ca_certificates_file)
self._glance_client = clients.GlanceAuth.get_glance_client(
service_name=CONF.glance.service_name,
endpoint=CONF.glance.endpoint,
region=CONF.glance.region_name,
endpoint_type=CONF.glance.endpoint_type,
insecure=CONF.glance.insecure,
cacert=CONF.glance.ca_certificates_file)
self.manager = self._nova_client.servers
self.server_groups = self._nova_client.server_groups
self.flavor_manager = self._nova_client.flavors
self.availability_zone_manager = self._nova_client.availability_zones
self.volume_driver = stevedore_driver.DriverManager(
namespace='octavia.volume.drivers',
name=CONF.controller_worker.volume_driver,
invoke_on_load=True
).driver
示例5: get_driver
# 需要导入模块: from stevedore import driver [as 别名]
# 或者: from stevedore.driver import DriverManager [as 别名]
def get_driver(provider):
# If this came in None it must be a load balancer that existed before
# provider support was added. These must be of type 'amphora' and not
# whatever the current "default" is set to.
if isinstance(provider, wtypes.UnsetType):
provider = CONF.api_settings.default_provider_driver
elif not provider:
provider = 'amphora'
if provider not in CONF.api_settings.enabled_provider_drivers:
LOG.warning("Requested provider driver '%s' was not enabled in the "
"configuration file.", provider)
raise exceptions.ProviderNotEnabled(prov=provider)
try:
driver = stevedore_driver.DriverManager(
namespace='octavia.api.drivers',
name=provider,
invoke_on_load=True).driver
driver.name = provider
except Exception as e:
LOG.error('Unable to load provider driver %s due to: %s',
provider, e)
raise exceptions.ProviderNotFound(prov=provider)
return driver
示例6: __init__
# 需要导入模块: from stevedore import driver [as 别名]
# 或者: from stevedore.driver import DriverManager [as 别名]
def __init__(self):
super(HaproxyAmphoraLoadBalancerDriver, self).__init__()
self.clients = {
'base': AmphoraAPIClientBase(),
'0.5': AmphoraAPIClient0_5(),
'1.0': AmphoraAPIClient1_0(),
}
self.cert_manager = stevedore_driver.DriverManager(
namespace='octavia.cert_manager',
name=CONF.certificates.cert_manager,
invoke_on_load=True,
).driver
self.jinja_combo = jinja_combo.JinjaTemplater(
base_amp_path=CONF.haproxy_amphora.base_path,
base_crt_dir=CONF.haproxy_amphora.base_cert_dir,
haproxy_template=CONF.haproxy_amphora.haproxy_template,
connection_logging=CONF.haproxy_amphora.connection_logging)
self.jinja_split = jinja_split.JinjaTemplater(
base_amp_path=CONF.haproxy_amphora.base_path,
base_crt_dir=CONF.haproxy_amphora.base_cert_dir,
haproxy_template=CONF.haproxy_amphora.haproxy_template,
connection_logging=CONF.haproxy_amphora.connection_logging)
self.udp_jinja = jinja_udp_cfg.LvsJinjaTemplater()
示例7: __init__
# 需要导入模块: from stevedore import driver [as 别名]
# 或者: from stevedore.driver import DriverManager [as 别名]
def __init__(self):
self._amphora_repo = repo.AmphoraRepository()
self._amphora_health_repo = repo.AmphoraHealthRepository()
self._health_mon_repo = repo.HealthMonitorRepository()
self._lb_repo = repo.LoadBalancerRepository()
self._listener_repo = repo.ListenerRepository()
self._member_repo = repo.MemberRepository()
self._pool_repo = repo.PoolRepository()
self._l7policy_repo = repo.L7PolicyRepository()
self._l7rule_repo = repo.L7RuleRepository()
self._flavor_repo = repo.FlavorRepository()
self._az_repo = repo.AvailabilityZoneRepository()
persistence = tsk_driver.MysqlPersistenceDriver()
self.jobboard_driver = stevedore_driver.DriverManager(
namespace='octavia.worker.jobboard_driver',
name=CONF.task_flow.jobboard_backend_driver,
invoke_args=(persistence,),
invoke_on_load=True).driver
示例8: _load_multi_store
# 需要导入模块: from stevedore import driver [as 别名]
# 或者: from stevedore.driver import DriverManager [as 别名]
def _load_multi_store(conf, store_entry,
invoke_load=True,
backend=None):
if backend:
invoke_args = [conf, backend]
else:
invoke_args = [conf]
try:
LOG.debug("Attempting to import store %s", store_entry)
mgr = driver.DriverManager('glance_store.drivers',
store_entry,
invoke_args=invoke_args,
invoke_on_load=invoke_load)
return mgr.driver
except RuntimeError as e:
LOG.warning("Failed to load driver %(driver)s. The "
"driver will be disabled", dict(driver=str([driver, e])))
示例9: format
# 需要导入模块: from stevedore import driver [as 别名]
# 或者: from stevedore.driver import DriverManager [as 别名]
def format(filename, env=None):
"""
Format a file
:param filename: Path to file
:type filename: str or :py:class:`pathlib.Path`
:param dict[str,str] env: List of variables
"""
ext = str(filename).split(".")[-1]
driver = DriverManager("eastern.formatter", ext)
driver.propagate_map_exceptions = True
env = env or {}
if isinstance(filename, Path):
file_obj = filename
else:
file_obj = Path(filename)
body = file_obj.read_text()
return driver(lambda ext: ext.plugin(body, file_obj.parent, env).format())
示例10: load_driver
# 需要导入模块: from stevedore import driver [as 别名]
# 或者: from stevedore.driver import DriverManager [as 别名]
def load_driver(driver_cfg, namespace, *args, **kwargs):
try:
# Try to resolve by alias
mgr = driver.DriverManager(namespace, driver_cfg)
class_to_load = mgr.driver
except RuntimeError:
e1_info = sys.exc_info()
# try with name
try:
class_to_load = importutils.import_class(driver_cfg)
except (ImportError, ValueError):
LOG.error("Error loading class %(class)s by alias e: %(e)s",
{'class': driver_cfg, 'e': e1_info},
exc_info=e1_info)
LOG.error("Error loading class by class name",
exc_info=True)
raise ImportError(_("Class not found."))
return class_to_load(*args, **kwargs)
示例11: test_multiple_drivers
# 需要导入模块: from stevedore import driver [as 别名]
# 或者: from stevedore.driver import DriverManager [as 别名]
def test_multiple_drivers(self):
# The idea for this test was contributed by clayg:
# https://gist.github.com/clayg/6311348
extensions = [
extension.Extension(
'backend',
pkg_resources.EntryPoint.parse('backend = pkg1:driver'),
'pkg backend',
None,
),
extension.Extension(
'backend',
pkg_resources.EntryPoint.parse('backend = pkg2:driver'),
'pkg backend',
None,
),
]
try:
dm = driver.DriverManager.make_test_instance(extensions[0])
# Call the initialization code that verifies the extension
dm._init_plugins(extensions)
except exception.MultipleMatches as err:
self.assertIn("Multiple", str(err))
else:
self.fail('Should have had an error')
示例12: load
# 需要导入模块: from stevedore import driver [as 别名]
# 或者: from stevedore.driver import DriverManager [as 别名]
def load(self, name, **kwargs):
try:
LOG.debug("Loading in namespace %s => %s ", self.namespace, name)
driver_manager = drivermanager.DriverManager(
namespace=self.namespace,
name=name,
invoke_on_load=False,
)
driver_cls = driver_manager.driver
config = self._load_plugin_config(name, driver_cls)
driver = driver_cls(config, **kwargs)
except Exception as exc:
LOG.exception(exc)
raise exception.LoadingError(name=name)
return driver
示例13: get_backend_driver
# 需要导入模块: from stevedore import driver [as 别名]
# 或者: from stevedore.driver import DriverManager [as 别名]
def get_backend_driver(namespace, name, invoke_on_load=False):
"""
Retrieve a driver (module / class / function) the provided backend.
:param name: Backend name.
:type name: ``str``
"""
# NOTE: We use lazy import because importing from stevedore adds significat import time
# overhead to other modules which don't need this package (stevedore needs to inspect various
# entrypoint files on disk for all the installed Python packages which is slow)
from stevedore.driver import DriverManager
LOG.debug('Retrieving driver for backend "%s"' % (name))
try:
manager = DriverManager(namespace=namespace, name=name,
invoke_on_load=invoke_on_load)
except RuntimeError:
message = 'Invalid "%s" backend specified: %s' % (namespace, name)
LOG.exception(message)
raise ValueError(message)
return manager.driver
示例14: register_runners
# 需要导入模块: from stevedore import driver [as 别名]
# 或者: from stevedore.driver import DriverManager [as 别名]
def register_runners(experimental=False, fail_on_failure=True):
"""
Register runners
"""
LOG.debug('Start : register runners')
runner_count = 0
manager = ExtensionManager(namespace=RUNNERS_NAMESPACE, invoke_on_load=False)
extension_names = manager.names()
for name in extension_names:
LOG.debug('Found runner "%s"' % (name))
manager = DriverManager(namespace=RUNNERS_NAMESPACE, invoke_on_load=False, name=name)
runner_metadata = manager.driver.get_metadata()
runner_count += register_runner(runner_metadata, experimental)
LOG.debug('End : register runners')
return runner_count
示例15: _initialize_drivers
# 需要导入模块: from stevedore import driver [as 别名]
# 或者: from stevedore.driver import DriverManager [as 别名]
def _initialize_drivers(self, enabled_drivers=None):
"""Load accelerator drivers.
:return: [nvidia_gpu_driver_obj, intel_fpga_driver_obj]
"""
acc_drivers = []
if not enabled_drivers:
enabled_drivers = CONF.agent.enabled_drivers
valid_drivers = ExtensionManager(
namespace='cyborg.accelerator.driver').names()
for d in enabled_drivers:
if d not in valid_drivers:
raise exception.InvalidDriver(name=d)
acc_driver = driver.DriverManager(
namespace='cyborg.accelerator.driver', name=d,
invoke_on_load=True).driver
acc_drivers.append(acc_driver)
self.acc_drivers = acc_drivers