From a9f93eb6ca38228e49367c90327cb44feef0e4c9 Mon Sep 17 00:00:00 2001 From: Ivar Lazzaro Date: Fri, 1 Jun 2018 10:43:26 -0700 Subject: [PATCH] [SFC][AIM] Safe access to keys in the port pair groups extension Change-Id: I3842998b719fc348c5cc42e33b525a4da994b863 --- .../neutron/services/sfc/aim/sfc_driver.py | 2 +- .../unit/services/sfc/test_aim_sfc_driver.py | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/gbpservice/neutron/services/sfc/aim/sfc_driver.py b/gbpservice/neutron/services/sfc/aim/sfc_driver.py index 14fd8552f..93162e9d5 100644 --- a/gbpservice/neutron/services/sfc/aim/sfc_driver.py +++ b/gbpservice/neutron/services/sfc/aim/sfc_driver.py @@ -714,7 +714,7 @@ class SfcAIMDriver(SfcAIMDriverBase): param_curr = context.current['port_pair_group_parameters'] param_orig = context.original['port_pair_group_parameters'] return (any(context.current[a] != context.original[a] for a in attrs) - or any(param_curr[x] != param_orig[x] for x in + or any(param_curr.get(x) != param_orig.get(x) for x in sfc_cts.AIM_PPG_PARAMS.keys())) def _should_regenerate_pc(self, context): diff --git a/gbpservice/neutron/tests/unit/services/sfc/test_aim_sfc_driver.py b/gbpservice/neutron/tests/unit/services/sfc/test_aim_sfc_driver.py index 1448535fc..b11a01bc1 100644 --- a/gbpservice/neutron/tests/unit/services/sfc/test_aim_sfc_driver.py +++ b/gbpservice/neutron/tests/unit/services/sfc/test_aim_sfc_driver.py @@ -723,6 +723,28 @@ class TestPortPairGroup(TestAIMServiceFunctionChainingBase): ppg2['id'], port_pairs=[pp3['id'], pp1['id']], expected_res_status=500) + def test_ppg_update(self): + # Correct creation + net1 = self._make_network(self.fmt, 'net1', True) + self._make_subnet(self.fmt, net1, '192.168.0.1', '192.168.0.0/24') + net2 = self._make_network(self.fmt, 'net2', True) + self._make_subnet(self.fmt, net2, '192.168.1.1', '192.168.1.0/24') + + # Service 1 + p11 = self._make_port(self.fmt, net1['network']['id'])['port'] + self._bind_port_to_host(p11['id'], 'h1') + p12 = self._make_port(self.fmt, net2['network']['id'])['port'] + self._bind_port_to_host(p12['id'], 'h1') + pp1 = self.create_port_pair(ingress=p11['id'], egress=p12['id'], + expected_res_status=201)['port_pair'] + # This goes through + ppg1 = self.create_port_pair_group( + port_pairs=[pp1['id']], + expected_res_status=201)['port_pair_group'] + # Same ID update works + self.update_port_pair_group(ppg1['id'], port_pairs=[pp1['id']], + expected_res_status=200) + def test_healthcheck_group(self): # Correct creation net1 = self._make_network(self.fmt, 'net1', True)