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

Python base.get_rand_device_name函数代码示例

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

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



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

示例1: test_install_flood_to_tun

    def test_install_flood_to_tun(self):
        attrs = {
            'remote_ip': '192.0.2.1',  # RFC 5737 TEST-NET-1
            'local_ip': '198.51.100.1',  # RFC 5737 TEST-NET-2
        }
        kwargs = {'vlan': 777, 'tun_id': 888}
        port_name = tests_base.get_rand_device_name(net_helpers.PORT_PREFIX)
        ofport = self.br_tun.add_tunnel_port(port_name, attrs['remote_ip'],
                                             attrs['local_ip'])
        self.br_tun.install_flood_to_tun(ports=[ofport], **kwargs)
        test_packet = ("icmp,in_port=%d," % self.tun_p +
                       "dl_src=12:34:56:ab:cd:ef,dl_dst=12:34:56:78:cc:dd,"
                       "nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_ecn=0,"
                       "nw_tos=0,nw_ttl=128,icmp_type=8,icmp_code=0,"
                       "dl_vlan=%(vlan)d,dl_vlan_pcp=0" % kwargs)
        trace = self._run_trace(self.tun_br.br_name, test_packet)
        self.assertTrue(("tun_id=0x%(tun_id)x" % kwargs) in
                        trace["Final flow"])
        self.assertTrue("vlan_tci=0x0000," in trace["Final flow"])

        self.br_tun.delete_flood_to_tun(kwargs['vlan'])

        trace = self._run_trace(self.tun_br.br_name, test_packet)
        self.assertEqual(" unchanged", trace["Final flow"])
        self.assertTrue("drop" in trace["Datapath actions"])
开发者ID:HoratiusTang,项目名称:neutron,代码行数:25,代码来源:test_ovs_flows.py


示例2: test_add_patch_port

 def test_add_patch_port(self):
     local = tests_base.get_rand_device_name(net_helpers.PORT_PREFIX)
     peer = 'remotepeer'
     self.br.add_patch_port(local, peer)
     self.assertEqual(self.ovs.db_get_val('Interface', local, 'type'),
                      'patch')
     options = self.ovs.db_get_val('Interface', local, 'options')
     self.assertEqual(peer, options['peer'])
开发者ID:gotostack,项目名称:neutron,代码行数:8,代码来源:test_ovs_lib.py


示例3: _test_add_tunnel_port

 def _test_add_tunnel_port(self, attrs):
     port_name = tests_base.get_rand_device_name(net_helpers.PORT_PREFIX)
     self.br.add_tunnel_port(port_name, attrs['remote_ip'],
                             attrs['local_ip'])
     self.assertEqual('gre',
                      self.ovs.db_get_val('Interface', port_name, 'type'))
     options = self.ovs.db_get_val('Interface', port_name, 'options')
     for attr, val in attrs.items():
         self.assertEqual(val, options[attr])
开发者ID:gotostack,项目名称:neutron,代码行数:9,代码来源:test_ovs_lib.py


示例4: create_patch_ports

def create_patch_ports(source, destination):
    """Hook up two OVS bridges.

    The result is two patch ports, each end connected to a bridge.
    The two patch port names will start with 'patch-', followed by identical
    four characters. For example patch-xyzw-fedora, and patch-xyzw-ubuntu,
    where fedora and ubuntu are random strings.

    :param source: Instance of OVSBridge
    :param destination: Instance of OVSBridge
    """
    common = tests_base.get_rand_name(max_length=4, prefix='')
    prefix = '%s-%s-' % (PATCH_PREFIX, common)

    source_name = tests_base.get_rand_device_name(prefix=prefix)
    destination_name = tests_base.get_rand_device_name(prefix=prefix)

    source.add_patch_port(source_name, destination_name)
    destination.add_patch_port(destination_name, source_name)
开发者ID:21atlas,项目名称:neutron,代码行数:19,代码来源:net_helpers.py


