]> 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>
Sun, 14 Jun 2020 08:34:53 +0000 (16:34 +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>
(cherry picked from commit a620587ecfd2fb5351deff0f073c4abe1a222c3d)

qa/tasks/keystone.py

index 5690082eef2a30a7d6f49991bb429fa5ffba0d80..058804fe6b15d937588c547032e2b083c79ff55c 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
@@ -267,25 +270,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]
 
@@ -299,7 +302,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):