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

View File

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