]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr/mgr_module: make rados handle available to all modules 19972/head
authorSage Weil <sage@redhat.com>
Tue, 16 Jan 2018 21:02:14 +0000 (15:02 -0600)
committerSage Weil <sage@redhat.com>
Tue, 16 Jan 2018 21:02:14 +0000 (15:02 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/pybind/mgr/dashboard/module.py
src/pybind/mgr/mgr_module.py

index 2e35f34edddf7fae45cb96f760ceb6da845df645..de9b889a2eeaa6879b5e2867381c7aa7dbe9f764 100644 (file)
@@ -32,7 +32,6 @@ from mgr_module import MgrModule, MgrStandbyModule, CommandResult
 from types import OsdMap, NotFound, Config, FsMap, MonMap, \
     PgSummary, Health, MonStatus
 
-import rados
 import rbd_iscsi
 import rbd_mirroring
 from rbd_ls import RbdLs, RbdPoolLs
@@ -125,9 +124,6 @@ class Module(MgrModule):
         self.log_buffer = collections.deque(maxlen=LOG_BUFFER_SIZE)
         self.audit_buffer = collections.deque(maxlen=LOG_BUFFER_SIZE)
 
-        # Keep a librados instance for those that need it.
-        self._rados = None
-
         # Stateful instances of RbdLs, hold cached results.  Key to dict
         # is pool name.
         self.rbd_ls = {}
@@ -156,21 +152,6 @@ class Module(MgrModule):
         # A prefix for all URLs to use the dashboard with a reverse http proxy
         self.url_prefix = ''
 
-    @property
-    def rados(self):
-        """
-        A librados instance to be shared by any classes within
-        this mgr module that want one.
-        """
-        if self._rados:
-            return self._rados
-
-        ctx_capsule = self.get_context()
-        self._rados = rados.Rados(context=ctx_capsule)
-        self._rados.connect()
-
-        return self._rados
-
     def update_pool_stats(self):
         df = global_instance().get("df")
         pool_stats = dict([(p['id'], p['stats']) for p in df['pools']])
@@ -245,10 +226,6 @@ class Module(MgrModule):
         cherrypy.engine.exit()
         log.info("Stopped server")
 
-        log.info("Stopping librados...")
-        if self._rados:
-            self._rados.shutdown()
-        log.info("Stopped librados.")
 
     def get_latest(self, daemon_type, daemon_name, stat):
         data = self.get_counter(daemon_type, daemon_name, stat)[stat]
index 88296f9308918ea2fcbf53e410c7e8b05a4cd021..430d8b3558020c2f5567d37cddf074be653eb9b7 100644 (file)
@@ -8,6 +8,7 @@ import json
 import logging
 import threading
 from collections import defaultdict
+import rados
 
 
 class CPlusPlusHandler(logging.Handler):
@@ -225,6 +226,9 @@ class MgrModule(ceph_module.BaseMgrModule):
 
         self._perf_schema_cache = None
 
+        # Keep a librados instance for those that need it.
+        self._rados = None
+
     def __del__(self):
         unconfigure_logger(self, self.module_name)
 
@@ -278,7 +282,8 @@ class MgrModule(ceph_module.BaseMgrModule):
 
         :return: None
         """
-        pass
+        if self._rados:
+            self._rados.shutdown()
 
     def get(self, data_name):
         """
@@ -603,4 +608,20 @@ class MgrModule(ceph_module.BaseMgrModule):
         and/or the monitor cluster is down.
         """
 
-        return self._ceph_have_mon_connection()
\ No newline at end of file
+        return self._ceph_have_mon_connection()
+
+    @property
+    def rados(self):
+        """
+        A librados instance to be shared by any classes within
+        this mgr module that want one.
+        """
+        if self._rados:
+            return self._rados
+
+        ctx_capsule = self.get_context()
+        self._rados = rados.Rados(context=ctx_capsule)
+        self._rados.connect()
+
+        return self._rados
+