MCPcopy Create free account
hub / github.com/ceph/ceph / task

Function task

qa/tasks/populate_rbd_pool.py:10–82  ·  view source on GitHub ↗

Populate pools with prefix with rbd images at snaps The config could be as follows:: populate_rbd_pool: client: pool_prefix: foo num_pools: 5 num_images: 10 num_snaps:

(ctx, config)

Source from the content-addressed store, hash-verified

8
9@contextlib.contextmanager
10def task(ctx, config):
11 """
12 Populate <num_pools> pools with prefix <pool_prefix> with <num_images>
13 rbd images at <num_snaps> snaps
14
15 The config could be as follows::
16
17 populate_rbd_pool:
18 client: <client>
19 pool_prefix: foo
20 num_pools: 5
21 num_images: 10
22 num_snaps: 3
23 image_size: 10737418240
24 """
25 if config is None:
26 config = {}
27 client = config.get("client", "client.0")
28 pool_prefix = config.get("pool_prefix", "foo")
29 num_pools = config.get("num_pools", 2)
30 num_images = config.get("num_images", 20)
31 num_snaps = config.get("num_snaps", 4)
32 image_size = config.get("image_size", 100)
33 write_size = config.get("write_size", 1024*1024)
34 write_threads = config.get("write_threads", 10)
35 write_total_per_snap = config.get("write_total_per_snap", 1024*1024*30)
36
37 (remote,) = ctx.cluster.only(client).remotes.keys()
38
39 for poolid in range(num_pools):
40 poolname = "%s-%s" % (pool_prefix, str(poolid))
41 log.info("Creating pool %s" % (poolname,))
42 ctx.managers['ceph'].create_pool(poolname)
43 for imageid in range(num_images):
44 imagename = "rbd-%s" % (str(imageid),)
45 log.info("Creating imagename %s" % (imagename,))
46 remote.run(
47 args = [
48 "rbd",
49 "create",
50 imagename,
51 "--image-format", "1",
52 "--size", str(image_size),
53 "--pool", str(poolname)])
54 def bench_run():
55 remote.run(
56 args = [
57 "rbd",
58 "bench-write",
59 imagename,
60 "--pool", poolname,
61 "--io-size", str(write_size),
62 "--io-threads", str(write_threads),
63 "--io-total", str(write_total_per_snap),
64 "--io-pattern", "rand"])
65 log.info("imagename %s first bench" % (imagename,))
66 bench_run()
67 for snapid in range(num_snaps):

Callers

nothing calls this directly

Calls 7

bench_runFunction · 0.85
onlyMethod · 0.80
getMethod · 0.45
keysMethod · 0.45
infoMethod · 0.45
create_poolMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected