]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks/keystone.py: support multiple positional args
authorKefu Chai <kchai@redhat.com>
Thu, 28 May 2020 15:14:35 +0000 (23:14 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 2 Jun 2020 01:48:32 +0000 (09:48 +0800)
it's required when creating endpoint, see
https://docs.openstack.org/python-openstackclient/pike/cli/command-objects/endpoint.html,
where we need to pass <service>, <interface>, and <url>

Signed-off-by: Kefu Chai <kchai@redhat.com>
qa/tasks/keystone.py

index 88abd7b978013d09e29e3dfe01425977a304b0c6..21ff816e280ca01e7c6add394c835cf6f4c0a39e 100644 (file)
@@ -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):