Merge "Set or unset port pair group failed"

This commit is contained in:
Zuul 2018-04-26 08:12:04 +00:00 committed by Gerrit Code Review
commit 873db8ccec
2 changed files with 9 additions and 9 deletions

View File

@ -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'] = []

View File

@ -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(