]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: ganesha: notify ganesha daemons to reload configuration
authorRicardo Dias <rdias@suse.com>
Tue, 5 Feb 2019 12:03:27 +0000 (12:03 +0000)
committerRicardo Dias <rdias@suse.com>
Tue, 5 Feb 2019 12:03:27 +0000 (12:03 +0000)
Signed-off-by: Ricardo Dias <rdias@suse.com>
src/pybind/mgr/dashboard/controllers/nfsganesha.py
src/pybind/mgr/dashboard/services/ganesha.py

index 3e3629bc7f0513312dff5dbed599ad8141ef1f25..90ccfdb50289cadd4ff6be81778f5efbdbd9024a 100644 (file)
@@ -41,7 +41,8 @@ class NFSGaneshaExports(RESTController):
     @NfsTask('create', {'path': '{path}', 'fsal': '{fsal.name}',
                         'cluster_id': '{cluster_id}'}, 2.0)
     def create(self, path, cluster_id, daemons, pseudo, tag, access_type,
-               squash, security_label, protocols, transports, fsal, clients):
+               squash, security_label, protocols, transports, fsal, clients,
+               reload_daemons=True):
         if fsal['name'] not in Ganesha.fsals_available():
             raise NFSException("Cannot create this export. "
                                "FSAL '{}' cannot be managed by the dashboard."
@@ -62,7 +63,8 @@ class NFSGaneshaExports(RESTController):
             'fsal': fsal,
             'clients': clients
         })
-        Ganesha.reload_daemons(cluster_id, daemons)
+        if reload_daemons:
+            ganesha_conf.reload_daemons(daemons)
         return ganesha_conf.get_export(ex_id).to_dict()
 
     def get(self, cluster_id, export_id):
@@ -75,7 +77,8 @@ class NFSGaneshaExports(RESTController):
     @NfsTask('edit', {'cluster_id': '{cluster_id}', 'export_id': '{export_id}'},
              2.0)
     def set(self, cluster_id, export_id, path, daemons, pseudo, tag, access_type,
-            squash, security_label, protocols, transports, fsal, clients):
+            squash, security_label, protocols, transports, fsal, clients,
+            reload_daemons=True):
         export_id = int(export_id)
         ganesha_conf = GaneshaConf.instance(cluster_id)
 
@@ -106,12 +109,13 @@ class NFSGaneshaExports(RESTController):
         for d_id in old_export.daemons:
             if d_id not in daemons:
                 daemons.append(d_id)
-        Ganesha.reload_daemons(cluster_id, daemons)
+        if reload_daemons:
+            ganesha_conf.reload_daemons(daemons)
         return ganesha_conf.get_export(export_id).to_dict()
 
     @NfsTask('delete', {'cluster_id': '{cluster_id}',
                         'export_id': '{export_id}'}, 2.0)
-    def delete(self, cluster_id, export_id):
+    def delete(self, cluster_id, export_id, reload_daemons=True):
         export_id = int(export_id)
         ganesha_conf = GaneshaConf.instance(cluster_id)
 
@@ -119,7 +123,8 @@ class NFSGaneshaExports(RESTController):
             raise cherrypy.HTTPError(404)
 
         export = ganesha_conf.remove_export(export_id)
-        Ganesha.reload_daemons(cluster_id, export.daemons)
+        if reload_daemons:
+            ganesha_conf.reload_daemons(export.daemons)
 
 
 @ApiController('/nfs-ganesha/daemon')
index d602c6d6bd9a8579c0d9986da46658d1a7d72327..f74b10f09f2ec85bf95e8c00f4642239b29cf6d6 100644 (file)
@@ -976,3 +976,9 @@ class GaneshaConf(object):
 
     def list_daemons(self):
         return [daemon_id for daemon_id in self.daemons_conf_blocks]
+
+    def reload_daemons(self, daemons):
+        with mgr.rados.open_ioctx(self.rados_pool) as ioctx:
+            ioctx.set_namespace(self.rados_namespace)
+            for daemon_id in daemons:
+                ioctx.notify("conf-{}".format(daemon_id))