From e975f2dfd175128d67cc6bdc67ded7513bb4642e Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Fri, 17 Mar 2017 14:27:51 -0600 Subject: [PATCH] add_remotes: Correctly map remotes to roles We used to use the 'targets' object to make remotes to roles. This worked fine before multi-OS locking, but broke down because of the unordered nature of dicts. Signed-off-by: Zack Cerza --- teuthology/task/internal/__init__.py | 32 +++++++++++----------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/teuthology/task/internal/__init__.py b/teuthology/task/internal/__init__.py index 2e16423ade..c19fcd6eac 100644 --- a/teuthology/task/internal/__init__.py +++ b/teuthology/task/internal/__init__.py @@ -137,30 +137,24 @@ def add_remotes(ctx, config): """ ctx.cluster = cluster.Cluster() # Allow jobs to run without using nodes, for self-testing - if 'roles' not in ctx.config and 'targets' not in ctx.config: + if 'nodes' not in ctx.config and 'targets' not in ctx.config: return - remotes = [] - machs = [] - for name in ctx.config['targets'].iterkeys(): - machs.append(name) - for t, key in ctx.config['targets'].iteritems(): - t = misc.canonicalize_hostname(t) - try: - if ctx.config['sshkeys'] == 'ignore': - key = None - except (AttributeError, KeyError): - pass - rem = remote.Remote(name=t, host_key=key, keep_alive=True) - remotes.append(rem) - if 'roles' in ctx.config: - for rem, roles in zip(remotes, ctx.config['roles']): + for node_conf in ctx.config['nodes']: + remotes = [] + for name, key in node_conf['targets'].items(): + name = misc.canonicalize_hostname(name) + try: + if ctx.config['sshkeys'] == 'ignore': + key = None + except (AttributeError, KeyError): + pass + rem = remote.Remote(name=name, host_key=key, keep_alive=True) + remotes.append(rem) + roles = node_conf['roles'] assert all(isinstance(role, str) for role in roles), \ "Roles in config must be strings: %r" % roles ctx.cluster.add(rem, roles) log.info('roles: %s - %s' % (rem, roles)) - else: - for rem in remotes: - ctx.cluster.add(rem, rem.name) def connect(ctx, config): -- 2.39.5