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

Python ip_lib.vxlan_in_use函数代码示例

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

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



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

示例1: test_vxlan_exists

 def test_vxlan_exists(self):
     attr = self.generate_device_details()
     ip = ip_lib.IPWrapper(namespace=attr.namespace)
     ip.netns.add(attr.namespace)
     self.addCleanup(ip.netns.delete, attr.namespace)
     self.assertFalse(ip_lib.vxlan_in_use(9999, namespace=attr.namespace))
     device = ip.add_vxlan(attr.name, 9999)
     self.addCleanup(self._safe_delete_device, device)
     self.assertTrue(ip_lib.vxlan_in_use(9999, namespace=attr.namespace))
     device.link.delete()
     self.assertFalse(ip_lib.vxlan_in_use(9999, namespace=attr.namespace))
开发者ID:Lily913,项目名称:neutron,代码行数:11,代码来源:test_ip_lib.py


示例2: vxlan_ucast_supported

    def vxlan_ucast_supported(self):
        if not cfg.CONF.VXLAN.l2_population:
            return False
        if not ip_lib.iproute_arg_supported(
                ['bridge', 'fdb'], 'append'):
            LOG.warning(_LW('Option "%(option)s" must be supported by command '
                            '"%(command)s" to enable %(mode)s mode'),
                        {'option': 'append',
                         'command': 'bridge fdb',
                         'mode': 'VXLAN UCAST'})
            return False

        test_iface = None
        for seg_id in moves.range(1, p_const.MAX_VXLAN_VNI + 1):
            if (ip_lib.device_exists(self.get_vxlan_device_name(seg_id))
                    or ip_lib.vxlan_in_use(seg_id)):
                continue
            test_iface = self.ensure_vxlan(seg_id)
            break
        else:
            LOG.error(_LE('No valid Segmentation ID to perform UCAST test.'))
            return False

        try:
            utils.execute(
                cmd=['bridge', 'fdb', 'append', constants.FLOODING_ENTRY[0],
                     'dev', test_iface, 'dst', '1.1.1.1'],
                run_as_root=True, log_fail_as_error=False)
            return True
        except RuntimeError:
            return False
        finally:
            self.delete_interface(test_iface)
开发者ID:dims,项目名称:neutron,代码行数:33,代码来源:linuxbridge_neutron_agent.py


示例3: ensure_vxlan

 def ensure_vxlan(self, segmentation_id):
     """Create a vxlan unless it already exists."""
     interface = self.get_vxlan_device_name(segmentation_id)
     if not ip_lib.device_exists(interface):
         LOG.debug("Creating vxlan interface %(interface)s for "
                   "VNI %(segmentation_id)s",
                   {'interface': interface,
                    'segmentation_id': segmentation_id})
         args = {'dev': self.local_int}
         if self.vxlan_mode == lconst.VXLAN_MCAST:
             args['group'] = self.get_vxlan_group(segmentation_id)
         if cfg.CONF.VXLAN.ttl:
             args['ttl'] = cfg.CONF.VXLAN.ttl
         if cfg.CONF.VXLAN.tos:
             args['tos'] = cfg.CONF.VXLAN.tos
         if cfg.CONF.VXLAN.l2_population:
             args['proxy'] = True
         try:
             int_vxlan = self.ip.add_vxlan(interface, segmentation_id,
                                           **args)
         except RuntimeError:
             with excutils.save_and_reraise_exception() as ctxt:
                 # perform this check after an attempt rather than before
                 # to avoid excessive lookups and a possible race condition.
                 if ip_lib.vxlan_in_use(segmentation_id):
                     ctxt.reraise = False
                     LOG.error(_LE("Unable to create VXLAN interface for "
                                   "VNI %s because it is in use by another "
                                   "interface."), segmentation_id)
                     return None
         int_vxlan.link.set_up()
         LOG.debug("Done creating vxlan interface %s", interface)
     return interface
开发者ID:dims,项目名称:neutron,代码行数:33,代码来源:linuxbridge_neutron_agent.py


