本文整理汇总了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;未经允许,请勿转载。 |
请发表评论