From 721fab343c5d3dadfc0def2c2e3716c71834a781 Mon Sep 17 00:00:00 2001 From: Ricardo Dias Date: Tue, 5 Feb 2019 16:06:21 +0000 Subject: [PATCH] mgr/dashboard: ganesha: support no namespace Signed-off-by: Ricardo Dias --- src/pybind/mgr/dashboard/services/ganesha.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/pybind/mgr/dashboard/services/ganesha.py b/src/pybind/mgr/dashboard/services/ganesha.py index f74b10f09f2e..0fffd3f5ce67 100644 --- a/src/pybind/mgr/dashboard/services/ganesha.py +++ b/src/pybind/mgr/dashboard/services/ganesha.py @@ -44,13 +44,15 @@ class Ganesha(object): cluster = "_default_" if location.count('/') == 0: pool, namespace = location, None - pool, namespace = location.split('/', 1) + else: + pool, namespace = location.split('/', 1) else: cluster = location[:location.find(':')] pool_nm = location[location.find(':')+1:] if pool_nm.count('/') == 0: pool, namespace = pool_nm, None - pool, namespace = pool_nm.split('/', 1) + else: + pool, namespace = pool_nm.split('/', 1) if cluster in result: raise NFSException("Duplicate Ganesha cluster definition in " @@ -780,7 +782,8 @@ class GaneshaConf(object): def _read_raw_config(self): with mgr.rados.open_ioctx(self.rados_pool) as ioctx: - ioctx.set_namespace(self.rados_namespace) + if self.rados_namespace: + ioctx.set_namespace(self.rados_namespace) objs = ioctx.list_objects() for obj in objs: if obj.key.startswith("export-"): @@ -806,7 +809,8 @@ class GaneshaConf(object): def _write_raw_config(self, conf_block, obj): raw_config = GaneshaConfParser.write_conf(conf_block) with mgr.rados.open_ioctx(self.rados_pool) as ioctx: - ioctx.set_namespace(self.rados_namespace) + if self.rados_namespace: + ioctx.set_namespace(self.rados_namespace) ioctx.write_full(obj, raw_config.encode('utf-8')) logger.debug( "[NFS] write configuration into rados object %s/%s/%s:\n%s", @@ -936,7 +940,8 @@ class GaneshaConf(object): def _delete_export(self, export_id): self._persist_daemon_configuration() with mgr.rados.open_ioctx(self.rados_pool) as ioctx: - ioctx.set_namespace(self.rados_namespace) + if self.rados_namespace: + ioctx.set_namespace(self.rados_namespace) ioctx.remove_object("export-{}".format(export_id)) def list_exports(self): @@ -979,6 +984,7 @@ class GaneshaConf(object): def reload_daemons(self, daemons): with mgr.rados.open_ioctx(self.rados_pool) as ioctx: - ioctx.set_namespace(self.rados_namespace) + if self.rados_namespace: + ioctx.set_namespace(self.rados_namespace) for daemon_id in daemons: ioctx.notify("conf-{}".format(daemon_id)) -- 2.47.3