Skip to content

Commit 30f8299

Browse files
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 <[email protected]>
1 parent 0b61b1c commit 30f8299

File tree

1 file changed

+0
-60
lines changed

1 file changed

+0
-60
lines changed

qa/tasks/vip.py

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3,72 +3,12 @@
33
import logging
44
import re
55

6-
from teuthology import misc as teuthology
76
from teuthology.config import config as teuth_config
87
from teuthology.exceptions import ConfigError
98

109
log = logging.getLogger(__name__)
1110

1211

13-
def subst_vip(ctx, cmd):
14-
p = re.compile(r'({{VIP(\d+)}})')
15-
for m in p.findall(cmd):
16-
n = int(m[1])
17-
if n >= len(ctx.vip["vips"]):
18-
log.warning(f'no VIP{n} (we have {len(ctx.vip["vips"])})')
19-
else:
20-
cmd = cmd.replace(m[0], str(ctx.vip["vips"][n]))
21-
22-
if '{{VIPPREFIXLEN}}' in cmd:
23-
cmd = cmd.replace('{{VIPPREFIXLEN}}', str(ctx.vip["vnet"].prefixlen))
24-
25-
if '{{VIPSUBNET}}' in cmd:
26-
cmd = cmd.replace('{{VIPSUBNET}}', str(ctx.vip["vnet"].network_address))
27-
28-
return cmd
29-
30-
31-
def echo(ctx, config):
32-
"""
33-
This is mostly for debugging
34-
"""
35-
for remote in ctx.cluster.remotes.keys():
36-
log.info(subst_vip(ctx, config))
37-
38-
39-
def exec(ctx, config):
40-
"""
41-
This is similar to the standard 'exec' task, but does the VIP substitutions.
42-
"""
43-
assert isinstance(config, dict), "task exec got invalid config"
44-
45-
testdir = teuthology.get_testdir(ctx)
46-
47-
if 'all-roles' in config and len(config) == 1:
48-
a = config['all-roles']
49-
roles = teuthology.all_roles(ctx.cluster)
50-
config = dict((id_, a) for id_ in roles if not id_.startswith('host.'))
51-
elif 'all-hosts' in config and len(config) == 1:
52-
a = config['all-hosts']
53-
roles = teuthology.all_roles(ctx.cluster)
54-
config = dict((id_, a) for id_ in roles if id_.startswith('host.'))
55-
56-
for role, ls in config.items():
57-
(remote,) = ctx.cluster.only(role).remotes.keys()
58-
log.info('Running commands on role %s host %s', role, remote.name)
59-
for c in ls:
60-
c.replace('$TESTDIR', testdir)
61-
remote.run(
62-
args=[
63-
'sudo',
64-
'TESTDIR={tdir}'.format(tdir=testdir),
65-
'bash',
66-
'-ex',
67-
'-c',
68-
subst_vip(ctx, c)],
69-
)
70-
71-
7212
def _map_vips(mip, count):
7313
vip_entries = teuth_config.get('vip', [])
7414
if not vip_entries:

0 commit comments

Comments
 (0)