]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/keystone: use bindep to discover keystone's dependencies
authorCasey Bodley <cbodley@redhat.com>
Thu, 5 Sep 2019 15:09:26 +0000 (11:09 -0400)
committerCasey Bodley <cbodley@redhat.com>
Fri, 13 Sep 2019 19:04:43 +0000 (15:04 -0400)
downloads the keystone repository first, because we need
keystone/bindep.txt to discover the binary dependencies

Signed-off-by: Casey Bodley <cbodley@redhat.com>
qa/tasks/keystone.py

index 08905216cb488a47905cae29287f776ede2ff854..116a20bf21fb61fdee1c35a3b884645d283ce474 100644 (file)
@@ -4,6 +4,7 @@ Deploy and configure Keystone for Teuthology
 import argparse
 import contextlib
 import logging
+from cStringIO import StringIO
 
 from teuthology import misc as teuthology
 from teuthology import contextutil
@@ -16,42 +17,13 @@ from teuthology.exceptions import ConfigError
 log = logging.getLogger(__name__)
 
 
-@contextlib.contextmanager
-def install_packages(ctx, config):
-    """
-    Download the packaged dependencies of Keystone.
-    Remove install packages upon exit.
-
-    The context passed in should be identical to the context
-    passed in to the main task.
-    """
-    assert isinstance(config, dict)
-    log.info('Installing packages for Keystone...')
-
-    deps = {
-       'deb': [ 'libffi-dev', 'libssl-dev', 'libldap2-dev', 'libsasl2-dev' ],
-       'rpm': [ 'libffi-devel', 'openssl-devel' ],
-    }
-    for (client, _) in config.items():
-        (remote,) = ctx.cluster.only(client).remotes.iterkeys()
-        for dep in deps[remote.os.package_type]:
-            install_package(dep, remote)
-    try:
-        yield
-    finally:
-        log.info('Removing packaged dependencies of Keystone...')
-
-        for (client, _) in config.items():
-            (remote,) = ctx.cluster.only(client).remotes.iterkeys()
-            for dep in deps[remote.os.package_type]:
-                remove_package(dep, remote)
-
 def get_keystone_dir(ctx):
     return '{tdir}/keystone'.format(tdir=teuthology.get_testdir(ctx))
 
-def run_in_keystone_dir(ctx, client, args):
-    ctx.cluster.only(client).run(
+def run_in_keystone_dir(ctx, client, args, **kwargs):
+    return ctx.cluster.only(client).run(
         args=[ 'cd', get_keystone_dir(ctx), run.Raw('&&'), ] + args,
+        **kwargs
     )
 
 def run_in_keystone_venv(ctx, client, args):
@@ -114,6 +86,36 @@ def download(ctx, config):
                 args=[ 'rm', '-rf', keystonedir ],
             )
 
+@contextlib.contextmanager
+def install_packages(ctx, config):
+    """
+    Download the packaged dependencies of Keystone.
+    Remove install packages upon exit.
+
+    The context passed in should be identical to the context
+    passed in to the main task.
+    """
+    assert isinstance(config, dict)
+    log.info('Installing packages for Keystone...')
+
+    packages = {}
+    for (client, _) in config.items():
+        # use bindep to read which dependencies we need from keystone/bindep.txt
+        r = run_in_keystone_dir(ctx, client, ['bindep', '-c'], stdout=StringIO())
+        packages[client] = r.stdout.getvalue().splitlines()
+        (remote,) = ctx.cluster.only(client).remotes.iterkeys()
+        for dep in packages[client]:
+            install_package(dep, remote)
+    try:
+        yield
+    finally:
+        log.info('Removing packaged dependencies of Keystone...')
+
+        for (client, _) in config.items():
+            (remote,) = ctx.cluster.only(client).remotes.iterkeys()
+            for dep in packages[client]:
+                remove_package(dep, remote)
+
 @contextlib.contextmanager
 def setup_venv(ctx, config):
     """
@@ -387,8 +389,8 @@ def task(ctx, config):
     ctx.keystone.admin_endpoints = assign_ports(ctx, config, 35357)
 
     with contextutil.nested(
-        lambda: install_packages(ctx=ctx, config=config),
         lambda: download(ctx=ctx, config=config),
+        lambda: install_packages(ctx=ctx, config=config),
         lambda: setup_venv(ctx=ctx, config=config),
         lambda: configure_instance(ctx=ctx, config=config),
         lambda: run_keystone(ctx=ctx, config=config),