From 076ccd5465a5945ef29d01f2b0cbec2db718a9de Mon Sep 17 00:00:00 2001 From: Ricardo Dias Date: Tue, 5 Feb 2019 12:03:27 +0000 Subject: [PATCH] mgr/dashboard: ganesha: notify ganesha daemons to reload configuration Signed-off-by: Ricardo Dias --- .../mgr/dashboard/controllers/nfsganesha.py | 17 +++++++++++------ src/pybind/mgr/dashboard/services/ganesha.py | 6 ++++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/pybind/mgr/dashboard/controllers/nfsganesha.py b/src/pybind/mgr/dashboard/controllers/nfsganesha.py index 3e3629bc7f0..90ccfdb5028 100644 --- a/src/pybind/mgr/dashboard/controllers/nfsganesha.py +++ b/src/pybind/mgr/dashboard/controllers/nfsganesha.py @@ -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') diff --git a/src/pybind/mgr/dashboard/services/ganesha.py b/src/pybind/mgr/dashboard/services/ganesha.py index d602c6d6bd9..f74b10f09f2 100644 --- a/src/pybind/mgr/dashboard/services/ganesha.py +++ b/src/pybind/mgr/dashboard/services/ganesha.py @@ -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)) -- 2.39.5