Merge "Fix allowed address pair row unique ID" into stable/2024.1

This commit is contained in:
Zuul 2024-11-11 17:24:41 +00:00 committed by Gerrit Code Review
commit 5dfb79b95f
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)