]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks/vip: add 'vip.exec' task
authorSage Weil <sage@newdream.net>
Fri, 30 Apr 2021 15:41:23 +0000 (11:41 -0400)
committerSage Weil <sage@newdream.net>
Wed, 19 May 2021 12:43:14 +0000 (08:43 -0400)
Signed-off-by: Sage Weil <sage@newdream.net>
qa/tasks/vip.py

index d6d794ef0e9649741a1c6dad02ee1a4498f5d76f..d4d27b85e49529b3dba95d5d7372ac24fd76a54f 100644 (file)
@@ -3,6 +3,7 @@ import ipaddress
 import logging
 import re
 
+from teuthology import misc as teuthology
 from teuthology.config import config as teuth_config
 
 log = logging.getLogger(__name__)
@@ -34,6 +35,38 @@ def echo(ctx, config):
         log.info(subst_vip(ctx, config))
 
 
+def exec(ctx, config):
+    """
+    This is similar to the standard 'exec' task, but does the VIP substitutions.
+    """
+    assert isinstance(config, dict), "task exec got invalid config"
+
+    testdir = teuthology.get_testdir(ctx)
+
+    if 'all-roles' in config and len(config) == 1:
+        a = config['all-roles']
+        roles = teuthology.all_roles(ctx.cluster)
+        config = dict((id_, a) for id_ in roles if not id_.startswith('host.'))
+    elif 'all-hosts' in config and len(config) == 1:
+        a = config['all-hosts']
+        roles = teuthology.all_roles(ctx.cluster)
+        config = dict((id_, a) for id_ in roles if id_.startswith('host.'))
+
+    for role, ls in config.items():
+        (remote,) = ctx.cluster.only(role).remotes.keys()
+        log.info('Running commands on role %s host %s', role, remote.name)
+        for c in ls:
+            c.replace('$TESTDIR', testdir)
+            remote.run(
+                args=[
+                    'sudo',
+                    'TESTDIR={tdir}'.format(tdir=testdir),
+                    'bash',
+                    '-c',
+                    subst_vip(ctx, c)],
+                )
+
+
 def map_vips(mip, count):
     for mapping in teuth_config.get('vip', []):
         mnet = ipaddress.ip_network(mapping['machine_subnet'])