]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Split internal.connect() into two subtasks 470/head
authorZack Cerza <zack@redhat.com>
Thu, 23 Apr 2015 16:51:54 +0000 (10:51 -0600)
committerZack Cerza <zack@redhat.com>
Thu, 23 Apr 2015 16:51:54 +0000 (10:51 -0600)
One creates the ctx.cluster object; the other initiates connections

Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/run.py
teuthology/task/internal.py

index 177730193ee529fbbc618009ceeb291264542b74..a938329e896d5116b1065f5d80432a6bdd0d3684 100644 (file)
@@ -181,6 +181,7 @@ def get_initial_tasks(lock, config, machine_type):
     init_tasks.extend([
         {'internal.save_config': None},
         {'internal.check_lock': None},
+        {'internal.add_remotes': None},
         {'internal.connect': None},
         {'internal.push_inventory': None},
         {'internal.serialize_remote_roles': None},
index 26286aa5c6d4559ce40d5579e647e1c37b3058ce..baf70883c63482e3f140b8d0206f79acff7aeda4 100644 (file)
@@ -263,25 +263,22 @@ def timer(ctx, config):
         ctx.summary['duration'] = duration
 
 
-def connect(ctx, config):
+def add_remotes(ctx, config):
     """
-    Open a connection to a remote host.
+    Create a ctx.cluster object populated with remotes mapped to roles
     """
-    log.info('Opening connections...')
     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)
-        log.debug('connecting to %s', t)
         try:
             if ctx.config['sshkeys'] == 'ignore':
                 key = None
         except (AttributeError, KeyError):
             pass
         rem = remote.Remote(name=t, host_key=key, keep_alive=True)
-        rem.connect()
         remotes.append(rem)
     ctx.cluster = cluster.Cluster()
     if 'roles' in ctx.config:
@@ -295,6 +292,16 @@ def connect(ctx, config):
             ctx.cluster.add(rem, rem.name)
 
 
+def connect(ctx, config):
+    """
+    Connect to all remotes in ctx.cluster
+    """
+    log.info('Opening connections...')
+    for rem in ctx.cluster.remotes.iterkeys():
+        log.debug('connecting to %s', rem.name)
+        rem.connect()
+
+
 def push_inventory(ctx, config):
     if not teuth_config.lock_server:
         return