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


Python importutils.import_object方法代码示例

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


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

示例1: __init__

# 需要导入模块: from oslo_utils import importutils [as 别名]
# 或者: from oslo_utils.importutils import import_object [as 别名]
def __init__(self, service_plugin, validator=None):
        super(L2gwRpcDriver, self).__init__(service_plugin, validator)
        self.ovsdb_callback = importutils.import_object(
            L2GW_CALLBACK, self)
        self.endpoints = (
            [self.ovsdb_callback, agents_db.AgentExtRpcCallback()])
        self.conn = n_rpc.Connection()
        self.conn.create_consumer(topics.L2GATEWAY_PLUGIN,
                                  self.endpoints,
                                  fanout=False)
        self.conn.consume_in_threads()
        self.create_rpc_conn()
        LOG.debug("starting l2gateway agent scheduler")
        self.start_l2gateway_agent_scheduler()
        self.gateway_resource = constants.GATEWAY_RESOURCE_NAME
        self.l2gateway_db = l2_gw_db.L2GatewayMixin()
        self.type_manager = managers.TypeManager()
        self.port_dict_before_update = [] 
开发者ID:openstack,项目名称:networking-l2gw,代码行数:20,代码来源:rpc_l2gw.py

示例2: __init__

# 需要导入模块: from oslo_utils import importutils [as 别名]
# 或者: from oslo_utils.importutils import import_object [as 别名]
def __init__(self, scheduler_driver=None, service_name=None,
                 *args, **kwargs):

        if not scheduler_driver:
            scheduler_driver = CONF.scheduler_driver
        if scheduler_driver in MAPPING:
            msg_args = {
                'old': scheduler_driver,
                'new': MAPPING[scheduler_driver],
            }
            LOG.warning("Scheduler driver path %(old)s is deprecated, "
                        "update your configuration to the new path "
                        "%(new)s", msg_args)
            scheduler_driver = MAPPING[scheduler_driver]

        self.driver = importutils.import_object(scheduler_driver)
        self.message_api = message_api.API()
        super(SchedulerManager, self).__init__(*args, **kwargs) 
开发者ID:openstack,项目名称:manila,代码行数:20,代码来源:manager.py

示例3: _register_action_recipes

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

        # noinspection PyDictCreation
        recipes = {}

        recipes[ActionType.SET_STATE] = importutils.import_object(
            "%s.%s" % (SetState.__module__, SetState.__name__))

        recipes[ActionType.RAISE_ALARM] = importutils.import_object(
            "%s.%s" % (RaiseAlarm.__module__, RaiseAlarm.__name__))

        recipes[ActionType.ADD_CAUSAL_RELATIONSHIP] = \
            importutils.import_object(
            "%s.%s" % (AddCausalRelationship.__module__,
                       AddCausalRelationship.__name__))

        recipes[ActionType.MARK_DOWN] = importutils.import_object(
            "%s.%s" % (MarkDown.__module__, MarkDown.__name__))

        recipes[ActionType.EXECUTE_MISTRAL] = importutils.import_object(
            "%s.%s" % (ExecuteMistral.__module__, ExecuteMistral.__name__))

        return recipes 
开发者ID:openstack,项目名称:vitrage,代码行数:25,代码来源:action_executor.py

示例4: zabbix_client_login

# 需要导入模块: from oslo_utils import importutils [as 别名]
# 或者: from oslo_utils.importutils import import_object [as 别名]
def zabbix_client_login(self):
        if not CONF.zabbix.user:
            LOG.warning('Zabbix user is not defined')
        if not CONF.zabbix.password:
            LOG.warning('Zabbix password is not defined')
        if not CONF.zabbix.url:
            LOG.warning('Zabbix url is not defined')

        try:
            if not self._client:
                self._client = utils.import_object(
                    'pyzabbix.ZabbixAPI',
                    CONF.zabbix.url)
            self._client.login(
                CONF.zabbix.user,
                CONF.zabbix.password)
        except Exception:
            LOG.exception('pyzabbix.ZabbixAPI error occurred.')
            self._client = None 
开发者ID:openstack,项目名称:vitrage,代码行数:21,代码来源:driver.py

示例5: _build_vif_driver

