]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Add scrub methods to OSD controller and service
authorTiago Melo <tmelo@suse.com>
Fri, 11 May 2018 15:20:53 +0000 (16:20 +0100)
committerTiago Melo <tmelo@suse.com>
Mon, 4 Jun 2018 13:49:54 +0000 (14:49 +0100)
Signed-off-by: Tiago Melo <tmelo@suse.com>
qa/tasks/mgr/dashboard/test_osd.py
src/pybind/mgr/dashboard/controllers/osd.py
src/pybind/mgr/dashboard/frontend/src/app/shared/api/osd.service.ts

index 63124591228e8577192a7dc376d7ab2859d7134e..c61a8020c739299bf857e174d68c4b3e5d92b3cd 100644 (file)
@@ -34,3 +34,11 @@ class OsdTest(DashboardTestCase):
         self.assert_in_and_not_none(data['histogram'], ['osd'])
         self.assert_in_and_not_none(data['histogram']['osd'], ['op_w_latency_in_bytes_histogram',
                                                                'op_r_latency_out_bytes_histogram'])
+
+    @authenticate
+    def test_scrub(self):
+        self._post('/api/osd/0/scrub?deep=False')
+        self.assertStatus(200)
+
+        self._post('/api/osd/0/scrub?deep=True')
+        self.assertStatus(200)
index 44295d6ef9291854fcb051ca86e9820b464918df..3259649b8e4841fe0a2ab08e0d72a7bc139bc0a5 100644 (file)
@@ -3,8 +3,10 @@ from __future__ import absolute_import
 
 from . import ApiController, AuthRequired, RESTController
 from .. import mgr
+
 from ..services.ceph_service import CephService
 from ..services.exception import handle_send_command_error
+from ..tools import str_to_bool
 
 
 @ApiController('/osd')
@@ -56,3 +58,8 @@ class Osd(RESTController):
             'osd_metadata': mgr.get_metadata('osd', svc_id),
             'histogram': histogram,
         }
+
+    @RESTController.Resource('POST', query_params=['deep'])
+    def scrub(self, svc_id, deep=False):
+        api_scrub = "osd deep-scrub" if str_to_bool(deep) else "osd scrub"
+        CephService.send_command("mon", api_scrub, who=svc_id)
index cf9adf1b5fd75a066a852d9701e9b5295b1369eb..a59bcbcf34249ea0ddba84ded055ac65d39fdcfa 100644 (file)
@@ -5,13 +5,17 @@ import { Injectable } from '@angular/core';
 export class OsdService {
   private path = 'api/osd';
 
-  constructor (private http: HttpClient) {}
+  constructor(private http: HttpClient) {}
 
-  getList () {
+  getList() {
     return this.http.get(`${this.path}`);
   }
 
   getDetails(id: number) {
     return this.http.get(`${this.path}/${id}`);
   }
+
+  scrub(id, deep) {
+    return this.http.post(`${this.path}/${id}/scrub?deep=${deep}`, null);
+  }
 }