• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python importutils.import_module函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中neutron.openstack.common.importutils.import_module函数的典型用法代码示例。如果您正苦于以下问题:Python import_module函数的具体用法?Python import_module怎么用?Python import_module使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: _mk_test_dp

 def _mk_test_dp(name):
     ofp = importutils.import_module("ryu.ofproto.ofproto_v1_3")
     ofpp = importutils.import_module("ryu.ofproto.ofproto_v1_3_parser")
     dp = mock.Mock()
     dp.ofproto = ofp
     dp.ofproto_parser = ofpp
     dp.__repr__ = lambda _self: name
     return dp
开发者ID:hughsaunders,项目名称:neutron,代码行数:8,代码来源:test_ofa_neutron_agent.py


示例2: _mk_test_dp

 def _mk_test_dp(self, name):
     ofp = importutils.import_module('ryu.ofproto.ofproto_v1_3')
     ofpp = importutils.import_module('ryu.ofproto.ofproto_v1_3_parser')
     dp = mock.Mock()
     dp.ofproto = ofp
     dp.ofproto_parser = ofpp
     dp.__repr__ = mock.Mock(return_value=name)
     return dp
开发者ID:AsherBond,项目名称:quantum,代码行数:8,代码来源:ofa_test_base.py


示例3: _get_impl

def _get_impl():
    """Delay import of rpc_backend until configuration is loaded."""
    global _RPCIMPL
    if _RPCIMPL is None:
        try:
            _RPCIMPL = importutils.import_module(CONF.rpc_backend)
        except ImportError:
            # For backwards compatibility with older nova config.
            impl = CONF.rpc_backend.replace("nova.rpc", "nova.openstack.common.rpc")
            _RPCIMPL = importutils.import_module(impl)
    return _RPCIMPL
开发者ID:nabilmaad,项目名称:neutron,代码行数:11,代码来源:__init__.py


示例4: test_setup_default_table

 def test_setup_default_table(self):
     br = self.br
     with mock.patch.object(br, '_send_msg') as sendmsg:
         br.setup_default_table()
     (dp, ofp, ofpp) = br._get_dp()
     arp = importutils.import_module('ryu.lib.packet.arp')
     ether = importutils.import_module('ryu.ofproto.ether')
     call = mock.call
     expected_calls = [
         call(ofpp.OFPFlowMod(dp, command=ofp.OFPFC_DELETE,
              match=ofpp.OFPMatch(), out_group=ofp.OFPG_ANY,
              out_port=ofp.OFPP_ANY, priority=0, table_id=ofp.OFPTT_ALL)),
         call(ofpp.OFPFlowMod(dp, priority=0, table_id=0)),
         call(ofpp.OFPFlowMod(dp, priority=0, table_id=1)),
         call(ofpp.OFPFlowMod(dp, priority=0, table_id=2)),
         call(ofpp.OFPFlowMod(dp, instructions=[
              ofpp.OFPInstructionGotoTable(table_id=7)],
              priority=0, table_id=3)),
         call(ofpp.OFPFlowMod(dp, instructions=[
              ofpp.OFPInstructionGotoTable(table_id=5)],
              priority=0, table_id=4)),
         call(ofpp.OFPFlowMod(dp, instructions=[
              ofpp.OFPInstructionGotoTable(table_id=6)],
              priority=0, table_id=5)),
         call(ofpp.OFPFlowMod(dp, instructions=[
              ofpp.OFPInstructionActions(ofp.OFPIT_APPLY_ACTIONS,
              [ofpp.OFPActionOutput(ofp.OFPP_CONTROLLER)])],
              match=ofpp.OFPMatch(arp_op=arp.ARP_REQUEST,
              eth_type=ether.ETH_TYPE_ARP), priority=1, table_id=6)),
         call(ofpp.OFPFlowMod(dp, instructions=[
              ofpp.OFPInstructionGotoTable(table_id=7)],
              priority=0, table_id=6)),
         call(ofpp.OFPFlowMod(dp, instructions=[
              ofpp.OFPInstructionGotoTable(table_id=8)],
              priority=0, table_id=7)),
         call(ofpp.OFPFlowMod(dp, instructions=[
              ofpp.OFPInstructionGotoTable(table_id=9)],
              priority=0, table_id=8)),
         call(ofpp.OFPFlowMod(dp, instructions=[
              ofpp.OFPInstructionGotoTable(table_id=10)],
              priority=0, table_id=9)),
         call(ofpp.OFPFlowMod(dp, instructions=[
              ofpp.OFPInstructionGotoTable(table_id=11)],
              priority=0, table_id=10)),
         call(ofpp.OFPFlowMod(dp, instructions=[
              ofpp.OFPInstructionGotoTable(table_id=12)],
              priority=0, table_id=11)),
         call(ofpp.OFPFlowMod(dp, instructions=[
              ofpp.OFPInstructionGotoTable(table_id=13)],
              priority=0, table_id=12)),
         call(ofpp.OFPFlowMod(dp, priority=0, table_id=13)),
     ]
     sendmsg.assert_has_calls(expected_calls, any_order=True)
