rados: allow existing pool(s) to be used

Signed-off-by: Sage Weil <sage@inktank.com>
This commit is contained in:
Sage Weil 2013-12-09 16:02:13 -08:00
parent 2266eeb301
commit 6c856a2e94

View File

@ -51,6 +51,31 @@ def task(ctx, config):
snap_remove: 0 snap_remove: 0
runs: 10 runs: 10
- interactive: - interactive:
Optionally, you can provide the pool name to run against:
tasks:
- ceph:
- exec:
client.0:
- ceph osd pool create foo
- rados:
clients: [client.0]
pools: [foo]
...
Alternatively, you can provide a pool prefix:
tasks:
- ceph:
- exec:
client.0:
- ceph osd pool create foo.client.0
- rados:
clients: [client.0]
pool_prefix: foo
...
""" """
log.info('Beginning rados...') log.info('Beginning rados...')
assert isinstance(config, dict), \ assert isinstance(config, dict), \
@ -102,14 +127,21 @@ def task(ctx, config):
for i in range(int(config.get('runs', '1'))): for i in range(int(config.get('runs', '1'))):
log.info("starting run %s out of %s", str(i), config.get('runs', '1')) log.info("starting run %s out of %s", str(i), config.get('runs', '1'))
tests = {} tests = {}
pools = [] existing_pools = config.get('pools', [])
created_pools = []
for role in config.get('clients', clients): for role in config.get('clients', clients):
assert isinstance(role, basestring) assert isinstance(role, basestring)
PREFIX = 'client.' PREFIX = 'client.'
assert role.startswith(PREFIX) assert role.startswith(PREFIX)
id_ = role[len(PREFIX):] id_ = role[len(PREFIX):]
pool = ctx.manager.create_pool_with_unique_name()
pools.append(pool) pool = config.get('pool', None)
if not pool and existing_pools:
pool = existing_pools.pop()
else:
pool = ctx.manager.create_pool_with_unique_name()
created_pools.append(pool)
(remote,) = ctx.cluster.only(role).remotes.iterkeys() (remote,) = ctx.cluster.only(role).remotes.iterkeys()
proc = remote.run( proc = remote.run(
args=["CEPH_CLIENT_ID={id_}".format(id_=id_)] + args + args=["CEPH_CLIENT_ID={id_}".format(id_=id_)] + args +
@ -120,7 +152,8 @@ def task(ctx, config):
) )
tests[id_] = proc tests[id_] = proc
run.wait(tests.itervalues()) run.wait(tests.itervalues())
for pool in pools:
for pool in created_pools:
ctx.manager.remove_pool(pool) ctx.manager.remove_pool(pool)
running = gevent.spawn(thread) running = gevent.spawn(thread)