]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/cephfs: Allow deferred fs creation
authorDouglas Fuller <dfuller@redhat.com>
Wed, 26 Jul 2017 17:05:59 +0000 (13:05 -0400)
committerNathan Cutler <ncutler@suse.com>
Thu, 21 Sep 2017 03:40:00 +0000 (05:40 +0200)
Permit Filesystem objects to be created and settings modified before
calling Filesystem.create().

Signed-off-by: Douglas Fuller <dfuller@redhat.com>
(cherry picked from commit 5fafc03cb9e6d5f39ce494375ea28c89b896e2f5)

qa/tasks/ceph.py
qa/tasks/cephfs/cephfs_test_case.py
qa/tasks/cephfs/filesystem.py
qa/tasks/vstart_runner.py

index 358ec8d648e99555adf05ce5290ab418408e910a..a37fec1c070374e88612306dd9797a88219637f7 100644 (file)
@@ -365,7 +365,7 @@ def cephfs_setup(ctx, config):
     if mdss.remotes:
         log.info('Setting up CephFS filesystem...')
 
-        fs = Filesystem(ctx, create='cephfs')
+        fs = Filesystem(ctx, name='cephfs', create=True)
 
         is_active_mds = lambda role: 'mds.' in role and not role.endswith('-s') and '-s-' not in role
         all_roles = [item for remote_roles in mdss.remotes.values() for item in remote_roles]
index d3c1154ca86aabe7b27df4f2cf0df8a3f6295f11..7f5c6e9d834cdbab431f9a7905d1213d0b6a02f7 100644 (file)
@@ -139,7 +139,7 @@ class CephFSTestCase(CephTestCase):
                 self.mds_cluster.mon_manager.raw_cluster_cmd("auth", "del", entry['entity'])
 
         if self.REQUIRE_FILESYSTEM:
-            self.fs = self.mds_cluster.newfs(True)
+            self.fs = self.mds_cluster.newfs(create=True)
             self.fs.mds_restart()
 
             # In case some test messed with auth caps, reset them
index dad3bd87b2654979a2b22a6664e39401c7fc16e2..f96b6c0afffd0bad69e2dc58a50a63cf776b4afc 100644 (file)
@@ -256,8 +256,8 @@ class MDSCluster(CephCluster):
 
         self._one_or_all(mds_id, _fail_restart)
 
-    def newfs(self, name):
-        return Filesystem(self._ctx, create=name)
+    def newfs(self, name='cephfs', create=True):
+        return Filesystem(self._ctx, name=name, create=create)
 
     def status(self):
         return FSStatus(self.mon_manager)
@@ -362,9 +362,10 @@ class Filesystem(MDSCluster):
     This object is for driving a CephFS filesystem.  The MDS daemons driven by
     MDSCluster may be shared with other Filesystems.
     """
-    def __init__(self, ctx, fscid=None, create=None):
+    def __init__(self, ctx, fscid=None, name=None, create=False):
         super(Filesystem, self).__init__(ctx)
 
+        self.name = name
         self.id = None
         self.name = None
         self.metadata_pool_name = None
@@ -374,18 +375,15 @@ class Filesystem(MDSCluster):
         self.client_id = client_list[0]
         self.client_remote = list(misc.get_clients(ctx=ctx, roles=["client.{0}".format(self.client_id)]))[0][1]
 
-        if create is not None:
+        if name is not None:
             if fscid is not None:
                 raise RuntimeError("cannot specify fscid when creating fs")
-            if create is True:
-                self.name = 'cephfs'
-            else:
-                self.name = create
-            if not self.legacy_configured():
+            if create and not self.legacy_configured():
                 self.create()
-        elif fscid is not None:
-            self.id = fscid
-        self.getinfo(refresh = True)
+        else:
+            if fscid is not None:
+                self.id = fscid
+                self.getinfo(refresh = True)
 
         # Stash a reference to the first created filesystem on ctx, so
         # that if someone drops to the interactive shell they can easily
@@ -412,6 +410,11 @@ class Filesystem(MDSCluster):
         self.get_pool_names(status = status, refresh = refresh)
         return status
 
+    def set_metadata_overlay(self, overlay):
+        if fscid is not None:
+            raise RuntimeError("cannot specify fscid when configuring overlay")
+        self.metadata_overlay = overlay
+
     def deactivate(self, rank):
         if rank < 0:
             raise RuntimeError("invalid rank")
index ce729c96b0894d05863d76175c13d5ce1465fc62..842e80d4d4e857c9421a50e7e28548e5c1d720ea 100644 (file)
@@ -678,8 +678,8 @@ class LocalMDSCluster(LocalCephCluster, MDSCluster):
         # FIXME: unimplemented
         pass
 
-    def newfs(self, name):
-        return LocalFilesystem(self._ctx, create=name)
+    def newfs(self, name='cephfs', create=True):
+        return LocalFilesystem(self._ctx, name=name, create=create)
 
 
 class LocalMgrCluster(LocalCephCluster, MgrCluster):
@@ -691,13 +691,15 @@ class LocalMgrCluster(LocalCephCluster, MgrCluster):
 
 
 class LocalFilesystem(Filesystem, LocalMDSCluster):
-    def __init__(self, ctx, fscid=None, create=None):
+    def __init__(self, ctx, fscid=None, name='cephfs', create=False):
         # Deliberately skip calling parent constructor
         self._ctx = ctx
 
         self.id = None
         self.name = None
         self.metadata_pool_name = None
+        self.metadata_overlay = False
+        self.data_pool_name = None
         self.data_pools = None
 
         # Hack: cheeky inspection of ceph.conf to see what MDSs exist
@@ -722,17 +724,15 @@ class LocalFilesystem(Filesystem, LocalMDSCluster):
 
         self._conf = defaultdict(dict)
 
-        if create is not None:
+        if name is not None:
             if fscid is not None:
                 raise RuntimeError("cannot specify fscid when creating fs")
-            if create is True:
-                self.name = 'cephfs'
-            else:
-                self.name = create
-            self.create()
-        elif fscid is not None:
-            self.id = fscid
-        self.getinfo(refresh=True)
+            if create and not self.legacy_configured():
+                self.create()
+        else:
+            if fscid is not None:
+                self.id = fscid
+                self.getinfo(refresh=True)
 
         # Stash a reference to the first created filesystem on ctx, so
         # that if someone drops to the interactive shell they can easily