diff options
author | Zuul <zuul@review.openstack.org> | 2017-12-01 23:12:39 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2017-12-01 23:12:39 +0000 |
commit | 759c1aad394972b3f971e477f6be499564aa12cd (patch) | |
tree | ccad010bf55167241d68aff4143ca9ca64a9944a /neutronclient/osc | |
parent | 7926406568909e930f4c0b6d76dd10e77d4f8063 (diff) | |
parent | 864f4d111f325dd7458ada523fbc3355d3afce2f (diff) | |
download | python-neutronclient-759c1aad394972b3f971e477f6be499564aa12cd.tar.gz |
Merge "SFC plugin: fix port chain set commands"
Diffstat (limited to 'neutronclient/osc')
-rwxr-xr-x | neutronclient/osc/v2/sfc/sfc_port_chain.py | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/neutronclient/osc/v2/sfc/sfc_port_chain.py b/neutronclient/osc/v2/sfc/sfc_port_chain.py index 37b3020..36db079 100755 --- a/neutronclient/osc/v2/sfc/sfc_port_chain.py +++ b/neutronclient/osc/v2/sfc/sfc_port_chain.py @@ -188,37 +188,38 @@ class SetSfcPortChain(command.Command): if parsed_args.no_flow_classifier: attrs['flow_classifiers'] = [] if parsed_args.flow_classifiers: - for fc in parsed_args.flow_classifiers: - added = [client.find_resource( - 'flow_classifier', fc, - cmd_resource='sfc_flow_classifier')['id']] if parsed_args.no_flow_classifier: - existing = [] + fc_list = [] else: - existing = [client.find_resource( + fc_list = client.find_resource( resource, parsed_args.port_chain, - cmd_resource='sfc_port_chain')['flow_classifiers']] - attrs['flow_classifiers'] = sorted(list( - set(existing) | set(added))) + cmd_resource='sfc_port_chain')['flow_classifiers'] + for fc in parsed_args.flow_classifiers: + fc_list.append(client.find_resource( + 'flow_classifier', fc, + cmd_resource='sfc_flow_classifier')['id']) + attrs['flow_classifiers'] = sorted(list(set(fc_list))) if (parsed_args.no_port_pair_group and not parsed_args.port_pair_groups): message = _('At least one --port-pair-group must be specified.') raise exceptions.CommandError(message) if parsed_args.no_port_pair_group and parsed_args.port_pair_groups: + ppg_list = [] for ppg in parsed_args.port_pair_groups: - attrs['port_pair_groups'] = [client.find_resource( + ppg_list.append(client.find_resource( 'port_pair_group', ppg, - cmd_resource='sfc_port_pair_group')['id']] + cmd_resource='sfc_port_pair_group')['id']) + attrs['port_pair_groups'] = sorted(list(set(ppg_list))) if (parsed_args.port_pair_groups and not parsed_args.no_port_pair_group): - existing_ppg = [client.find_resource( + ppg_list = client.find_resource( resource, parsed_args.port_chain, - cmd_resource='sfc_port_chain')['port_pair_groups']] + cmd_resource='sfc_port_chain')['port_pair_groups'] for ppg in parsed_args.port_pair_groups: - existing_ppg.append(client.find_resource( + ppg_list.append(client.find_resource( 'port_pair_group', ppg, cmd_resource='sfc_port_pair_group')['id']) - attrs['port_pair_groups'] = sorted(list(set(existing_ppg))) + attrs['port_pair_groups'] = sorted(list(set(ppg_list))) body = {resource: attrs} try: client.update_sfc_port_chain(pc_id, body) |