From c51a6755b52954910512f804cde9e5255c1db9e7 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Thu, 27 Jan 2022 16:06:50 -0500 Subject: [PATCH] mgr/nfs: make _check_rados_notify a function This was previously a staticmethod. This static method was only used by NFSRados object. Staticmethods are nearly always better implemented as functions, which is done so here. Signed-off-by: John Mulligan --- src/pybind/mgr/nfs/export.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/pybind/mgr/nfs/export.py b/src/pybind/mgr/nfs/export.py index 96a4863da622f..8d51225f9ad1b 100644 --- a/src/pybind/mgr/nfs/export.py +++ b/src/pybind/mgr/nfs/export.py @@ -45,6 +45,13 @@ def exception_handler( return getattr(exception_obj, 'errno', -1), "", str(exception_obj) +def _check_rados_notify(ioctx: Any, obj: str) -> None: + try: + ioctx.notify(obj) + except TimedOut: + log.exception("Ganesha timed out") + + class NFSRados: def __init__(self, rados: 'Rados', namespace: str) -> None: self.rados = rados @@ -70,7 +77,7 @@ class NFSRados: # Add created obj url to common config obj ioctx.append(config_obj, GaneshaConfParser.write_block( self._create_url_block(obj)).encode('utf-8')) - ExportMgr._check_rados_notify(ioctx, config_obj) + _check_rados_notify(ioctx, config_obj) log.debug("Added %s url to %s", obj, config_obj) def read_obj(self, obj: str) -> Optional[str]: @@ -87,7 +94,7 @@ class NFSRados: ioctx.write_full(obj, conf_block.encode('utf-8')) log.debug("write configuration into rados object %s/%s/%s", self.pool, self.namespace, obj) - ExportMgr._check_rados_notify(ioctx, config_obj) + _check_rados_notify(ioctx, config_obj) log.debug("Update export %s in %s", obj, config_obj) def remove_obj(self, obj: str, config_obj: str) -> None: @@ -98,7 +105,7 @@ class NFSRados: export_urls = export_urls.replace(url.encode('utf-8'), b'') ioctx.remove_object(obj) ioctx.write_full(config_obj, export_urls) - ExportMgr._check_rados_notify(ioctx, config_obj) + _check_rados_notify(ioctx, config_obj) log.debug("Object deleted: %s", url) def remove_all_obj(self) -> None: @@ -126,13 +133,6 @@ class ExportMgr: self.rados_pool = POOL_NAME self._exports: Optional[Dict[str, List[Export]]] = export_ls - @staticmethod - def _check_rados_notify(ioctx: Any, obj: str) -> None: - try: - ioctx.notify(obj) - except TimedOut: - log.exception("Ganesha timed out") - @property def exports(self) -> Dict[str, List[Export]]: if self._exports is None: -- 2.39.5