From 83b6678e79904793bf31e82bbecad7bf16c1b2b5 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 4 Aug 2011 15:01:49 -0700 Subject: [PATCH] fix get_clients Only return the clients that are listed (not _all_ clients). There might be a combination of cfuse and kclient (or other) clients here! --- teuthology/misc.py | 19 +++++++++++-------- teuthology/task/ceph.py | 2 ++ teuthology/task/cfuse.py | 2 +- teuthology/task/kclient.py | 2 +- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/teuthology/misc.py b/teuthology/misc.py index ccf79727f6..a7184b79e5 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -294,14 +294,17 @@ def write_secret_file(remote, role, 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) +# return id, remote dictionary for the clients listed in config +def get_clients(ctx, config): + clients = [] + crem = ctx.cluster.only(is_type('client')) + for client in config: + assert client.startswith('client.') + id = client[len('client.'):] + for remote, roles in crem.remotes.iteritems(): + if client in roles: + clients.append((id, remote)) + return clients def get_user(): return getpass.getuser() + '@' + socket.gethostname() diff --git a/teuthology/task/ceph.py b/teuthology/task/ceph.py index ea6ceea289..b8cb60a8e4 100644 --- a/teuthology/task/ceph.py +++ b/teuthology/task/ceph.py @@ -391,9 +391,11 @@ def cluster(ctx, config): ) log.info('Setting up client nodes...') + clients = ctx.cluster.only(teuthology.is_type('client')) for remote, roles_for_host in clients.remotes.iteritems(): for id_ in teuthology.roles_of_type(roles_for_host, 'client'): + log.info('id %s remote %s' % (id_, remote)) remote.run( args=[ '/tmp/cephtest/enable-coredump', diff --git a/teuthology/task/cfuse.py b/teuthology/task/cfuse.py index fec223e107..00298e1d37 100644 --- a/teuthology/task/cfuse.py +++ b/teuthology/task/cfuse.py @@ -40,8 +40,8 @@ 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(teuthology.get_clients(ctx=ctx, roles=config)) + clients = teuthology.get_clients(ctx=ctx, config=config) for id_, remote in clients: mnt = os.path.join('/tmp/cephtest', 'mnt.{id}'.format(id=id_)) remote.run( diff --git a/teuthology/task/kclient.py b/teuthology/task/kclient.py index 38f13b4531..6257c6c168 100644 --- a/teuthology/task/kclient.py +++ b/teuthology/task/kclient.py @@ -38,8 +38,8 @@ 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(teuthology.get_clients(ctx=ctx, roles=config)) + clients = teuthology.get_clients(ctx=ctx, config=config) for id_, remote in clients: log.debug('Mounting client client.{id}...'.format(id=id_)) remotes_and_roles = ctx.cluster.remotes.items() -- 2.39.5