Move get_clients method into misc to avoid duplication.

This commit is contained in:
Josh Durgin 2011-06-20 12:12:11 -07:00
parent 256e6a2bbc
commit 0904ce550d
3 changed files with 11 additions and 22 deletions

View File

@ -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)

View File

@ -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_))

View File

@ -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_))