From 2783b021eccbc4e743e1c2a3888f624984d27da8 Mon Sep 17 00:00:00 2001 From: Tiago Melo Date: Fri, 11 May 2018 16:20:53 +0100 Subject: [PATCH] mgr/dashboard: Add scrub methods to OSD controller and service Signed-off-by: Tiago Melo --- qa/tasks/mgr/dashboard/test_osd.py | 8 ++++++++ src/pybind/mgr/dashboard/controllers/osd.py | 7 +++++++ .../dashboard/frontend/src/app/shared/api/osd.service.ts | 8 ++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/qa/tasks/mgr/dashboard/test_osd.py b/qa/tasks/mgr/dashboard/test_osd.py index 63124591228..c61a8020c73 100644 --- a/qa/tasks/mgr/dashboard/test_osd.py +++ b/qa/tasks/mgr/dashboard/test_osd.py @@ -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) diff --git a/src/pybind/mgr/dashboard/controllers/osd.py b/src/pybind/mgr/dashboard/controllers/osd.py index 44295d6ef92..3259649b8e4 100644 --- a/src/pybind/mgr/dashboard/controllers/osd.py +++ b/src/pybind/mgr/dashboard/controllers/osd.py @@ -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) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/osd.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/osd.service.ts index cf9adf1b5fd..a59bcbcf342 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/osd.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/osd.service.ts @@ -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); + } } -- 2.39.5