# 需要导入模块: from oslo_utils import importutils [as 别名]
# 或者: from oslo_utils.importutils import import_object [as 别名]
def _build_vif_driver(adapter, host_uuid, instance, vif):
    """Returns the appropriate VIF Driver for the given VIF.

    :param adapter: The pypowervm adapter API interface.
    :param host_uuid: The host system UUID.
    :param instance: The nova instance.
    :param vif: The virtual interface to from Nova.
    :return: The appropriate PvmVifDriver for the VIF.
    """
    if vif.get('type') is None:
        raise exception.VirtualInterfacePlugException(
            _("vif_type parameter must be present for this vif_driver "
              "implementation"))

    # Check the type to the implementations
    if VIF_MAPPING.get(vif['type']):
        return importutils.import_object(
            VIF_MAPPING.get(vif['type']), adapter, host_uuid, instance)

    # No matching implementation, raise error.
    raise exception.VirtualInterfacePlugException(
        _("Unable to find appropriate PowerVM VIF Driver for VIF type "
          "%(vif_type)s on instance %(instance)s") %
        {'vif_type': vif['type'], 'instance': instance.name}) 
开发者ID:openstack,项目名称:nova-powervm,代码行数:26,代码来源:vif.py

示例6: _get_class

# 需要导入模块: from oslo_utils import importutils [as 别名]
# 或者: from oslo_utils.importutils import import_object [as 别名]
def _get_class(class_type, *args, **kwargs):
    if class_type not in utils_map:
        raise exceptions.HyperVException(_('Class type %s does '
                                           'not exist') % class_type)

    windows_version = utils.get_windows_version()
    build = list(map(int, windows_version.split('.')))
    windows_version = float("%i.%i" % (build[0], build[1]))

    existing_classes = utils_map.get(class_type, [])
    for class_variant in existing_classes:
        min_version = class_variant.get('min_version', DEFAULT_MIN_VERSION)
        max_version = class_variant.get('max_version', DEFAULT_MAX_VERSION)
        class_path = class_variant['path']
        if (min_version <= windows_version and
                (max_version is None or windows_version < max_version)):
            return importutils.import_object(class_path, *args, **kwargs)

    raise exceptions.HyperVException(_('Could not find any %(class)s class for'
                                       'this Windows version: %(win_version)s')
                                     % {'class': class_type,
                                        'win_version': windows_version}) 
开发者ID:openstack,项目名称:os-win,代码行数:24,代码来源:utilsfactory.py

示例7: _driver

# 需要导入模块: from oslo_utils import importutils [as 别名]
# 或者: from oslo_utils.importutils import import_object [as 别名]
def _driver(self):
        if self.__driver:
            return self.__driver

        self.__driver = importutils.import_object(CONF.quota.driver)
        return self.__driver 
开发者ID:openstack,项目名称:zun,代码行数:8,代码来源:quota.py

示例8: setUp

# 需要导入模块: from oslo_utils import importutils [as 别名]
# 或者: from oslo_utils.importutils import import_object [as 别名]
def setUp(self):
        flowclassifier_plugin = (
            test_flowclassifier_db.DB_FLOWCLASSIFIER_PLUGIN_CLASS)

        service_plugins = {
            flowclassifier.FLOW_CLASSIFIER_EXT: flowclassifier_plugin
        }
        fdb.FlowClassifierDbPlugin.supported_extension_aliases = [
            flowclassifier.FLOW_CLASSIFIER_EXT]
        fdb.FlowClassifierDbPlugin.path_prefix = (
            flowclassifier.FLOW_CLASSIFIER_PREFIX
        )
        super(OVSFlowClassifierDriverTestCase, self).setUp(
            ext_mgr=None,
            plugin=None,
            service_plugins=service_plugins
        )
        self.flowclassifier_plugin = importutils.import_object(
            flowclassifier_plugin)
        ext_mgr = api_ext.PluginAwareExtensionManager(
            test_flowclassifier_db.extensions_path,
            {
                flowclassifier.FLOW_CLASSIFIER_EXT: self.flowclassifier_plugin
            }
        )
        app = config.load_paste_app('extensions_test_app')
        self.ext_api = api_ext.ExtensionMiddleware(app, ext_mgr=ext_mgr)
        self.ctx = context.get_admin_context()
        self.driver = driver.OVSFlowClassifierDriver()
        self.driver.initialize() 
开发者ID:openstack,项目名称:networking-sfc,代码行数:32,代码来源:test_driver.py

