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
This commit is contained in:
chenyaguang 2018-04-18 15:45:23 +08:00
parent 2cf52672b7
commit 2bff68649b
2 changed files with 9 additions and 9 deletions
neutronclient
osc/v2/sfc
tests/unit/osc/v2/sfc

@ -188,9 +188,9 @@ class SetSfcPortPairGroup(command.Command):
if parsed_args.no_port_pair: if parsed_args.no_port_pair:
existing = [] existing = []
else: else:
existing = [client.find_resource( existing = client.find_resource(
resource, parsed_args.port_pair_group, 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))) attrs['port_pairs'] = sorted(list(set(existing) | set(added)))
body = {resource: attrs} body = {resource: attrs}
try: try:
@ -250,12 +250,12 @@ class UnsetSfcPortPairGroup(command.Command):
ppg_id = _get_id(client, parsed_args.port_pair_group, resource) ppg_id = _get_id(client, parsed_args.port_pair_group, resource)
attrs = {} attrs = {}
if parsed_args.port_pairs: if parsed_args.port_pairs:
existing = [client.find_resource( existing = client.find_resource(
resource, parsed_args.port_pair_group, resource, parsed_args.port_pair_group,
cmd_resource='sfc_port_pair_group')['port_pairs']] cmd_resource='sfc_port_pair_group')['port_pairs']
for pp in parsed_args.port_pairs: removed = [client.find_resource('port_pair', pp,
removed = [client.find_resource( cmd_resource='sfc_port_pair')['id']
'port_pair', pp, cmd_resource='sfc_port_pair')['id']] for pp in parsed_args.port_pairs]
attrs['port_pairs'] = list(set(existing) - set(removed)) attrs['port_pairs'] = list(set(existing) - set(removed))
if parsed_args.all_port_pair: if parsed_args.all_port_pair:
attrs['port_pairs'] = [] attrs['port_pairs'] = []

@ -293,7 +293,7 @@ class TestSetSfcPortPairGroup(fakes.TestNeutronClientOSCV2):
if self.neutronclient.find_resource.call_count == 3: if self.neutronclient.find_resource.call_count == 3:
self.neutronclient.find_resource.assert_called_with( self.neutronclient.find_resource.assert_called_with(
self.res, target, cmd_resource='sfc_port_pair_group') 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 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: if self.neutronclient.find_resource.call_count == 1:
self.neutronclient.find_resource.assert_called_with( self.neutronclient.find_resource.assert_called_with(
self.res, target, cmd_resource='sfc_port_pair_group') 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: if self.neutronclient.find_resource.call_count == 2:
self.neutronclient.find_resource.assert_called_with( self.neutronclient.find_resource.assert_called_with(