示例5: ovs_conntrack_supported

def ovs_conntrack_supported():
    br_name = base.get_rand_device_name(prefix="ovs-test-")

    with ovs_lib.OVSBridge(br_name) as br:
        try:
            br.set_protocols(["OpenFlow%d" % i for i in range(10, 15)])
        except RuntimeError as e:
            LOG.debug("Exception while checking ovs conntrack support: %s", e)
            return False
    return ofctl_arg_supported(cmd='add-flow', ct_state='+trk', actions='drop')
开发者ID:FengFengHan,项目名称:neutron,代码行数:10,代码来源:checks.py


示例6: test_replace_port

 def test_replace_port(self):
     port_name = tests_base.get_rand_device_name(net_helpers.PORT_PREFIX)
     self.br.replace_port(port_name, ('type', 'internal'))
     self.assertTrue(self.br.port_exists(port_name))
     self.assertEqual('internal',
                      self.br.db_get_val('Interface', port_name, 'type'))
     self.br.replace_port(port_name, ('type', 'internal'),
                          ('external_ids', {'test': 'test'}))
     self.assertTrue(self.br.port_exists(port_name))
     self.assertEqual('test', self.br.db_get_val('Interface', port_name,
                                                 'external_ids')['test'])
开发者ID:gotostack,项目名称:neutron,代码行数:11,代码来源:test_ovs_lib.py


示例7: test_add_tunnel_port

 def test_add_tunnel_port(self):
     attrs = {
         'remote_ip': '192.0.2.1',  # RFC 5737 TEST-NET-1
         'local_ip': '198.51.100.1',  # RFC 5737 TEST-NET-2
     }
     port_name = tests_base.get_rand_device_name(net_helpers.PORT_PREFIX)
     self.br.add_tunnel_port(port_name, attrs['remote_ip'],
                             attrs['local_ip'])
     self.assertEqual(self.ovs.db_get_val('Interface', port_name, 'type'),
                      'gre')
     options = self.ovs.db_get_val('Interface', port_name, 'options')
     for attr, val in attrs.items():
         self.assertEqual(val, options[attr])
开发者ID:ytwxy99,项目名称:neutron,代码行数:13,代码来源:test_ovs_lib.py


示例8: _setUp

    def _setUp(self):
        super(OVSPortFixture, self)._setUp()

        interface_config = cfg.ConfigOpts()
        interface_config.register_opts(interface.OPTS)
        ovs_interface = interface.OVSInterfaceDriver(interface_config)

        port_name = tests_base.get_rand_device_name(PORT_PREFIX)
        ovs_interface.plug_new(
            None,
            self.port_id,
            port_name,
            self.mac,
            bridge=self.bridge.br_name,
            namespace=self.namespace)
        self.addCleanup(self.bridge.delete_port, port_name)
        self.port = ip_lib.IPDevice(port_name, self.namespace)
开发者ID:abhilabh,项目名称:neutron,代码行数:17,代码来源:net_helpers.py


示例9: ofctl_arg_supported

def ofctl_arg_supported(cmd, **kwargs):
    """Verify if ovs-ofctl binary supports cmd with **kwargs.

    :param cmd: ovs-ofctl command to use for test.
    :param **kwargs: arguments to test with the command.
    :returns: a boolean if the supplied arguments are supported.
    """
    br_name = base.get_rand_device_name(prefix='br-test-')
    with ovs_lib.OVSBridge(br_name) as test_br:
        full_args = ["ovs-ofctl", cmd, test_br.br_name,
                     ovs_lib._build_flow_expr_str(kwargs, cmd.split('-')[0])]
        try:
            agent_utils.execute(full_args, run_as_root=True)
        except RuntimeError as e:
            LOG.debug("Exception while checking supported feature via "
                      "command %s. Exception: %s", full_args, e)
            return False
        except Exception:
            LOG.exception(_LE("Unexpected exception while checking supported"
                              " feature via command: %s"), full_args)
            return False
        else:
            return True
