当前位置: 首页>>代码示例>>Python>>正文


Python importutils.import_module方法代码示例

本文整理汇总了Python中oslo_utils.importutils.import_module方法的典型用法代码示例。如果您正苦于以下问题:Python importutils.import_module方法的具体用法?Python importutils.import_module怎么用?Python importutils.import_module使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oslo_utils.importutils的用法示例。


在下文中一共展示了importutils.import_module方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_conf_modules

# 需要导入模块: from oslo_utils import importutils [as 别名]
# 或者: from oslo_utils.importutils import import_module [as 别名]
def load_conf_modules():
    """Loads all modules that contain configuration.

    Method iterates over modules of :py:module:`monasca_api.conf`
    and imports only those that contain following methods:

    - list_opts (required by oslo_config.genconfig)
    - register_opts (required by :py:currentmodule:)

    """
    for modname in _list_module_names():
        mod = importutils.import_module('monasca_api.conf.' + modname)
        required_funcs = ['register_opts', 'list_opts']
        for func in required_funcs:
            if hasattr(mod, func):
                yield mod 
开发者ID:openstack,项目名称:monasca-api,代码行数:18,代码来源:__init__.py

示例2: make_plugin_base_section

# 需要导入模块: from oslo_utils import importutils [as 别名]
# 或者: from oslo_utils.importutils import import_module [as 别名]
def make_plugin_base_section(plugin_group):
    elements = []

    for item in plugin_group["items"]:
        name = item["name"].title() if "SLA" != item["name"] else item["name"]
        category_obj = category("%s %ss" % (plugin_group["group"].title(),
                                            name))
        elements.append(category_obj)

        module, cls = item["base"].split(":")
        plugin_base = getattr(importutils.import_module(module), cls)

        for p in plugin_base.get_all():
            category_obj.append(make_plugin_section(p, item["name"]))

    return elements 
开发者ID:ovn-org,项目名称:ovn-scale-test,代码行数:18,代码来源:plugin_reference.py

示例3: load_conf_modules

# 需要导入模块: from oslo_utils import importutils [as 别名]
# 或者: from oslo_utils.importutils import import_module [as 别名]
def load_conf_modules():
    """Loads all modules that contain configuration

    Method iterates over modules of :py:module:`monasca_log_api.conf`
    and imports only those that contain following methods:

    - list_opts (required by oslo_config.genconfig)
    - register_opts (required by :py:currentmodule:)

    """
    for modname in _list_module_names():
        mod = importutils.import_module('monasca_log_api.conf.' + modname)
        required_funcs = ['register_opts', 'list_opts']
        for func in required_funcs:
            if hasattr(mod, func):
                yield mod 
开发者ID:openstack,项目名称:monasca-log-api,代码行数:18,代码来源:__init__.py

示例4: port_unbind

# 需要导入模块: from oslo_utils import importutils [as 别名]
# 或者: from oslo_utils.importutils import import_module [as 别名]
def port_unbind(endpoint_id, neutron_port, driver=None, **kwargs):
    """Unbinds the Neutron port from the network interface on the host.

    :param endpoint_id: the ID of the Docker container as string
    :param neutron_port: a port dictionary returned from python-neutronclient
    :param driver:       the binding driver name
    :param kwargs:       Additional driver-specific arguments
    :returns: the tuple of stdout and stderr returned by processutils.execute
              invoked with the executable script for unbinding
    :raises: processutils.ProcessExecutionError, pyroute2.NetlinkError,
             kuryr.common.exceptions.DriverNotEnabledException,
    """
    driver = importutils.import_module(
        driver or cfg.CONF.binding.default_driver)
    _verify_driver(driver)

    return driver.port_unbind(endpoint_id, neutron_port, **kwargs) 
开发者ID:openstack,项目名称:kuryr,代码行数:19,代码来源:__init__.py

示例5: test_all_public_methods_are_traced

# 需要导入模块: from oslo_utils import importutils [as 别名]
# 或者: from oslo_utils.importutils import import_module [as 别名]
def test_all_public_methods_are_traced(self):
        profiler_opts.set_defaults(conf.CONF)
        self.config(enabled=True,
                    group='profiler')

        classes = [
            'zun.compute.api.API',
            'zun.compute.rpcapi.API',
        ]
        for clsname in classes:
            # give the metaclass and trace_cls() decorator a chance to patch
            # methods of the classes above
            imp.reload(
                importutils.import_module(clsname.rsplit('.', 1)[0]))
            cls = importutils.import_class(clsname)

            for attr, obj in cls.__dict__.items():
                # only public methods are traced
                if attr.startswith('_'):
                    continue
                # only checks callables
                if not (inspect.ismethod(obj) or inspect.isfunction(obj)):
                    continue
                # osprofiler skips static methods
                if isinstance(obj, staticmethod):
                    continue

                self.assertTrue(getattr(obj, '__traced__', False), obj) 
开发者ID:openstack,项目名称:zun,代码行数:30,代码来源:test_profiler.py

示例6: _get_classes_from_module

# 需要导入模块: from oslo_utils import importutils [as 别名]
# 或者: from oslo_utils.importutils import import_module [as 别名]
def _get_classes_from_module(self, module_name):
        """Get the classes from a module that match the type we want."""
        classes = []
        module = importutils.import_module(module_name)
        for obj_name in dir(module):
            # Skip objects that are meant to be private.
            if obj_name.startswith('_'):
                continue
            itm = getattr(module, obj_name)
            if self._is_correct_class(itm):
                classes.append(itm)
        return classes 
开发者ID:openstack,项目名称:zun,代码行数:14,代码来源:loadables.py

示例7: import_versioned_module

