From: Kefu Chai Date: Thu, 28 May 2020 15:14:35 +0000 (+0800) Subject: qa/tasks/keystone.py: support multiple positional args X-Git-Tag: v16.1.0~2190^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a620587ecfd2fb5351deff0f073c4abe1a222c3d;p=ceph.git qa/tasks/keystone.py: support multiple positional args it's required when creating endpoint, see https://docs.openstack.org/python-openstackclient/pike/cli/command-objects/endpoint.html, where we need to pass , , and Signed-off-by: Kefu Chai --- diff --git a/qa/tasks/keystone.py b/qa/tasks/keystone.py index 88abd7b9780..21ff816e280 100644 --- a/qa/tasks/keystone.py +++ b/qa/tasks/keystone.py @@ -5,6 +5,9 @@ import argparse import contextlib import logging +# still need this for python3.6 +from collections import OrderedDict + from teuthology import misc as teuthology from teuthology import contextutil from teuthology.orchestra import run @@ -260,25 +263,25 @@ def run_keystone(ctx, config): cluster_name).stop() -def dict_to_args(special, items): +def dict_to_args(specials, items): """ Transform [(key1, val1), (special, val_special), (key3, val3) ] into: [ '--key1', 'val1', '--key3', 'val3', 'val_special' ] """ - args=[] + args = [] + special_vals = OrderedDict((k, '') for k in specials.split(',')) for (k, v) in items: - if k == special: - special_val = v + if k in special_vals: + special_vals[k] = v else: args.append('--{k}'.format(k=k)) args.append(v) - if special_val: - args.append(special_val) + args.extend(arg for arg in special_vals.values() if arg) return args -def run_section_cmds(ctx, cclient, section_cmd, special, +def run_section_cmds(ctx, cclient, section_cmd, specials, section_config_list): admin_host, admin_port = ctx.keystone.admin_endpoints[cclient] @@ -292,7 +295,7 @@ def run_section_cmds(ctx, cclient, section_cmd, special, for section_item in section_config_list: run_in_keystone_venv(ctx, cclient, [ 'openstack' ] + section_cmd.split() + - dict_to_args(special, auth_section + list(section_item.items())) + + dict_to_args(specials, auth_section + list(section_item.items())) + [ '--debug' ]) def create_endpoint(ctx, cclient, service, url, adminurl=None):