示例9: setUp

# 需要导入模块: from oslo_utils import importutils [as 别名]
# 或者: from oslo_utils.importutils import import_object [as 别名]
def setUp(self, core_plugin=None, sfc_plugin=None,
              flowclassifier_plugin=None, ext_mgr=None):
        mock_log_p = mock.patch.object(sfc_db, 'LOG')
        self.mock_log = mock_log_p.start()
        cfg.CONF.register_opts(sfc.sfc_quota_opts, 'QUOTAS')
        if not sfc_plugin:
            sfc_plugin = DB_SFC_PLUGIN_CLASS
        if not flowclassifier_plugin:
            flowclassifier_plugin = (
                test_flowclassifier_db.DB_FLOWCLASSIFIER_PLUGIN_CLASS)

        service_plugins = {
            sfc.SFC_EXT: sfc_plugin,
            fc_ext.FLOW_CLASSIFIER_EXT: flowclassifier_plugin
        }
        sfc_db.SfcDbPlugin.supported_extension_aliases = [
            sfc.SFC_EXT, sg_ext.SG_EXT, tap_ext.TAP_EXT]
        sfc_db.SfcDbPlugin.path_prefix = sfc.SFC_PREFIX
        fdb.FlowClassifierDbPlugin.supported_extension_aliases = [
            fc_ext.FLOW_CLASSIFIER_EXT]
        fdb.FlowClassifierDbPlugin.path_prefix = (
            fc_ext.FLOW_CLASSIFIER_PREFIX
        )
        super(SfcDbPluginTestCase, self).setUp(
            ext_mgr=ext_mgr,
            plugin=core_plugin,
            service_plugins=service_plugins
        )
        if not ext_mgr:
            self.sfc_plugin = importutils.import_object(sfc_plugin)
            self.flowclassifier_plugin = importutils.import_object(
                flowclassifier_plugin)
            # Note (vks1): Auto-load extensions.
            ext_mgr = api_ext.PluginAwareExtensionManager.get_instance()
            app = config.load_paste_app('extensions_test_app')
            self.ext_api = api_ext.ExtensionMiddleware(app, ext_mgr=ext_mgr) 
开发者ID:openstack,项目名称:networking-sfc,代码行数:38,代码来源:test_sfc_db.py

示例10: setUp

# 需要导入模块: from oslo_utils import importutils [as 别名]
# 或者: from oslo_utils.importutils import import_object [as 别名]
def setUp(self, core_plugin=None, flowclassifier_plugin=None,
              ext_mgr=None):
        mock_log_p = mock.patch.object(fdb, 'LOG')
        self.mock_log = mock_log_p.start()
        cfg.CONF.register_opts(fc_ext.flow_classifier_quota_opts, 'QUOTAS')
        if not flowclassifier_plugin:
            flowclassifier_plugin = DB_FLOWCLASSIFIER_PLUGIN_CLASS
        service_plugins = {
            fc_ext.FLOW_CLASSIFIER_EXT: flowclassifier_plugin
        }
        fdb.FlowClassifierDbPlugin.supported_extension_aliases = [
            fc_ext.FLOW_CLASSIFIER_EXT]
        fdb.FlowClassifierDbPlugin.path_prefix = (
            fc_ext.FLOW_CLASSIFIER_PREFIX
        )
        super(FlowClassifierDbPluginTestCase, self).setUp(
            ext_mgr=ext_mgr,
            plugin=core_plugin,
            service_plugins=service_plugins
        )
        if not ext_mgr:
            self.flowclassifier_plugin = importutils.import_object(
                flowclassifier_plugin)
            ext_mgr = api_ext.PluginAwareExtensionManager(
                extensions_path,
                {fc_ext.FLOW_CLASSIFIER_EXT: self.flowclassifier_plugin}
            )
            app = config.load_paste_app('extensions_test_app')
            self.ext_api = api_ext.ExtensionMiddleware(app, ext_mgr=ext_mgr) 
开发者ID:openstack,项目名称:networking-sfc,代码行数:31,代码来源:test_flowclassifier_db.py

示例11: get_db

# 需要导入模块: from oslo_utils import importutils [as 别名]
# 或者: from oslo_utils.importutils import import_object [as 别名]
def get_db(driver=None):
    """Automatically loads the database driver to be used."""
    storage = CONF.get('storage')
    if not driver:
        driver = storage['driver']
    driver_instance = importutils.import_object(
        driver,
        backend=storage['backend']
    )

    return driver_instance 
