2011-06-16 01:07:18 +00:00
|
|
|
import contextlib
|
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
|
|
|
|
from teuthology import misc as teuthology
|
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
@contextlib.contextmanager
|
|
|
|
def task(ctx, config):
|
|
|
|
"""
|
|
|
|
Mount/unmount a ``kernel`` client.
|
|
|
|
|
2011-06-16 23:07:59 +00:00
|
|
|
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
|
|
|
|
``cfuse`` and another with ``kclient``.
|
2011-06-16 01:07:18 +00:00
|
|
|
|
2011-06-16 23:51:57 +00:00
|
|
|
Example that mounts all clients::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- kclient:
|
|
|
|
- interactive:
|
|
|
|
|
|
|
|
Example that uses both ``kclient` and ``cfuse``::
|
|
|
|
|
2011-06-16 01:07:18 +00:00
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- cfuse: [client.0]
|
|
|
|
- kclient: [client.1]
|
|
|
|
- interactive:
|
|
|
|
"""
|
|
|
|
log.info('Mounting kernel clients...')
|
2011-06-16 23:07:59 +00:00
|
|
|
assert config is None or isinstance(config, list), \
|
|
|
|
"task kclient got invalid config"
|
2011-06-16 01:07:18 +00:00
|
|
|
|
2011-06-16 23:07:59 +00:00
|
|
|
if config is None:
|
|
|
|
config = ['client.{id}'.format(id=id_)
|
|
|
|
for id_ in teuthology.all_roles_of_type(ctx.cluster, 'client')]
|
2011-08-09 20:23:58 +00:00
|
|
|
clients = list(teuthology.get_clients(ctx=ctx, roles=config))
|
2011-06-16 23:07:59 +00:00
|
|
|
|
|
|
|
for id_, remote in clients:
|
2011-08-04 22:03:05 +00:00
|
|
|
mnt = os.path.join('/tmp/cephtest', 'mnt.{id}'.format(id=id_))
|
|
|
|
log.info('Mounting kclient client.{id} at {remote} {mnt}...'.format(
|
|
|
|
id=id_, remote=remote, mnt=mnt))
|
|
|
|
|
|
|
|
# figure mon ips
|
2011-06-16 01:07:18 +00:00
|
|
|
remotes_and_roles = ctx.cluster.remotes.items()
|
2011-08-04 17:41:50 +00:00
|
|
|
roles = [roles for (remote_, roles) in remotes_and_roles]
|
|
|
|
ips = [host for (host, port) in (remote_.ssh.get_transport().getpeername() for (remote_, roles) in remotes_and_roles)]
|
2011-06-16 01:07:18 +00:00
|
|
|
mons = teuthology.get_mons(roles, ips).values()
|
2011-08-04 22:03:05 +00:00
|
|
|
|
2011-06-16 23:07:59 +00:00
|
|
|
secret = '/tmp/cephtest/data/client.{id}.secret'.format(id=id_)
|
|
|
|
teuthology.write_secret_file(remote, 'client.{id}'.format(id=id_), secret)
|
2011-06-16 01:07:18 +00:00
|
|
|
|
|
|
|
remote.run(
|
|
|
|
args=[
|
|
|
|
'mkdir',
|
|
|
|
'--',
|
|
|
|
mnt,
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
remote.run(
|
|
|
|
args=[
|
|
|
|
'sudo',
|
2011-06-17 23:00:39 +00:00
|
|
|
'/tmp/cephtest/enable-coredump',
|
2011-06-16 01:07:18 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
'/tmp/cephtest/archive/coverage',
|
|
|
|
'/tmp/cephtest/binary/usr/local/sbin/mount.ceph',
|
|
|
|
'{mons}:/'.format(mons=','.join(mons)),
|
|
|
|
mnt,
|
|
|
|
'-v',
|
|
|
|
'-o',
|
|
|
|
'name={id},secretfile={secret}'.format(id=id_,
|
|
|
|
secret=secret),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
try:
|
|
|
|
yield
|
|
|
|
finally:
|
|
|
|
log.info('Unmounting kernel clients...')
|
2011-06-16 23:07:59 +00:00
|
|
|
for id_, remote in clients:
|
|
|
|
log.debug('Unmounting client client.{id}...'.format(id=id_))
|
2011-06-16 01:07:18 +00:00
|
|
|
mnt = os.path.join('/tmp/cephtest', 'mnt.{id}'.format(id=id_))
|
|
|
|
remote.run(
|
|
|
|
args=[
|
|
|
|
'sudo',
|
|
|
|
'umount',
|
|
|
|
mnt,
|
|
|
|
],
|
|
|
|
)
|
|
|
|
remote.run(
|
|
|
|
args=[
|
|
|
|
'rmdir',
|
|
|
|
'--',
|
|
|
|
mnt,
|
|
|
|
],
|
|
|
|
)
|