From cd3a61093dfdabaa56684ca41381d7f0ffb5edff Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Thu, 23 Apr 2015 10:51:54 -0600 Subject: [PATCH] Split internal.connect() into two subtasks One creates the ctx.cluster object; the other initiates connections Signed-off-by: Zack Cerza --- teuthology/run.py | 1 + teuthology/task/internal.py | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/teuthology/run.py b/teuthology/run.py index 177730193e..a938329e89 100644 --- a/teuthology/run.py +++ b/teuthology/run.py @@ -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}, diff --git a/teuthology/task/internal.py b/teuthology/task/internal.py index 26286aa5c6..baf70883c6 100644 --- a/teuthology/task/internal.py +++ b/teuthology/task/internal.py @@ -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 -- 2.39.5