开发者ID:ISCAS-VDI,项目名称:neutron-base,代码行数:23,代码来源:checks.py


示例10: _generate_tun_peer

 def _generate_tun_peer(self):
     return base.get_rand_device_name(prefix='patch-int')
开发者ID:Lily913,项目名称:neutron,代码行数:2,代码来源:config.py


示例11: create_ovs_port

 def create_ovs_port(self, *interface_attrs):
     # Convert ((a, b), (c, d)) to {a: b, c: d} and add 'type' by default
     attrs = collections.OrderedDict(interface_attrs)
     attrs.setdefault('type', 'internal')
     port_name = tests_base.get_rand_device_name(net_helpers.PORT_PREFIX)
     return (port_name, self.br.add_port(port_name, *attrs.items()))
开发者ID:gotostack,项目名称:neutron,代码行数:6,代码来源:test_ovs_lib.py


示例12: ovs_geneve_supported

def ovs_geneve_supported(from_ip='192.0.2.3', to_ip='192.0.2.4'):
    name = base.get_rand_device_name(prefix='genevetest-')
    with ovs_lib.OVSBridge(name) as br:
        port = br.add_tunnel_port(from_ip, to_ip, const.TYPE_GENEVE)
        return port != ovs_lib.INVALID_OFPORT
开发者ID:ISCAS-VDI,项目名称:neutron-base,代码行数:5,代码来源:checks.py


示例13: iproute2_vxlan_supported

def iproute2_vxlan_supported():
    ip = ip_lib.IPWrapper()
    name = base.get_rand_device_name(prefix='vxlantest-')
    port = ip.add_vxlan(name, 3000)
    ip.del_veth(name)
    return name == port.name
开发者ID:ISCAS-VDI,项目名称:neutron-base,代码行数:6,代码来源:checks.py


示例14: get_veth_name

 def get_veth_name(name):
     if name.startswith(VETH0_PREFIX):
         return tests_base.get_rand_device_name(VETH0_PREFIX)
     if name.startswith(VETH1_PREFIX):
         return tests_base.get_rand_device_name(VETH1_PREFIX)
     return name
开发者ID:21atlas,项目名称:neutron,代码行数:6,代码来源:net_helpers.py


示例15: _generate_external_bridge

 def _generate_external_bridge(self):
     return base.get_rand_device_name(prefix='br-ex')
开发者ID:Lily913,项目名称:neutron,代码行数:2,代码来源:config.py


示例16: ovs_vxlan_supported

def ovs_vxlan_supported(from_ip='192.0.2.1', to_ip='192.0.2.2'):
    name = base.get_rand_device_name(prefix='vxlantest-')
    with ovs_lib.OVSBridge(name) as br:
        port = br.add_tunnel_port(from_ip, to_ip, const.TYPE_VXLAN)
        return port != ovs_lib.INVALID_OFPORT
开发者ID:ISCAS-VDI,项目名称:neutron-base,代码行数:5,代码来源:checks.py


示例17: _generate_tunnel_bridge

 def _generate_tunnel_bridge(self):
     return base.get_rand_device_name(prefix='br-tun')
开发者ID:Lily913,项目名称:neutron,代码行数:2,代码来源:config.py


示例18: _generate_integration_bridge

 def _generate_integration_bridge(self):
     return base.get_rand_device_name(prefix='br-int')
开发者ID:Lily913,项目名称:neutron,代码行数:2,代码来源:config.py


示例19: _generate_bridge_mappings

 def _generate_bridge_mappings(self):
     return 'physnet1:%s' % base.get_rand_device_name(prefix='br-eth')
开发者ID:Lily913,项目名称:neutron,代码行数:2,代码来源:config.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python base.get_rand_name函数代码示例发布时间:2022-05-27
下一篇:
Python base._run函数代码示例发布时间: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