]>
git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/ceph_fuse.py
8 from teuthology
import misc
as teuthology
9 from cephfs
.fuse_mount
import FuseMount
10 from tasks
.cephfs
.filesystem
import Filesystem
12 log
= logging
.getLogger(__name__
)
15 def get_client_configs(ctx
, config
):
17 Get a map of the configuration for each FUSE client in the configuration by
18 combining the configuration of the current task with any global overrides.
20 :param ctx: Context instance
21 :param config: configuration for this task
22 :return: dict of client name to config or to None
25 config
= dict(('client.{id}'.format(id=id_
), None)
26 for id_
in teuthology
.all_roles_of_type(ctx
.cluster
, 'client'))
27 elif isinstance(config
, list):
28 config
= dict((name
, None) for name
in config
)
30 overrides
= ctx
.config
.get('overrides', {})
31 teuthology
.deep_merge(config
, overrides
.get('ceph-fuse', {}))
36 @contextlib.contextmanager
37 def task(ctx
, config
):
39 Mount/unmount a ``ceph-fuse`` client.
41 The config is optional and defaults to mounting on all clients. If
42 a config is given, it is expected to be a list of clients to do
43 this operation on. This lets you e.g. set up one client with
44 ``ceph-fuse`` and another with ``kclient``.
46 Example that mounts all clients::
53 Example that uses both ``kclient` and ``ceph-fuse``::
57 - ceph-fuse: [client.0]
61 Example that enables valgrind:
67 valgrind: [--tool=memcheck, --leak-check=full, --show-reachable=yes]
70 Example that stops an already-mounted client:
76 - ceph-fuse: [client.0]
77 - ... do something that requires the FS mounted ...
81 - ... do something that requires the FS unmounted ...
83 Example that adds more generous wait time for mount (for virtual machines):
89 mount_wait: 60 # default is 0, do not wait before checking /sys/
90 mount_timeout: 120 # default is 30, give up if /sys/ is not populated
94 :param config: Configuration
96 log
.info('Running ceph_fuse task...')
98 testdir
= teuthology
.get_testdir(ctx
)
99 log
.info("config is {}".format(str(config
)))
100 config
= get_client_configs(ctx
, config
)
101 log
.info("new config is {}".format(str(config
)))
103 # List clients we will configure mounts for, default is all clients
104 clients
= list(teuthology
.get_clients(ctx
=ctx
, roles
=filter(lambda x
: 'client.' in x
, config
.keys())))
106 all_mounts
= getattr(ctx
, 'mounts', {})
110 # Construct any new FuseMount instances
111 for id_
, remote
in clients
:
112 client_config
= config
.get("client.%s" % id_
)
113 if client_config
is None:
116 skip
= client_config
.get("skip", False)
121 if id_
not in all_mounts
:
122 fuse_mount
= FuseMount(ctx
, client_config
, testdir
, id_
, remote
)
123 all_mounts
[id_
] = fuse_mount
125 # Catch bad configs where someone has e.g. tried to use ceph-fuse and kcephfs for the same client
126 assert isinstance(all_mounts
[id_
], FuseMount
)
128 if not config
.get("disabled", False) and client_config
.get('mounted', True):
129 mounted_by_me
[id_
] = all_mounts
[id_
]
131 ctx
.mounts
= all_mounts
133 # Mount any clients we have been asked to (default to mount all)
134 log
.info('Mounting ceph-fuse clients...')
135 for mount
in mounted_by_me
.values():
138 for mount
in mounted_by_me
.values():
139 mount
.wait_until_mounted()
141 # Umount any pre-existing clients that we have not been asked to mount
142 for client_id
in set(all_mounts
.keys()) - set(mounted_by_me
.keys()) - set(skipped
.keys()):
143 mount
= all_mounts
[client_id
]
144 if mount
.is_mounted():
150 log
.info('Unmounting ceph-fuse clients...')
152 for mount
in mounted_by_me
.values():
153 # Conditional because an inner context might have umounted it
154 if mount
.is_mounted():