2 Mount cifs clients. Unmount when finished.
8 from teuthology import misc as teuthology
9 from teuthology.orchestra import run
11 log = logging.getLogger(__name__)
13 @contextlib.contextmanager
14 def task(ctx, config):
16 Mount/unmount a cifs client.
18 The config is optional and defaults to mounting on all clients. If
19 a config is given, it is expected to be a list of clients to do
22 Example that starts smbd and mounts cifs on all nodes::
30 Example that splits smbd and cifs:
35 - cifs-mount: [client.0]
36 - ceph-fuse: [client.1]
39 Example that specifies the share name:
46 cephfuse: "{testdir}/mnt.0"
52 :param config: Configuration
54 log.info('Mounting cifs clients...')
57 config = dict(('client.{id}'.format(id=id_), None)
58 for id_ in teuthology.all_roles_of_type(ctx.cluster, 'client'))
59 elif isinstance(config, list):
60 config = dict((name, None) for name in config)
62 clients = list(teuthology.get_clients(ctx=ctx, roles=config.keys()))
64 from .samba import get_sambas
65 samba_roles = ['samba.{id_}'.format(id_=id_) for id_ in teuthology.all_roles_of_type(ctx.cluster, 'samba')]
66 sambas = list(get_sambas(ctx=ctx, roles=samba_roles))
67 (ip, _) = sambas[0][1].ssh.get_transport().getpeername()
68 log.info('samba ip: {ip}'.format(ip=ip))
70 for id_, remote in clients:
71 mnt = os.path.join(teuthology.get_testdir(ctx), 'mnt.{id}'.format(id=id_))
72 log.info('Mounting cifs client.{id} at {remote} {mnt}...'.format(
73 id=id_, remote=remote,mnt=mnt))
83 rolestr = 'client.{id_}'.format(id_=id_)
85 log.info("config: {c}".format(c=config))
86 if config[rolestr] is not None and 'share' in config[rolestr]:
87 unc = config[rolestr]['share']
95 '//{sambaip}/{unc}'.format(sambaip=ip, unc=unc),
97 'username=ubuntu,password=ubuntu',
107 '{m}/'.format(m=mnt),
114 log.info('Unmounting cifs clients...')
115 for id_, remote in clients:
123 for id_, remote in clients:
131 'grep', 'Device or resource busy',