]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard/api: move/create OSD histogram in separate endpoint 37973/head
authorAashish Sharma <aashishsharma@localhost.localdomain>
Wed, 16 Sep 2020 13:43:04 +0000 (19:13 +0530)
committerLaura Paduano <lpaduano@suse.com>
Thu, 3 Dec 2020 13:59:51 +0000 (14:59 +0100)
Added a separate endpoint for osd/histogram - api/osd/{svc_id}/histogram

Fixes:https://tracker.ceph.com/issues/46898
Signed-off-by: Aashish Sharma <aasharma@redhat.com>
(cherry picked from commit 1c812e0d61ec8320cb5d3864199af9c31b2aa238)

qa/tasks/mgr/dashboard/test_osd.py
src/pybind/mgr/dashboard/controllers/osd.py

index 0bd3f93f32495b37b1688fe887b47455c11ef021..3f6c03e851e013e59c4b5f431e14fb7bce8995d1 100644 (file)
@@ -54,6 +54,12 @@ class OsdTest(DashboardTestCase):
         self.assert_in_and_not_none(data['histogram']['osd'], ['op_w_latency_in_bytes_histogram',
                                                                'op_r_latency_out_bytes_histogram'])
 
+    def test_histogram(self):
+        data = self._get('/api/osd/0/histogram')
+        self.assertStatus(200)
+        self.assert_in_and_not_none(data['osd'], ['op_w_latency_in_bytes_histogram',
+                                                               'op_r_latency_out_bytes_histogram'])    
+
     def test_scrub(self):
         self._post('/api/osd/0/scrub?deep=False')
         self.assertStatus(200)
index e29a056a167fdaac854b0f7c2070dbd9892425d0..fa7a6fc7019a5844a66f9e66f85ca3e3ec458a39 100644 (file)
@@ -117,6 +117,22 @@ class Osd(RESTController):
             'histogram': histogram,
         }
 
+    @RESTController.Resource('GET')
+    @handle_send_command_error('osd')
+    def histogram(self, svc_id):
+        # type: (int) -> Dict[str, Any]
+        """
+        :return: Returns the histogram data.
+        """
+        try:
+            histogram = CephService.send_command(
+                'osd', srv_spec=svc_id, prefix='perf histogram dump')
+        except SendCommandError as e:  # pragma: no cover - the handling is too obvious
+            raise DashboardException(
+                component='osd', http_status_code=400, msg=str(e))
+
+        return histogram
+
     def set(self, svc_id, device_class):  # pragma: no cover
         old_device_class = CephService.send_command('mon', 'osd crush get-device-class',
                                                     ids=[svc_id])