开发者ID:asadoughi,项目名称:neutron,代码行数:53,代码来源:test_ofa_flows.py


示例5: setUp

 def setUp(self):
     super(OFAAgentTestBase, self).setUp()
     ryu_cfg = importutils.import_module('ryu.cfg')
     ryu_cfg.CONF = cfg.ConfigOpts()
     ryu_cfg.CONF.register_cli_opts([
         cfg.StrOpt('ofp-listen-host', default='',
                    help='openflow listen host'),
         cfg.IntOpt('ofp-tcp-listen-port', default=6633,
                    help='openflow tcp listen port')
     ])
     self.mod_agent = importutils.import_module(self._AGENT_NAME)
     self.ryuapp = mock.Mock()
开发者ID:kongseokhwan,项目名称:kulcloud-neutron,代码行数:12,代码来源:ofa_test_base.py


示例6: __call__

    def __call__(self, target, creds, enforcer):
        if self.target_field not in target:
            # policy needs a plugin check
            # target field is in the form resource:field
            # however if they're not separated by a colon, use an underscore
            # as a separator for backward compatibility

            def do_split(separator):
                parent_res, parent_field = self.target_field.split(separator, 1)
                return parent_res, parent_field

            for separator in (":", "_"):
                try:
                    parent_res, parent_field = do_split(separator)
                    break
                except ValueError:
                    LOG.debug(_("Unable to find ':' as separator in %s."), self.target_field)
            else:
                # If we are here split failed with both separators
                err_reason = _("Unable to find resource name in %s") % self.target_field
                LOG.exception(err_reason)
                raise exceptions.PolicyCheckError(policy="%s:%s" % (self.kind, self.match), reason=err_reason)
            parent_foreign_key = attributes.RESOURCE_FOREIGN_KEYS.get("%ss" % parent_res, None)
            if not parent_foreign_key:
                err_reason = _("Unable to verify match:%(match)s as the " "parent resource: %(res)s was not found") % {
                    "match": self.match,
                    "res": parent_res,
                }
                LOG.exception(err_reason)
                raise exceptions.PolicyCheckError(policy="%s:%s" % (self.kind, self.match), reason=err_reason)
            # NOTE(salv-orlando): This check currently assumes the parent
            # resource is handled by the core plugin. It might be worth
            # having a way to map resources to plugins so to make this
            # check more general
            # NOTE(ihrachys): if import is put in global, circular
            # import failure occurs
            manager = importutils.import_module("neutron.manager")
            f = getattr(manager.NeutronManager.get_instance().plugin, "get_%s" % parent_res)
            # f *must* exist, if not found it is better to let neutron
            # explode. Check will be performed with admin context
            context = importutils.import_module("neutron.context")
            try:
                data = f(context.get_admin_context(), target[parent_foreign_key], fields=[parent_field])
                target[self.target_field] = data[parent_field]
            except Exception:
                with excutils.save_and_reraise_exception():
                    LOG.exception(_LE("Policy check error while calling %s!"), f)
        match = self.match % target
        if self.kind in creds:
            return match == unicode(creds[self.kind])
        return False
开发者ID:asadoughi,项目名称:neutron,代码行数:51,代码来源:policy.py


示例7: setUp

 def setUp(self):
     self.fake_oflib_of = fake_oflib.patch_fake_oflib_of()
     self.fake_oflib_of.start()
     self.addCleanup(self.fake_oflib_of.stop)
     self.mod_agent = importutils.import_module(self._AGENT_NAME)
     super(OFAAgentTestBase, self).setUp()
     self.ryuapp = mock.Mock()
