]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tasks/ceph: refactor legacy FS configuration check
authorJohn Spray <jspray@redhat.com>
Mon, 6 Apr 2015 18:53:50 +0000 (19:53 +0100)
committerJohn Spray <jcspray@gmail.com>
Tue, 21 Apr 2015 13:20:44 +0000 (14:20 +0100)
Move up into Filesystem so that this can be used from
the ceph_deploy task as well.

Signed-off-by: John Spray <john.spray@redhat.com>
(cherry picked from commit ea7c39222ae084c90b5a8510ce5af35a2f75a6e3)

tasks/ceph.py
tasks/cephfs/filesystem.py

index 6de4702916929b007b604f2eca58391d74f25e02..ddd95fd5f0574fbe1489d399b81a7e44ac3f51a5 100644 (file)
@@ -18,7 +18,6 @@ from teuthology import misc as teuthology
 from teuthology import contextutil
 from teuthology.orchestra import run
 import ceph_client as cclient
-from teuthology.orchestra.run import CommandFailedError
 from teuthology.orchestra.daemon import DaemonGroup
 
 
@@ -202,24 +201,8 @@ def cephfs_setup(ctx, config):
     if mdss.remotes:
         log.info('Setting up CephFS filesystem...')
 
-        try:
-            proc = mon_remote.run(args=['sudo', 'ceph', '--format=json-pretty', 'osd', 'lspools'],
-                                  stdout=StringIO())
-            pools = json.loads(proc.stdout.getvalue())
-            metadata_pool_exists = 'metadata' in [p['poolname'] for p in pools]
-        except CommandFailedError as e:
-            # For use in upgrade tests, Ceph cuttlefish and earlier don't support
-            # structured output (--format) from the CLI.
-            if e.exitstatus == 22:
-                metadata_pool_exists = True
-            else:
-                raise
-
-        # In case we are using an older Ceph which creates FS by default
-        if metadata_pool_exists:
-            log.info("Metadata pool already exists, skipping")
-        else:
-            ceph_fs = Filesystem(ctx)
+        ceph_fs = Filesystem(ctx)
+        if not ceph_fs.legacy_configured():
             ceph_fs.create()
 
         is_active_mds = lambda role: role.startswith('mds.') and not role.endswith('-s') and role.find('-s-') == -1
index 07acd1fc62f31dddcf18c5ef4fd52830348ce4f4..cf7f6041cf97cb53fc5971b108a535577c68a59d 100644 (file)
@@ -70,6 +70,26 @@ class Filesystem(object):
         self.mon_remote.run(args=['sudo', 'ceph', 'osd', 'pool', 'delete',
                                   'data', 'data', '--yes-i-really-really-mean-it'])
 
+    def legacy_configured(self):
+        """
+        Check if a legacy (i.e. pre "fs new") filesystem configuration is present.  If this is
+        the case, the caller should avoid using Filesystem.create
+        """
+        try:
+            proc = self.mon_remote.run(args=['sudo', 'ceph', '--format=json-pretty', 'osd', 'lspools'],
+                                  stdout=StringIO())
+            pools = json.loads(proc.stdout.getvalue())
+            metadata_pool_exists = 'metadata' in [p['poolname'] for p in pools]
+        except CommandFailedError as e:
+            # For use in upgrade tests, Ceph cuttlefish and earlier don't support
+            # structured output (--format) from the CLI.
+            if e.exitstatus == 22:
+                metadata_pool_exists = True
+            else:
+                raise
+
+        return metadata_pool_exists
+
     def _df(self):
         return json.loads(self.mon_manager.raw_cluster_cmd("df", "--format=json-pretty"))