# 需要导入模块: from oslo_utils import importutils [as 别名]
# 或者: from oslo_utils.importutils import import_module [as 别名]
def import_versioned_module(version, submodule=None):
    module = 'monitoringclient.v%s' % version

    if submodule:
        module = '.'.join((module, submodule))
    return importutils.import_module(module) 
开发者ID:nttcom,项目名称:eclcli,代码行数:8,代码来源:utils.py

示例8: import_versioned_module

# 需要导入模块: from oslo_utils import importutils [as 别名]
# 或者: from oslo_utils.importutils import import_module [as 别名]
def import_versioned_module(version, submodule=None):
    module = 'heatclient.v%s' % version
    if submodule:
        module = '.'.join((module, submodule))
    return importutils.import_module(module) 
开发者ID:nttcom,项目名称:eclcli,代码行数:7,代码来源:utils.py

示例9: get_version_info

# 需要导入模块: from oslo_utils import importutils [as 别名]
# 或者: from oslo_utils.importutils import import_module [as 别名]
def get_version_info(self, stack):
        stack_param = self.template_def.get_heat_param(
            cluster_attr='coe_version')
        if stack_param:
            self.cluster.coe_version = stack.parameters[stack_param]

        version_module_path = self.template_def.driver_module_path+'.version'
        try:
            ver = importutils.import_module(version_module_path)
            container_version = ver.container_version
        except Exception:
            container_version = None
        self.cluster.container_version = container_version 
开发者ID:openstack,项目名称:magnum,代码行数:15,代码来源:driver.py

示例10: test_all_public_methods_are_traced

# 需要导入模块: from oslo_utils import importutils [as 别名]
# 或者: from oslo_utils.importutils import import_module [as 别名]
def test_all_public_methods_are_traced(self):
        profiler_opts.set_defaults(conf.CONF)
        self.config(enabled=True,
                    group='profiler')

        classes = [
            'magnum.conductor.api.API',
            'magnum.conductor.api.ListenerAPI',
            'magnum.conductor.handlers.ca_conductor.Handler',
            'magnum.conductor.handlers.cluster_conductor.Handler',
            'magnum.conductor.handlers.conductor_listener.Handler',
            'magnum.conductor.handlers.indirection_api.Handler',
            'magnum.service.periodic.MagnumPeriodicTasks',
        ]
        for clsname in classes:
            # give the metaclass and trace_cls() decorator a chance to patch
            # methods of the classes above
            six.reload_module(
                importutils.import_module(clsname.rsplit('.', 1)[0]))
            cls = importutils.import_class(clsname)

            for attr, obj in cls.__dict__.items():
                # only public methods are traced
                if attr.startswith('_'):
                    continue
                # only checks callables
                if not (inspect.ismethod(obj) or inspect.isfunction(obj)):
                    continue
                # osprofiler skips static methods
                if isinstance(obj, staticmethod):
                    continue

                self.assertTrue(getattr(obj, '__traced__', False), obj) 
开发者ID:openstack,项目名称:magnum,代码行数:35,代码来源:test_profiler.py

示例11: add_policy_attributes

# 需要导入模块: from oslo_utils import importutils [as 别名]
# 或者: from oslo_utils.importutils import import_module [as 别名]
def add_policy_attributes(target):
    """Adds extra information for policy enforcement to raw target object"""
    context = importutils.import_module('magnum.common.context')
    admin_context = context.make_admin_context()
    admin_osc = clients.OpenStackClients(admin_context)
    trustee_domain_id = admin_osc.keystone().trustee_domain_id
    target['trustee_domain_id'] = trustee_domain_id
    return target 
开发者ID:openstack,项目名称:magnum,代码行数:10,代码来源:policy.py

示例12: setup_rados

# 需要导入模块: from oslo_utils import importutils [as 别名]
# 或者: from oslo_utils.importutils import import_module [as 别名]
def setup_rados():
    global rados
    if not rados:
        try:
            rados = importutils.import_module('rados')
        except ImportError:
            raise exception.ShareBackendException(
                _("python-rados is not installed")) 
开发者ID:openstack,项目名称:manila,代码行数:10,代码来源:manager.py

示例13: setup_winrm

# 需要导入模块: from oslo_utils import importutils [as 别名]
# 或者: from oslo_utils.importutils import import_module [as 别名]
def setup_winrm():
    global winrm
    if not winrm:
        try:
            winrm = importutils.import_module('winrm')
        except ImportError:
            raise exception.ShareBackendException(
                _("PyWinrm is not installed")) 
开发者ID:openstack,项目名称:manila,代码行数:10,代码来源:winrm_helper.py

示例14: __init__

# 需要导入模块: from oslo_utils import importutils [as 别名]
# 或者: from oslo_utils.importutils import import_module [as 别名]
def __init__(self, db_driver=None):
        super(Base, self).__init__()
        if not db_driver:
            db_driver = CONF.db_driver
        self.db = importutils.import_module(db_driver)  # pylint: disable=C0103 
开发者ID:openstack,项目名称:manila,代码行数:7,代码来源:base.py

示例15: datasources_opts

# 需要导入模块: from oslo_utils import importutils [as 别名]
# 或者: from oslo_utils.importutils import import_module [as 别名]
def datasources_opts():

    top = os.getcwd()

    datasources = _normalize_path_to_datasource_name(
        _filter_folders_containing_transformer(_get_datasources_folders(top)),
        top)

    return [(datasource, module.OPTS) for datasource in datasources
            for module in
            [importutils.import_module(DATASOURCES_PATH + datasource)]
            if 'OPTS' in vars(module)] 
开发者ID:openstack,项目名称:vitrage,代码行数:14,代码来源:opts.py


注:本文中的oslo_utils.importutils.import_module方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。