Mount/unmount a ``kernel`` client. The config is optional and defaults to mounting on all clients. If a config is given, it is expected to be a list of clients to do this operation on. This lets you e.g. set up one client with ``ceph-fuse`` and another with ``kclient``. ``
(ctx, config)
| 14 | |
| 15 | @contextlib.contextmanager |
| 16 | def task(ctx, config): |
| 17 | """ |
| 18 | Mount/unmount a ``kernel`` client. |
| 19 | |
| 20 | The config is optional and defaults to mounting on all clients. If |
| 21 | a config is given, it is expected to be a list of clients to do |
| 22 | this operation on. This lets you e.g. set up one client with |
| 23 | ``ceph-fuse`` and another with ``kclient``. |
| 24 | |
| 25 | ``brxnet`` should be a Private IPv4 Address range, default range is |
| 26 | [192.168.0.0/16] |
| 27 | |
| 28 | Example that mounts all clients:: |
| 29 | |
| 30 | tasks: |
| 31 | - ceph: |
| 32 | - kclient: |
| 33 | - interactive: |
| 34 | - brxnet: [192.168.0.0/16] |
| 35 | |
| 36 | Example that uses both ``kclient` and ``ceph-fuse``:: |
| 37 | |
| 38 | tasks: |
| 39 | - ceph: |
| 40 | - ceph-fuse: [client.0] |
| 41 | - kclient: [client.1] |
| 42 | - interactive: |
| 43 | |
| 44 | |
| 45 | Pass a dictionary instead of lists to specify per-client config: |
| 46 | |
| 47 | tasks: |
| 48 | -kclient: |
| 49 | client.0: |
| 50 | debug: true |
| 51 | mntopts: ["nowsync"] |
| 52 | |
| 53 | :param ctx: Context |
| 54 | :param config: Configuration |
| 55 | """ |
| 56 | log.info('Mounting kernel clients...') |
| 57 | |
| 58 | if config is None: |
| 59 | ids = misc.all_roles_of_type(ctx.cluster, 'client') |
| 60 | client_roles = [f'client.{id_}' for id_ in ids] |
| 61 | config = dict([r, dict()] for r in client_roles) |
| 62 | elif isinstance(config, list): |
| 63 | client_roles = config |
| 64 | config = dict([r, dict()] for r in client_roles) |
| 65 | elif isinstance(config, dict): |
| 66 | client_roles = filter(lambda x: 'client.' in x, config.keys()) |
| 67 | else: |
| 68 | raise ValueError(f"Invalid config object: {config} ({config.__class__})") |
| 69 | log.info(f"config is {config}") |
| 70 | |
| 71 | clients = list(misc.get_clients(ctx=ctx, roles=client_roles)) |
| 72 | |
| 73 | test_dir = misc.get_testdir(ctx) |
nothing calls this directly
no test coverage detected