]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr: Create pool for nfs ganesha recovery
authorVarsha Rao <varao@redhat.com>
Fri, 3 Jan 2020 13:21:28 +0000 (18:51 +0530)
committerVarsha Rao <varao@redhat.com>
Wed, 8 Apr 2020 09:19:43 +0000 (14:49 +0530)
Fixes: https://tracker.ceph.com/issues/44193
Signed-off-by: Varsha Rao <varao@redhat.com>
src/pybind/mgr/volumes/fs/nfs.py
src/pybind/mgr/volumes/module.py

index 93c607c6c273cd98db464078e869358f2f7d30d8..23ddfee5b2ffe885375de63d3dea6ae184d84984 100644 (file)
@@ -4,9 +4,12 @@ import cephfs
 import orchestrator
 from dashboard.services.cephx import CephX
 from dashboard.services.ganesha import Ganesha, NFSException, Export, GaneshaConfParser
+from .fs_util import create_pool
 
 log = logging.getLogger(__name__)
 
+exp_num = 0
+
 class GaneshaConf(object):
     # pylint: disable=R0902
 
@@ -179,14 +182,14 @@ class GaneshaConf(object):
             for daemon_id in daemons:
                 ioctx.notify("conf-{}".format(daemon_id))
 
-def create_instance(orch):
-    return GaneshaConf("a", "nfs-ganesha", "ganesha", orch)
+def create_instance(orch, pool_name):
+    return GaneshaConf("a", pool_name, "ganesha", orch)
 
 def create_export(ganesha_conf):
     ex_id = ganesha_conf.create_export({
         'path': "/",
         'pseudo': "/cephfs",
-        'cluster_id': "a",
+        'cluster_id': "cluster1",
         'daemons': ["ganesha.a"],
         'tag': "",
         'access_type': "RW",
@@ -199,6 +202,8 @@ def create_export(ganesha_conf):
         })
 
     log.info("Export ID is {}".format(ex_id))
+    global exp_num
+    exp_num += 1
     return 0, "", ""
 
 def delete_export(ganesha_conf, ex_id):
@@ -215,3 +220,19 @@ def check_fsal_valid(fs_map):
 
     #return 0, json.dumps(fsmap_res, indent=2), ""
     return fsmap_res
+
+def create_rados_pool(vc_mgr, pool_name):
+    global exp_num
+    if not exp_num:
+        r, outb, outs = create_pool(vc_mgr, pool_name)
+    """
+    if r != 0:
+        #return r, outb, outs
+
+    command = {'prefix': 'osd pool application enable', 'pool': pool_name, 'app': 'nfs'}
+    r, outb, outs = vc_mgr.mgr.mon_command(command)
+
+    if r != 0:
+        #return r, outb, outs
+    log.info("pool enable done r: {}".format(r))
+    """
index f0ae8192cc01365eaa5a885bc59976ea1c813ab0..902ed981f1b92dd3825342eb84a83aae9d2f95c7 100644 (file)
@@ -5,7 +5,8 @@ from mgr_module import MgrModule
 import orchestrator
 
 from .fs.volume import VolumeClient
-from .fs.nfs import check_fsal_valid, create_instance, create_export, delete_export
+#from .fs.nfs import check_fsal_valid, create_instance, create_export, delete_export
+from .fs.nfs import *
 
 class Module(orchestrator.OrchestratorClientMixin, MgrModule):
     COMMANDS = [
@@ -391,9 +392,11 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule):
 
     def _cmd_fs_nfs_create(self, inbuf, cmd):
         if check_fsal_valid(self.vc.mgr.get('fs_map')):
-            instance = create_instance(self)
+            pool_name = "nfs-ganesha"
+            create_rados_pool(self.vc.mgr, pool_name)
+            instance = create_instance(self, pool_name)
             return create_export(instance)
 
     def _cmd_fs_nfs_delete(self, inbuf, cmd):
-            instance = create_instance(self)
+            instance = create_instance(self, "nfs-ganesha")
             return delete_export(instance, cmd['export_id'])