开发者ID:AsherBond,项目名称:quantum,代码行数:7,代码来源:ofa_test_base.py


示例8: setUp

    def setUp(self,
              plugin=MIDONET_PLUGIN_NAME,
              ext_mgr=None,
              service_plugins=None):

        self.midoclient_mock = mock.MagicMock()
        self.midoclient_mock.midonetclient.neutron.client.return_value = True
        modules = {
            'midonetclient': self.midoclient_mock,
            'midonetclient.neutron': self.midoclient_mock.neutron,
            'midonetclient.neutron.client': self.midoclient_mock.client,
        }

        self.module_patcher = mock.patch.dict('sys.modules', modules)
        self.module_patcher.start()

        # import midonetclient here because it needs proper mock objects to be
        # assigned to this module first.  'midoclient_mock' object is the
        # mock object used for this module.
        from midonetclient.neutron.client import MidonetClient
        client_class = MidonetClient
        self.mock_class = client_class()

        extensions_path = importutils.import_module(
            MIDOKURA_EXT_PATH).__file__
        cfg.CONF.set_override('api_extensions_path',
                              os.path.dirname(extensions_path))
        super(MidonetPluginV2TestCase, self).setUp(plugin=plugin)
开发者ID:zhangdy1985,项目名称:python-neutron-plugin-midonet,代码行数:28,代码来源:test_midonet_plugin.py


示例9: test_arp_passthrough

 def test_arp_passthrough(self):
     br = self.br
     with mock.patch.object(br, '_send_msg') as sendmsg:
         br.arp_passthrough(network=1234, tpa='192.0.2.1')
     (dp, ofp, ofpp) = br._get_dp()
     arp = importutils.import_module('ryu.lib.packet.arp')
     ether = importutils.import_module('ryu.ofproto.ether')
     call = mock.call
     expected_calls = [
         call(ofpp.OFPFlowMod(dp, idle_timeout=5,
              instructions=[ofpp.OFPInstructionGotoTable(table_id=7)],
              match=ofpp.OFPMatch(arp_op=arp.ARP_REQUEST,
              arp_tpa="192.0.2.1", eth_type=ether.ETH_TYPE_ARP,
              metadata=meta.mk_metadata(1234)), priority=1, table_id=5))
     ]
     sendmsg.assert_has_calls(expected_calls)
开发者ID:asadoughi,项目名称:neutron,代码行数:16,代码来源:test_ofa_flows.py


示例10: setUp

 def setUp(self):
     self.socket_mock = mock.patch(SERVERMANAGER + ".socket.create_connection").start()
     self.wrap_mock = mock.patch(SERVERMANAGER + ".ssl.wrap_socket").start()
     super(ServerManagerTests, self).setUp()
     # http patch must not be running or it will mangle the servermanager
     # import where the https connection classes are defined
     self.httpPatch.stop()
     self.sm = importutils.import_module(SERVERMANAGER)
开发者ID:li-ma,项目名称:neutron,代码行数:8,代码来源:test_servermanager.py


示例11: test__provision_local_vlan_outbound_flat

    def test__provision_local_vlan_outbound_flat(self):
        ofp = importutils.import_module("ryu.ofproto.ofproto_v1_3")
        ofpp = importutils.import_module("ryu.ofproto.ofproto_v1_3_parser")
        with mock.patch.object(self.agent, "ryu_send_msg") as sendmsg:
            self.agent._provision_local_vlan_outbound(888, ofp.OFPVID_NONE, "phys-net1")

        expected_msg = ofpp.OFPFlowMod(
            self.agent.phys_brs["phys-net1"].datapath,
            instructions=[
                ofpp.OFPInstructionActions(
                    ofp.OFPIT_APPLY_ACTIONS, [ofpp.OFPActionPopVlan(), ofpp.OFPActionOutput(ofp.OFPP_NORMAL, 0)]
                )
            ],
            match=ofpp.OFPMatch(in_port=777, vlan_vid=888 | ofp.OFPVID_PRESENT),
            priority=4,
        )
        sendmsg.assert_has_calls([mock.call(expected_msg)])
