當前位置: 首頁>>代碼示例>>Python>>正文


Python NetworkHelper.add_fdb_entries方法代碼示例

本文整理匯總了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'}])
開發者ID:pjbreaux,項目名稱:f5-openstack-agent,代碼行數:40,代碼來源:test_l2_service.py

示例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:
開發者ID:jputrino,項目名稱:f5-openstack-agent,代碼行數:70,代碼來源:l2_service.py


注:本文中的f5_openstack_agent.lbaasv2.drivers.bigip.network_helper.NetworkHelper.add_fdb_entries方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。