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


Python NetworkHelper.delete_fdb_entries方法代碼示例

本文整理匯總了Python中f5_openstack_agent.lbaasv2.drivers.bigip.network_helper.NetworkHelper.delete_fdb_entries方法的典型用法代碼示例。如果您正苦於以下問題:Python NetworkHelper.delete_fdb_entries方法的具體用法?Python NetworkHelper.delete_fdb_entries怎麽用?Python NetworkHelper.delete_fdb_entries使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在f5_openstack_agent.lbaasv2.drivers.bigip.network_helper.NetworkHelper的用法示例。


在下文中一共展示了NetworkHelper.delete_fdb_entries方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_network_helper_delete_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 delete_fdb_entries [as 別名]
    def test_network_helper_delete_fdb_entries(
            self, l2_service, service, bigips):
        # delete member fdb entry
        loadbalancer = None
        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 = NetworkHelper()
        tunnel = mock.MagicMock()
        tunnel.exists = mock.MagicMock(return_value=True)

        tunnel_record = mock.MagicMock()
        tunnel.records_s.records.load = mock.MagicMock(
            return_value=tunnel_record)
        tunnel.records_s.records.exist = mock.MagicMock(return_value=True)

        bigip = bigips[0]
        bigip.tm.net.fdb.tunnels.tunnel.load = mock.MagicMock(
            return_value=tunnel)
        network_helper.delete_fdb_entries(bigip, fdb_entries=tunnel_records)

        # expect to delete
        tunnel_record.delete.assert_called()
開發者ID:jputrino,項目名稱:f5-openstack-agent,代碼行數:30,代碼來源:test_l2_service.py

示例2: test_network_helper_delete_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 delete_fdb_entries [as 別名]
    def test_network_helper_delete_fdb_entries(
            self, l2_service, service, bigips):
        # delete member fdb entry
        loadbalancer = None
        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 = 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.delete_fdb_entries(bigip, fdb_entries=tunnel_records)

        # expect to modify with no records (i.e, removing entry)
        fdb_entry.modify.assert_called_with(records=None)
開發者ID:pjbreaux,項目名稱:f5-openstack-agent,代碼行數:24,代碼來源:test_l2_service.py

示例3: L2ServiceBuilder

# 需要導入模塊: from f5_openstack_agent.lbaasv2.drivers.bigip.network_helper import NetworkHelper [as 別名]
# 或者: from f5_openstack_agent.lbaasv2.drivers.bigip.network_helper.NetworkHelper import delete_fdb_entries [as 別名]

#.........這裏部分代碼省略.........
        # Add L2 records for a specific network+vtep
        folder = vtep_info['folder']
        tunnel_name = vtep_info['tunnel_name']
        for entry in vtep_info['fdb_entries']:
            mac_address = entry[0]
            if mac_address == '00:00:00:00:00:00':
                continue
            ip_address = entry[1]

            # create/get tunnel data
            if tunnel_name not in fdbs:
                fdbs[tunnel_name] = {}
            tunnel_fdbs = fdbs[tunnel_name]
            # update tunnel folder
            tunnel_fdbs['folder'] = folder

            # maybe create records for tunnel
            if 'records' not in tunnel_fdbs:
                tunnel_fdbs['records'] = {}

            # add entry to records map keyed by mac address
            tunnel_fdbs['records'][mac_address] = \
                {'endpoint': vtep_info['vtep'], 'ip_address': ip_address}

    def update_bigip_fdb(self, bigip, fdb):
        # Update l2 records
        self.add_bigip_fdb(bigip, fdb)

    def remove_bigip_fdb(self, bigip, fdb):
        # Add L2 records for MAC addresses behind tunnel endpoints
        for fdb_operation in \
            [{'network_type': 'vxlan',
              'get_tunnel_folder': self.network_helper.get_tunnel_folder,
              'fdb_method': self.network_helper.delete_fdb_entries},
             {'network_type': 'gre',
              'get_tunnel_folder': self.network_helper.get_tunnel_folder,
              'fdb_method': self.network_helper.delete_fdb_entries}]:
            self._operate_bigip_fdb(bigip, fdb, fdb_operation)

    # Utilities
    def get_network_name(self, bigip, network):
        # This constructs a name for a tunnel or vlan interface
        preserve_network_name = False
        if network['id'] in self.conf.common_network_ids:
            network_name = self.conf.common_network_ids[network['id']]
            preserve_network_name = True
        elif network['provider:network_type'] == 'vlan':
            network_name = self.get_vlan_name(network,
                                              bigip.hostname)
        elif network['provider:network_type'] == 'flat':
            network_name = self.get_vlan_name(network,
                                              bigip.hostname)
        elif network['provider:network_type'] == 'vxlan':
            network_name = _get_tunnel_name(network)
        elif network['provider:network_type'] == 'gre':
            network_name = _get_tunnel_name(network)
        else:
            error_message = 'Unsupported network type %s.' \
                            % network['provider:network_type'] + \
                            ' Cannot setup selfip or snat.'
            LOG.error(error_message)
            raise f5_ex.InvalidNetworkType(error_message)
        return network_name, preserve_network_name

    def _get_network_folder(self, network):
        if self.is_common_network(network):
開發者ID:jputrino,項目名稱:f5-openstack-agent,代碼行數:70,代碼來源:l2_service.py


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