diff --git a/openstack_dashboard/api/neutron.py b/openstack_dashboard/api/neutron.py index 3df0e8a8ca..2ad1ca56b4 100644 --- a/openstack_dashboard/api/neutron.py +++ b/openstack_dashboard/api/neutron.py @@ -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): diff --git a/openstack_dashboard/dashboards/project/networks/ports/extensions/allowed_address_pairs/tables.py b/openstack_dashboard/dashboards/project/networks/ports/extensions/allowed_address_pairs/tables.py index 85ed3ee9b5..7f3e139e8f 100644 --- a/openstack_dashboard/dashboards/project/networks/ports/extensions/allowed_address_pairs/tables.py +++ b/openstack_dashboard/dashboards/project/networks/ports/extensions/allowed_address_pairs/tables.py @@ -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) diff --git a/openstack_dashboard/dashboards/project/networks/ports/tests.py b/openstack_dashboard/dashboards/project/networks/ports/tests.py index 7fed538d03..f645744e7e 100644 --- a/openstack_dashboard/dashboards/project/networks/ports/tests.py +++ b/openstack_dashboard/dashboards/project/networks/ports/tests.py @@ -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)