开发者ID:openstack,项目名称:freezer-api,代码行数:13,代码来源:common.py

示例12: load_device_drivers

# 需要导入模块: from oslo_utils import importutils [as 别名]
# 或者: from oslo_utils.importutils import import_object [as 别名]
def load_device_drivers(self, host):
        """Loads one or more device drivers for VPNaaS."""
        drivers = []
        for device_driver in self.conf.vpnagent.vpn_device_driver:
            device_driver = provconfig.get_provider_driver_class(
                device_driver, DEVICE_DRIVERS)
            try:
                drivers.append(importutils.import_object(device_driver,
                                                         self,
                                                         host))
                LOG.debug('Loaded VPNaaS device driver: %s', device_driver)
            except ImportError:
                raise vpnaas.DeviceDriverImportError(
                    device_driver=device_driver)
        return drivers 
开发者ID:openstack,项目名称:neutron-vpnaas,代码行数:17,代码来源:vpn_service.py

示例13: _load_driver

# 需要导入模块: from oslo_utils import importutils [as 别名]
# 或者: from oslo_utils.importutils import import_object [as 别名]
def _load_driver(self, conf):
        self.lbdriver = None

        LOG.debug('loading LBaaS driver %s' %
                  conf.f5_bigip_lbaas_device_driver)
        try:
            self.lbdriver = importutils.import_object(
                conf.f5_bigip_lbaas_device_driver,
                self.conf)
            return
        except ImportError as ie:
            msg = ('Error importing loadbalancer device driver: %s error %s'
                   % (conf.f5_bigip_lbaas_device_driver, repr(ie)))
            LOG.error(msg)
            raise SystemExit(msg) 
开发者ID:F5Networks,项目名称:f5-openstack-agent,代码行数:17,代码来源:agent_manager.py

示例14: __init__

# 需要导入模块: from oslo_utils import importutils [as 别名]
# 或者: from oslo_utils.importutils import import_object [as 别名]
def __init__(self, driver, f5_global_routed_mode):
        self.conf = driver.conf
        self.driver = driver
        self.f5_global_routed_mode = f5_global_routed_mode
        self.vlan_binding = None
        self.fdb_connector = None
        self.interface_mapping = {}
        self.tagging_mapping = {}
        self.system_helper = SystemHelper()
        self.network_helper = NetworkHelper()
        self.service_adapter = ServiceModelAdapter(self.conf)

        if not f5_global_routed_mode:
            self.fdb_connector = FDBConnectorML2(self.conf)

        if self.conf.vlan_binding_driver:
            try:
                self.vlan_binding = importutils.import_object(
                    self.conf.vlan_binding_driver, self.conf, self)
            except ImportError:
                LOG.error('Failed to import VLAN binding driver: %s'
                          % self.conf.vlan_binding_driver)
                raise

        # map format is  phynet:interface:tagged
        for maps in self.conf.f5_external_physical_mappings:
            intmap = maps.split(':')
            net_key = str(intmap[0]).strip()
            if len(intmap) > 3:
                net_key = net_key + ':' + str(intmap[3]).strip()
            self.interface_mapping[net_key] = str(intmap[1]).strip()
            self.tagging_mapping[net_key] = str(intmap[2]).strip()
            LOG.debug('physical_network %s = interface %s, tagged %s'
                      % (net_key, intmap[1], intmap[2])) 
开发者ID:F5Networks,项目名称:f5-openstack-agent,代码行数:36,代码来源:l2_service.py

示例15: initialize_driver

# 需要导入模块: from oslo_utils import importutils [as 别名]
# 或者: from oslo_utils.importutils import import_object [as 别名]
def initialize_driver(self, conf):
        self.conf = conf or cfg.CONF.BGP
        try:
            self.dr_driver_cls = (
                    importutils.import_object(self.conf.bgp_speaker_driver,
                                              self.conf))
        except ImportError:
            LOG.exception(_LE("Error while importing BGP speaker driver %s"),
                          self.conf.bgp_speaker_driver)
            raise SystemExit(1) 
开发者ID:openstack,项目名称:neutron-dynamic-routing,代码行数:12,代码来源:bgp_dragent.py


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