开发者ID:hughsaunders,项目名称:neutron,代码行数:17,代码来源:test_ofa_neutron_agent.py


示例12: _load_backend

 def _load_backend(self):
     with self._lock:
         if not self._backend:
             # Import the untranslated name if we don't have a mapping
             backend_path = self._backend_mapping.get(self._backend_name,
                                                      self._backend_name)
             backend_mod = importutils.import_module(backend_path)
             self._backend = backend_mod.get_backend()
开发者ID:ArifovicH,项目名称:neutron,代码行数:8,代码来源:api.py


示例13: nuageclient_init

 def nuageclient_init(self):
     server = cfg.CONF.RESTPROXY.server
     serverauth = cfg.CONF.RESTPROXY.serverauth
     serverssl = cfg.CONF.RESTPROXY.serverssl
     base_uri = cfg.CONF.RESTPROXY.base_uri
     auth_resource = cfg.CONF.RESTPROXY.auth_resource
     organization = cfg.CONF.RESTPROXY.organization
     nuageclient = importutils.import_module("nuagenetlib.nuageclient")
     self.nuageclient = nuageclient.NuageClient(server, base_uri, serverssl, serverauth, auth_resource, organization)
开发者ID:kavonm,项目名称:neutron,代码行数:9,代码来源:plugin.py


示例14: setUp

    def setUp(self):
        super(TestArpLib, self).setUp()

        self.mod_arplib = importutils.import_module(_OFALIB_NAME)
        self.arplib = self.mod_arplib.ArpLib(self.ryuapp)
        self.packet_mod.get_protocol = self._fake_get_protocol
        self._fake_get_protocol_ethernet = True
        self._fake_get_protocol_vlan = True
        self._fake_get_protocol_arp = True
开发者ID:AsherBond,项目名称:quantum,代码行数:9,代码来源:test_arp_lib.py


示例15: __init__

 def __init__(self, backend_mapping=None):
     if backend_mapping is None:
         backend_mapping = {}
     backend_name = CONF.database.backend
     # Import the untranslated name if we don't have a
     # mapping.
     backend_path = backend_mapping.get(backend_name, backend_name)
     backend_mod = importutils.import_module(backend_path)
     self.__backend = backend_mod.get_backend()
开发者ID:50infivedays,项目名称:neutron,代码行数:9,代码来源:api.py


示例16: _import_ncclient

    def _import_ncclient(self):
        """Import the NETCONF client (ncclient) module.

        The ncclient module is not installed as part of the normal Neutron
        distributions. It is imported dynamically in this module so that
        the import can be mocked, allowing unit testing without requiring
        the installation of ncclient.
        """
        return importutils.import_module('ncclient.manager')
开发者ID:godp1301,项目名称:ironic-neutron-plugin,代码行数:9,代码来源:driver.py


示例17: test_install_arp_responder

 def test_install_arp_responder(self):
     br = self.br
     with mock.patch.object(br, '_send_msg') as sendmsg:
         br.install_arp_responder(table_id=99)
     (dp, ofp, ofpp) = br._get_dp()
     arp = importutils.import_module('ryu.lib.packet.arp')
     ether = importutils.import_module('ryu.ofproto.ether')
     call = mock.call
     expected_calls = [
         call(ofpp.OFPFlowMod(dp, instructions=[
              ofpp.OFPInstructionActions(ofp.OFPIT_APPLY_ACTIONS,
              [ofpp.OFPActionOutput(ofp.OFPP_CONTROLLER)])],
              match=ofpp.OFPMatch(arp_op=arp.ARP_REQUEST,
              eth_type=ether.ETH_TYPE_ARP), priority=1, table_id=99)),
         call(ofpp.OFPFlowMod(dp, instructions=[
              ofpp.OFPInstructionGotoTable(table_id=100)],
              priority=0, table_id=99)),
     ]
     sendmsg.assert_has_calls(expected_calls)
开发者ID:asadoughi,项目名称:neutron,代码行数:19,代码来源:test_ofa_flows.py


