From 2bff68649b4adcfb4a1b8bede5b0e312c846b4db Mon Sep 17 00:00:00 2001 From: chenyaguang Date: Wed, 18 Apr 2018 15:45:23 +0800 Subject: [PATCH] Set or unset port pair group failed Set or unset port pair for port pair group failed because the type of 'existing' is wrong Change-Id: I198e745fccff76184d9813805d1c1915aff5a273 Closes-Bug: #1762884 --- neutronclient/osc/v2/sfc/sfc_port_pair_group.py | 14 +++++++------- .../tests/unit/osc/v2/sfc/test_port_pair_group.py | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/neutronclient/osc/v2/sfc/sfc_port_pair_group.py b/neutronclient/osc/v2/sfc/sfc_port_pair_group.py index 6053c9a4f..8e7fadd26 100755 --- a/neutronclient/osc/v2/sfc/sfc_port_pair_group.py +++ b/neutronclient/osc/v2/sfc/sfc_port_pair_group.py @@ -188,9 +188,9 @@ class SetSfcPortPairGroup(command.Command): if parsed_args.no_port_pair: existing = [] else: - existing = [client.find_resource( + existing = client.find_resource( resource, parsed_args.port_pair_group, - cmd_resource='sfc_port_pair_group')['port_pairs']] + cmd_resource='sfc_port_pair_group')['port_pairs'] attrs['port_pairs'] = sorted(list(set(existing) | set(added))) body = {resource: attrs} try: @@ -250,12 +250,12 @@ class UnsetSfcPortPairGroup(command.Command): ppg_id = _get_id(client, parsed_args.port_pair_group, resource) attrs = {} if parsed_args.port_pairs: - existing = [client.find_resource( + existing = client.find_resource( resource, parsed_args.port_pair_group, - cmd_resource='sfc_port_pair_group')['port_pairs']] - for pp in parsed_args.port_pairs: - removed = [client.find_resource( - 'port_pair', pp, cmd_resource='sfc_port_pair')['id']] + cmd_resource='sfc_port_pair_group')['port_pairs'] + removed = [client.find_resource('port_pair', pp, + cmd_resource='sfc_port_pair')['id'] + for pp in parsed_args.port_pairs] attrs['port_pairs'] = list(set(existing) - set(removed)) if parsed_args.all_port_pair: attrs['port_pairs'] = [] diff --git a/neutronclient/tests/unit/osc/v2/sfc/test_port_pair_group.py b/neutronclient/tests/unit/osc/v2/sfc/test_port_pair_group.py index c59e96194..48cee1ed9 100755 --- a/neutronclient/tests/unit/osc/v2/sfc/test_port_pair_group.py +++ b/neutronclient/tests/unit/osc/v2/sfc/test_port_pair_group.py @@ -293,7 +293,7 @@ class TestSetSfcPortPairGroup(fakes.TestNeutronClientOSCV2): if self.neutronclient.find_resource.call_count == 3: self.neutronclient.find_resource.assert_called_with( self.res, target, cmd_resource='sfc_port_pair_group') - return {'port_pairs': self.ppg_pp} + return {'port_pairs': [self.ppg_pp]} self.neutronclient.find_resource.side_effect = _mock_port_pair_group @@ -423,7 +423,7 @@ class TestUnsetSfcPortPairGroup(fakes.TestNeutronClientOSCV2): if self.neutronclient.find_resource.call_count == 1: self.neutronclient.find_resource.assert_called_with( self.res, target, cmd_resource='sfc_port_pair_group') - return {'port_pairs': self.ppg_pp} + return {'port_pairs': [self.ppg_pp]} if self.neutronclient.find_resource.call_count == 2: self.neutronclient.find_resource.assert_called_with(