]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Add rbd.mkfs method.
authorJosh Durgin <josh.durgin@dreamhost.com>
Sat, 11 Jun 2011 00:02:01 +0000 (17:02 -0700)
committerTommi Virtanen <tommi.virtanen@dreamhost.com>
Wed, 22 Jun 2011 23:03:57 +0000 (16:03 -0700)
teuthology/task/rbd.py

index 092e342eea7e37276db49e724038bec37e071328..479d4fd6c982584e5766f136f7a8fe549743b2b8 100644 (file)
@@ -204,6 +204,45 @@ def dev_create(ctx, config):
                 wait=False,
                 )
 
+@contextlib.contextmanager
+def mkfs(ctx, config):
+    """
+    Create a filesystem on a block device.
+
+    For example::
+
+        tasks:
+        - ceph:
+        - rbd.create_image: [client.0]
+        - rbd.modprobe: [client.0]
+        - rbd.dev_create: [client.0]
+        - rbd.mkfs:
+            client.0:
+                fs_type: xfs
+    """
+    assert isinstance(config, list) or isinstance(config, dict), \
+        "task mkfs must be configured with a list or dictionary"
+    if isinstance(config, dict):
+        images = config.items()
+    else:
+        images = [(role, None) for role in config]
+
+    for role, properties in images:
+        if properties is None:
+            properties = {}
+        (remote,) = ctx.cluster.only(role).remotes.keys()
+        image = properties.get('image_name', default_image_name(role))
+        fs = properties.get('fs_type', 'ext3')
+        remote.run(
+            args=[
+                'sudo',
+                'mkfs',
+                '-t', fs,
+                '/dev/rbd/rbd/{image}'.format(image=image),
+                ],
+            )
+    yield
+
 @contextlib.contextmanager
 def task(ctx, config):
     create_image(ctx, config)