From 0904ce550d2803cea5436a85cd2e2f1c8dc2af1a Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Mon, 20 Jun 2011 12:12:11 -0700 Subject: [PATCH] Move get_clients method into misc to avoid duplication. --- teuthology/misc.py | 9 +++++++++ teuthology/task/cfuse.py | 12 +----------- teuthology/task/kclient.py | 12 +----------- 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/teuthology/misc.py b/teuthology/misc.py index 59e3f9afb26..974819dca42 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -283,3 +283,12 @@ def write_secret_file(remote, role, filename): filename, ], ) + +def get_clients(ctx, roles): + for role in roles: + assert isinstance(role, basestring) + PREFIX = 'client.' + assert role.startswith(PREFIX) + id_ = role[len(PREFIX):] + (remote,) = ctx.cluster.only(role).remotes.iterkeys() + yield (id_, remote) diff --git a/teuthology/task/cfuse.py b/teuthology/task/cfuse.py index 988fca18da6..fec223e1075 100644 --- a/teuthology/task/cfuse.py +++ b/teuthology/task/cfuse.py @@ -7,16 +7,6 @@ from orchestra import run log = logging.getLogger(__name__) -def get_clients(ctx, roles): - for role in roles: - assert isinstance(role, basestring) - PREFIX = 'client.' - assert role.startswith(PREFIX) - id_ = role[len(PREFIX):] - (remote,) = ctx.cluster.only(role).remotes.iterkeys() - yield (id_, remote) - - @contextlib.contextmanager def task(ctx, config): """ @@ -50,7 +40,7 @@ def task(ctx, config): if config is None: config = ['client.{id}'.format(id=id_) for id_ in teuthology.all_roles_of_type(ctx.cluster, 'client')] - clients = list(get_clients(ctx=ctx, roles=config)) + clients = list(teuthology.get_clients(ctx=ctx, roles=config)) for id_, remote in clients: mnt = os.path.join('/tmp/cephtest', 'mnt.{id}'.format(id=id_)) diff --git a/teuthology/task/kclient.py b/teuthology/task/kclient.py index 806c2bfe6b1..de404407319 100644 --- a/teuthology/task/kclient.py +++ b/teuthology/task/kclient.py @@ -6,16 +6,6 @@ from teuthology import misc as teuthology log = logging.getLogger(__name__) -def get_clients(ctx, roles): - for role in roles: - assert isinstance(role, basestring) - PREFIX = 'client.' - assert role.startswith(PREFIX) - id_ = role[len(PREFIX):] - (remote,) = ctx.cluster.only(role).remotes.iterkeys() - yield (id_, remote) - - @contextlib.contextmanager def task(ctx, config): """ @@ -48,7 +38,7 @@ def task(ctx, config): if config is None: config = ['client.{id}'.format(id=id_) for id_ in teuthology.all_roles_of_type(ctx.cluster, 'client')] - clients = list(get_clients(ctx=ctx, roles=config)) + clients = list(teuthology.get_clients(ctx=ctx, roles=config)) for id_, remote in clients: log.debug('Mounting client client.{id}...'.format(id=id_))