本文整理汇总了Python中f5_openstack_agent.lbaasv2.drivers.bigip.network_helper.NetworkHelper.add_fdb_entries方法的典型用法代码示例。如果您正苦于以下问题:Python NetworkHelper.add_fdb_entries方法的具体用法?Python NetworkHelper.add_fdb_entries怎么用?Python NetworkHelper.add_fdb_entries使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类f5_openstack_agent.lbaasv2.drivers.bigip.network_helper.NetworkHelper
的用法示例。
在下文中一共展示了NetworkHelper.add_fdb_entries方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_network_helper_add_fdb_entries
# 需要导入模块: from f5_openstack_agent.lbaasv2.drivers.bigip.network_helper import NetworkHelper [as 别名]
# 或者: from f5_openstack_agent.lbaasv2.drivers.bigip.network_helper.NetworkHelper import add_fdb_entries [as 别名]
def test_network_helper_add_fdb_entries(self, l2_service, service, bigips):
# add first member fdb entry
loadbalancer = None
members = list()
member = service['members'][0]
network_id = member['network_id']
member['network'] = service['networks'][network_id]
members.append(member)
tunnel_records = l2_service.create_fdb_records(loadbalancer, members)
network_helper = NetworkHelper()
fdb_entry = mock.MagicMock()
fdb_entry.modify = mock.MagicMock()
bigip = bigips[0]
bigip.tm.net.fdb.tunnels.tunnel.load = mock.MagicMock(
return_value=fdb_entry)
network_helper.add_fdb_entries(bigip, fdb_entries=tunnel_records)
# expect to modify with first member's VTEP and MAC addr
fdb_entry.modify.assert_called_with(
records=[{'endpoint': '192.168.130.59',
'name': 'fa:16:3e:0d:fa:c8'}])
# add second member fdb entry
members = list()
member = service['members'][1]
network_id = member['network_id']
member['network'] = service['networks'][network_id]
members.append(member)
tunnel_records = l2_service.create_fdb_records(loadbalancer, members)
network_helper.add_fdb_entries(bigip, fdb_entries=tunnel_records)
# expect to modify with second member's VTEP and MAC addr
fdb_entry.modify.assert_called_with(
records=[{'endpoint': '192.168.130.60',
'name': 'fa:16:3e:0d:fa:c6'}])
示例2: L2ServiceBuilder
# 需要导入模块: from f5_openstack_agent.lbaasv2.drivers.bigip.network_helper import NetworkHelper [as 别名]
# 或者: from f5_openstack_agent.lbaasv2.drivers.bigip.network_helper.NetworkHelper import add_fdb_entries [as 别名]
#.........这里部分代码省略.........
self.network_helper.delete_tunnel(
bigip,
tunnel_name,
partition=network_folder)
except Exception as err:
# Just log the exception, we want to continue cleanup
LOG.exception(err)
LOG.error(
"Failed to delete gre tunnel: %s" % tunnel_name)
if self.fdb_connector:
self.fdb_connector.notify_vtep_removed(network, bigip.local_ip)
def _delete_vcmp_device_network(self, bigip, vlan_name):
'''Disassociated VLAN with vCMP Guest, then delete it from vCMP Host
:param bigip: ManagementRoot object -- vCMP guest
:param vlan_name: str -- name of vlan
'''
if not self.vcmp_manager:
return
vcmp_host = self.vcmp_manager.get_vcmp_host(bigip)
if not vcmp_host:
return
self.vcmp_manager.disassoc_vlan_with_vcmp_guest(bigip, vlan_name)
def add_bigip_fdb(self, bigip, fdb):
# Add entries from the fdb relevant to the bigip
for fdb_operation in \
[{'network_type': 'vxlan',
'get_tunnel_folder': self.network_helper.get_tunnel_folder,
'fdb_method': self.network_helper.add_fdb_entries},
{'network_type': 'gre',
'get_tunnel_folder': self.network_helper.get_tunnel_folder,
'fdb_method': self.network_helper.add_fdb_entries}]:
self._operate_bigip_fdb(bigip, fdb, fdb_operation)
def _operate_bigip_fdb(self, bigip, fdb, fdb_operation):
"""Add L2 records for MAC addresses behind tunnel endpoints.
Description of fdb structure:
{'<network_id>':
'segment_id': <int>
'ports': [ '<vtep>': ['<mac_address>': '<ip_address>'] ]
'<network_id>':
'segment_id':
'ports': [ '<vtep>': ['<mac_address>': '<ip_address>'] ] }
Sample real fdb structure:
{u'45bbbce1-191b-4f7b-84c5-54c6c8243bd2':
{u'segment_id': 1008,
u'ports':
{u'10.30.30.2': [[u'00:00:00:00:00:00', u'0.0.0.0'],
[u'fa:16:3e:3d:7b:7f', u'10.10.1.4']]},
u'network_type': u'vxlan'}}
"""
network_type = fdb_operation['network_type']
get_tunnel_folder = fdb_operation['get_tunnel_folder']
fdb_method = fdb_operation['fdb_method']
for network in fdb:
net_fdb = fdb[network]
if net_fdb['network_type'] == network_type: