]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
add_remotes: Correctly map remotes to roles wip-flex-locking 1051/head
authorZack Cerza <zack@redhat.com>
Fri, 17 Mar 2017 20:27:51 +0000 (14:27 -0600)
committerZack Cerza <zack@redhat.com>
Tue, 21 Mar 2017 19:38:57 +0000 (13:38 -0600)
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 <zack@redhat.com>
teuthology/task/internal/__init__.py

index 2e16423adea2f3deee6b9968be322bd54733215d..c19fcd6eacb835b4990341d95515f39261c7f09c 100644 (file)
@@ -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):