Fix allowed address pair row unique ID

This fixes so that the ID for the allowed
address pair rows is unique if it's the
same ip_address range but different
mac_address.

Closes-Bug: 2034035
Change-Id: I49e84568ef7cfbc1547258305f2101bffe5bdea5
(cherry picked from commit 9c75ebba01cc58c77a7114226ebaeedbe033962a)
This commit is contained in:
Tobias Urdin 2023-09-04 13:03:15 +00:00 committed by Tobias Urdin
parent dcaf0cc51f
commit 5a7a49923e
3 changed files with 6 additions and 5 deletions

View File

@ -213,7 +213,8 @@ class PortAllowedAddressPair(NeutronAPIDictWrapper):
def __init__(self, addr_pair):
super().__init__(addr_pair)
# Horizon references id property for table operations
self.id = addr_pair['ip_address']
mac_addr = addr_pair['mac_address'].replace(':', '-')
self.id = addr_pair['ip_address'] + ":" + mac_addr
class Router(NeutronAPIDictWrapper):

View File

@ -81,13 +81,13 @@ class DeleteAllowedAddressPair(tables.DeleteAction):
return policy_target
def delete(self, request, ip_address):
def delete(self, request, obj_id):
try:
port_id = self.table.kwargs['port_id']
port = api.neutron.port_get(request, port_id)
pairs = port.get('allowed_address_pairs', [])
pairs = [pair for pair in pairs
if pair['ip_address'] != ip_address]
if pair.id != obj_id]
pairs = [pair.to_dict() for pair in pairs]
api.neutron.port_update(request, port_id,
allowed_address_pairs=pairs)

View File

@ -486,8 +486,8 @@ class NetworkPortTests(test.TestCase):
self._stub_is_extension_supported({'mac-learning': False,
'allowed-address-pairs': True})
pair_ip = pair['ip_address']
form_data = {'action': 'allowed_address_pairs__delete__%s' % pair_ip}
id = pair['ip_address'] + ":" + pair['mac_address'].replace(':', '-')
form_data = {'action': 'allowed_address_pairs__delete__%s' % id}
url = reverse(detail_path, args=[pre_port.id])
res = self.client.post(url, form_data)