]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
localdir: create/cleanup mnt.foo dir on local fs
authorSage Weil <sage@inktank.com>
Sat, 11 May 2013 06:01:04 +0000 (23:01 -0700)
committerSage Weil <sage@inktank.com>
Sat, 11 May 2013 06:01:04 +0000 (23:01 -0700)
This creates and cleans up a local mnt dir that can be consumed
by other tasks (like workunit, samba, etc), just like any
other client (ceph-fuse, kclient), except it is just a dir on
the local fs.

Signed-off-by: Sage Weil <sage@inktank.com>
teuthology/task/localdir.py [new file with mode: 0644]

diff --git a/teuthology/task/localdir.py b/teuthology/task/localdir.py
new file mode 100644 (file)
index 0000000..8b54217
--- /dev/null
@@ -0,0 +1,64 @@
+import contextlib
+import logging
+import os
+
+from teuthology import misc as teuthology
+from ..orchestra import run
+
+log = logging.getLogger(__name__)
+
+@contextlib.contextmanager
+def task(ctx, config):
+    """
+    Create a mount dir 'client' that is just the local disk:
+
+    Example that "mounts" all clients:
+
+        tasks:
+        - localdir:
+        - interactive:
+
+    Example for a specific client:
+
+        tasks:
+        - localdir: [client.2]
+        - interactive:
+
+    """
+    log.info('Creating local mnt dirs...')
+
+    testdir = teuthology.get_testdir(ctx)
+
+    if config is None:
+        config = list('client.{id}'.format(id=id_)
+                      for id_ in teuthology.all_roles_of_type(ctx.cluster,
+                                                              'client'))
+
+    clients = list(teuthology.get_clients(ctx=ctx, roles=config))
+    for id_, remote in clients:
+        mnt = os.path.join(testdir, 'mnt.{id}'.format(id=id_))
+        log.info('Creating dir {remote} {mnt}...'.format(
+                remote=remote, mnt=mnt))
+        remote.run(
+            args=[
+                'mkdir',
+                '--',
+                mnt,
+                ],
+            )
+
+    try:
+        yield
+
+    finally:
+        log.info('Removing local mnt dirs...')
+        for id_, remote in clients:
+            mnt = os.path.join(testdir, 'mnt.{id}'.format(id=id_))
+            remote.run(
+                args=[
+                    'rm',
+                    '-rf',
+                    '--',
+                    mnt,
+                    ],
+                )