示例18: _service_admin_creds

    def _service_admin_creds(api_version=2):
        # Import auth_token to have keystone_authtoken settings setup.
        importutils.import_module('keystoneclient.middleware.auth_token')

        creds = {
            'username': cfg.CONF.keystone_authtoken.admin_user,
            'password': cfg.CONF.keystone_authtoken.admin_password,
        }
        if api_version >= 3:
            creds['auth_url'] =\
                cfg.CONF.keystone_authtoken.auth_uri.replace('v2.0', 'v3')
            creds['project_name'] =\
                cfg.CONF.keystone_authtoken.admin_tenant_name
        else:
            creds['auth_url'] = cfg.CONF.keystone_authtoken.auth_uri
            creds['tenant_name'] =\
                cfg.CONF.keystone_authtoken.admin_tenant_name

        return creds
开发者ID:HybridCloud-dew,项目名称:hws,代码行数:19,代码来源:neutron_keystoneclient.py


示例19: main

def main():
    cfg.CONF(default_config_files=(
        [NUAGE_CONFIG_FILE]))
    config.nuage_register_cfg_opts()
    server = cfg.CONF.RESTPROXY.server
    serverauth = cfg.CONF.RESTPROXY.serverauth
    serverssl = cfg.CONF.RESTPROXY.serverssl
    base_uri = cfg.CONF.RESTPROXY.base_uri
    auth_resource = cfg.CONF.RESTPROXY.auth_resource
    organization = cfg.CONF.RESTPROXY.organization
    fipquota = str(cfg.CONF.RESTPROXY.default_floatingip_quota)
    logging = importutils.import_module('logging')
    nuageclientinst = importutils.import_module('nuagenetlib.nuageclient')
    nuageclient = nuageclientinst.NuageClient(server, base_uri,
                                              serverssl, serverauth,
                                              auth_resource,
                                              organization)
    logging.basicConfig(level=logging.DEBUG)
    SyncManager(nuageclient).synchronize(fipquota)
开发者ID:chrisacbr,项目名称:openstack-neutron,代码行数:19,代码来源:syncmanager.py


示例20: setUp

    def setUp(self):
        super(OFAAgentTestCase, self).setUp()

        Net = collections.namedtuple('Net', 'net, mac, ip')
        self.nets = [Net(net=10, mac='11:11:11:44:55:66', ip='10.1.2.20'),
                     Net(net=10, mac='11:11:11:44:55:67', ip='10.1.2.21'),
                     Net(net=20, mac='22:22:22:44:55:66', ip='10.2.2.20')]

        self.packet_mod = mock.Mock()
        self.proto_ethernet_mod = mock.Mock()
        self.proto_vlan_mod = mock.Mock()
        self.proto_vlan_mod.vid = 999
        self.proto_arp_mod = mock.Mock()
        self.fake_get_protocol = mock.Mock(return_value=self.proto_vlan_mod)
        self.packet_mod.get_protocol = self.fake_get_protocol
        self.fake_add_protocol = mock.Mock()
        self.packet_mod.add_protocol = self.fake_add_protocol
        self.arp = importutils.import_module('ryu.lib.packet.arp')
        self.ethernet = importutils.import_module('ryu.lib.packet.ethernet')
        self.vlan = importutils.import_module('ryu.lib.packet.vlan')
        mock.patch('ryu.lib.packet.packet.Packet',
                   return_value=self.packet_mod).start()

        self.ryuapp = 'ryuapp'
        self.inport = '1'
        self.ev = mock.Mock()
        self.datapath = self._mk_test_dp('tun_br')
        self.ofproto = importutils.import_module('ryu.ofproto.ofproto_v1_3')
        self.ofpp = mock.Mock()
        self.datapath.ofproto = self.ofproto
        self.datapath.ofproto_parser = self.ofpp
        self.OFPActionOutput = mock.Mock()
        self.OFPActionOutput.return_value = 'OFPActionOutput'
        self.ofpp.OFPActionOutput = self.OFPActionOutput
        self.msg = mock.Mock()
        self.msg.datapath = self.datapath
        self.msg.buffer_id = self.ofproto.OFP_NO_BUFFER
        self.msg_data = 'test_message_data'
        self.msg.data = self.msg_data
        self.ev.msg = self.msg
        self.msg.match = {'in_port': self.inport,
                          'metadata': meta.LOCAL | self.nets[0].net}
开发者ID:iuliat,项目名称:neutron,代码行数:42,代码来源:test_arp_lib.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python importutils.import_object函数代码示例发布时间:2022-05-27
下一篇:
Python importutils.import_class函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap