]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/services/ceph_service.py
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / pybind / mgr / dashboard / services / ceph_service.py
index 422375f4aff55cbbc8ee087e34ea3b3e4ac9408f..f0e21c598989d692c11a525f82adc7ab4a070049 100644 (file)
@@ -302,13 +302,14 @@ class CephService(object):
         return mgr.get("pg_summary")['by_pool'][pool['pool'].__str__()]
 
     @staticmethod
-    def send_command(srv_type, prefix, srv_spec='', **kwargs):
-        # type: (str, str, Optional[str], Any) -> Any
+    def send_command(srv_type, prefix, srv_spec='', to_json=True, inbuf='', **kwargs):
+        # type: (str, str, Optional[str], bool, str, Any) -> Any
         """
         :type prefix: str
         :param srv_type: mon |
         :param kwargs: will be added to argdict
         :param srv_spec: typically empty. or something like "<fs_id>:0"
+        :param to_json: if true return as json format
 
         :raises PermissionError: See rados.make_ex
         :raises ObjectNotFound: See rados.make_ex
@@ -323,11 +324,12 @@ class CephService(object):
         """
         argdict = {
             "prefix": prefix,
-            "format": "json",
         }
+        if to_json:
+            argdict["format"] = "json"
         argdict.update({k: v for k, v in kwargs.items() if v is not None})
         result = CommandResult("")
-        mgr.send_command(result, srv_type, srv_spec, json.dumps(argdict), "")
+        mgr.send_command(result, srv_type, srv_spec, json.dumps(argdict), "", inbuf=inbuf)
         r, outb, outs = result.wait()
         if r != 0:
             logger.error("send_command '%s' failed. (r=%s, outs=\"%s\", kwargs=%s)", prefix, r,
@@ -381,11 +383,9 @@ class CephService(object):
                         continue
                 else:
                     dev_smart_data = {}
-                for dev_id, dev_data in dev_smart_data.items():
-                    if 'error' in dev_data:
-                        logger.warning(
-                            '[SMART] Error retrieving smartctl data for device ID "%s": %s',
-                            dev_id, dev_data)
+
+                CephService.log_dev_data_error(dev_smart_data)
+
                 break
 
             return dev_smart_data
@@ -393,6 +393,14 @@ class CephService(object):
                        device['devid'])
         return {}
 
+    @staticmethod
+    def log_dev_data_error(dev_smart_data):
+        for dev_id, dev_data in dev_smart_data.items():
+            if 'error' in dev_data:
+                logger.warning(
+                    '[SMART] Error retrieving smartctl data for device ID "%s": %s',
+                    dev_id, dev_data)
+
     @staticmethod
     def get_devices_by_host(hostname):
         # type: (str) -> dict