示例4: ensure_vxlan

    def ensure_vxlan(self, segmentation_id, mtu=None):
        """Create a vxlan unless it already exists."""
        interface = self.get_vxlan_device_name(segmentation_id)
        if not ip_lib.device_exists(interface):
            LOG.debug("Creating vxlan interface %(interface)s for "
                      "VNI %(segmentation_id)s",
                      {'interface': interface,
                       'segmentation_id': segmentation_id})
            args = {'dev': self.local_int,
                    'srcport': (cfg.CONF.VXLAN.udp_srcport_min,
                                cfg.CONF.VXLAN.udp_srcport_max),
                    'dstport': cfg.CONF.VXLAN.udp_dstport,
                    'ttl': cfg.CONF.VXLAN.ttl}
            if cfg.CONF.VXLAN.tos:
                args['tos'] = cfg.CONF.VXLAN.tos
                if cfg.CONF.AGENT.dscp or cfg.CONF.AGENT.dscp_inherit:
                    LOG.warning('The deprecated tos option in group VXLAN '
                                'is set and takes precedence over dscp and '
                                'dscp_inherit in group AGENT.')
            elif cfg.CONF.AGENT.dscp_inherit:
                args['tos'] = 'inherit'
            elif cfg.CONF.AGENT.dscp:
                args['tos'] = int(cfg.CONF.AGENT.dscp) << 2

            if self.vxlan_mode == lconst.VXLAN_MCAST:
                args['group'] = self.get_vxlan_group(segmentation_id)
            if cfg.CONF.VXLAN.l2_population:
                args['proxy'] = cfg.CONF.VXLAN.arp_responder

            try:
                int_vxlan = self.ip.add_vxlan(interface, segmentation_id,
                                              **args)
            except RuntimeError:
                with excutils.save_and_reraise_exception() as ctxt:
                    # perform this check after an attempt rather than before
                    # to avoid excessive lookups and a possible race condition.
                    if ip_lib.vxlan_in_use(segmentation_id):
                        ctxt.reraise = False
                        LOG.error("Unable to create VXLAN interface for "
                                  "VNI %s because it is in use by another "
                                  "interface.", segmentation_id)
                        return None
            if mtu:
                try:
                    int_vxlan.link.set_mtu(mtu)
                except ip_lib.InvalidArgument:
                    phys_dev_mtu = ip_lib.get_device_mtu(self.local_int)
                    LOG.error("Provided MTU value %(mtu)s for VNI "
                              "%(segmentation_id)s is too high according "
                              "to physical device %(dev)s MTU=%(phys_mtu)s.",
                              {'mtu': mtu,
                               'segmentation_id': segmentation_id,
                               'dev': self.local_int,
                               'phys_mtu': phys_dev_mtu})
                    int_vxlan.link.delete()
                    return None
            int_vxlan.disable_ipv6()
            int_vxlan.link.set_up()
            LOG.debug("Done creating vxlan interface %s", interface)
        return interface
开发者ID:noironetworks,项目名称:neutron,代码行数:60,代码来源:linuxbridge_neutron_agent.py


示例5: vxlan_ucast_supported

    def vxlan_ucast_supported(self):
        if not cfg.CONF.VXLAN.l2_population:
            return False
        if not ip_lib.iproute_arg_supported(["bridge", "fdb"], "append"):
            LOG.warning(
                _LW('Option "%(option)s" must be supported by command ' '"%(command)s" to enable %(mode)s mode'),
                {"option": "append", "command": "bridge fdb", "mode": "VXLAN UCAST"},
            )
            return False

        test_iface = None
        for seg_id in moves.range(1, p_const.MAX_VXLAN_VNI + 1):
            if ip_lib.device_exists(self.get_vxlan_device_name(seg_id)) or ip_lib.vxlan_in_use(seg_id):
                continue
            test_iface = self.ensure_vxlan(seg_id)
            break
        else:
            LOG.error(_LE("No valid Segmentation ID to perform UCAST test."))
            return False

        try:
            utils.execute(
                cmd=["bridge", "fdb", "append", constants.FLOODING_ENTRY[0], "dev", test_iface, "dst", "1.1.1.1"],
                run_as_root=True,
                log_fail_as_error=False,
            )
            return True
        except RuntimeError:
            return False
        finally:
            self.delete_interface(test_iface)
开发者ID:FedericoRessi,项目名称:neutron,代码行数:31,代码来源:linuxbridge_neutron_agent.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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