]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/nfs: make _check_rados_notify a function
authorJohn Mulligan <jmulligan@redhat.com>
Thu, 27 Jan 2022 21:06:50 +0000 (16:06 -0500)
committerJohn Mulligan <jmulligan@redhat.com>
Wed, 23 Feb 2022 21:27:23 +0000 (16:27 -0500)
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 <jmulligan@redhat.com>
src/pybind/mgr/nfs/export.py

index 96a4863da622fdd8f90b86aa2a1d7db468e318e5..8d51225f9ad1b6300159dd8ac129fefb3e109ee9 100644 (file)
@@ -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: