From 30f82992a2a53afb6b9834bf0157b42cf6e83f05 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Wed, 6 Mar 2024 12:13:26 -0500 Subject: [PATCH] qa/tasks: remove templating functions from vip.py Now that all the generic templating can be done by template.py, we can remove the legacy functions from vip.py Signed-off-by: John Mulligan --- qa/tasks/vip.py | 60 ------------------------------------------------- 1 file changed, 60 deletions(-) diff --git a/qa/tasks/vip.py b/qa/tasks/vip.py index d907fbbd23482..78837a39ee494 100644 --- a/qa/tasks/vip.py +++ b/qa/tasks/vip.py @@ -3,72 +3,12 @@ import ipaddress import logging import re -from teuthology import misc as teuthology from teuthology.config import config as teuth_config from teuthology.exceptions import ConfigError log = logging.getLogger(__name__) -def subst_vip(ctx, cmd): - p = re.compile(r'({{VIP(\d+)}})') - for m in p.findall(cmd): - n = int(m[1]) - if n >= len(ctx.vip["vips"]): - log.warning(f'no VIP{n} (we have {len(ctx.vip["vips"])})') - else: - cmd = cmd.replace(m[0], str(ctx.vip["vips"][n])) - - if '{{VIPPREFIXLEN}}' in cmd: - cmd = cmd.replace('{{VIPPREFIXLEN}}', str(ctx.vip["vnet"].prefixlen)) - - if '{{VIPSUBNET}}' in cmd: - cmd = cmd.replace('{{VIPSUBNET}}', str(ctx.vip["vnet"].network_address)) - - return cmd - - -def echo(ctx, config): - """ - This is mostly for debugging - """ - for remote in ctx.cluster.remotes.keys(): - 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', - '-ex', - '-c', - subst_vip(ctx, c)], - ) - - def _map_vips(mip, count): vip_entries = teuth_config.get('vip', []) if not vip_entries: -- 2.39.5