mirror of
https://github.com/ceph/ceph
synced 2024-12-25 04:43:17 +00:00
mgr/dashboard: Refactor CephFS controller
Signed-off-by: Tiago Melo <tmelo@suse.com>
This commit is contained in:
parent
11aa333ff2
commit
f4d3b23555
@ -10,16 +10,16 @@ class CephfsTest(DashboardTestCase):
|
||||
@authenticate
|
||||
def test_cephfs_clients(self):
|
||||
fs_id = self.fs.get_namespace_id()
|
||||
data = self._get("/api/cephfs/clients/{}".format(fs_id))
|
||||
data = self._get("/api/cephfs/{}/clients".format(fs_id))
|
||||
self.assertStatus(200)
|
||||
|
||||
self.assertIn('status', data)
|
||||
self.assertIn('data', data)
|
||||
|
||||
@authenticate
|
||||
def test_cephfs_data(self):
|
||||
def test_cephfs_get(self):
|
||||
fs_id = self.fs.get_namespace_id()
|
||||
data = self._get("/api/cephfs/data/{}/".format(fs_id))
|
||||
data = self._get("/api/cephfs/{}/".format(fs_id))
|
||||
self.assertStatus(200)
|
||||
|
||||
self.assertIn('cephfs', data)
|
||||
@ -32,7 +32,7 @@ class CephfsTest(DashboardTestCase):
|
||||
@authenticate
|
||||
def test_cephfs_mds_counters(self):
|
||||
fs_id = self.fs.get_namespace_id()
|
||||
data = self._get("/api/cephfs/mds_counters/{}".format(fs_id))
|
||||
data = self._get("/api/cephfs/{}/mds_counters".format(fs_id))
|
||||
self.assertStatus(200)
|
||||
|
||||
self.assertIsInstance(data, dict)
|
||||
@ -40,11 +40,22 @@ class CephfsTest(DashboardTestCase):
|
||||
|
||||
@authenticate
|
||||
def test_cephfs_mds_counters_wrong(self):
|
||||
data = self._get("/api/cephfs/mds_counters/baadbaad")
|
||||
self._get("/api/cephfs/baadbaad/mds_counters")
|
||||
self.assertStatus(400)
|
||||
self.assertJsonBody({
|
||||
"component": 'cephfs',
|
||||
"code": "invalid_cephfs_id",
|
||||
"detail": "Invalid cephfs id baadbaad"
|
||||
"detail": "Invalid cephfs ID baadbaad"
|
||||
})
|
||||
|
||||
@authenticate
|
||||
def test_cephfs_list(self):
|
||||
data = self._get("/api/cephfs/")
|
||||
self.assertStatus(200)
|
||||
self.assertIsInstance(data, list)
|
||||
|
||||
cephfs = data[0]
|
||||
self.assertIn('id', cephfs)
|
||||
self.assertIn('mdsmap', cephfs)
|
||||
self.assertIsNotNone(cephfs['id'])
|
||||
self.assertIsNotNone(cephfs['mdsmap'])
|
||||
|
@ -6,7 +6,7 @@ from collections import defaultdict
|
||||
import cherrypy
|
||||
|
||||
from ..exceptions import DashboardException
|
||||
from . import ApiController, AuthRequired, Endpoint, BaseController
|
||||
from . import ApiController, AuthRequired, RESTController
|
||||
from .. import mgr
|
||||
from ..services.ceph_service import CephService
|
||||
from ..tools import ViewCache
|
||||
@ -14,7 +14,7 @@ from ..tools import ViewCache
|
||||
|
||||
@ApiController('/cephfs')
|
||||
@AuthRequired()
|
||||
class CephFS(BaseController):
|
||||
class CephFS(RESTController):
|
||||
def __init__(self):
|
||||
super(CephFS, self).__init__()
|
||||
|
||||
@ -22,19 +22,22 @@ class CephFS(BaseController):
|
||||
# dict is FSCID
|
||||
self.cephfs_clients = {}
|
||||
|
||||
@Endpoint()
|
||||
def list(self):
|
||||
fsmap = mgr.get("fs_map")
|
||||
return fsmap['filesystems']
|
||||
|
||||
def get(self, fs_id):
|
||||
fs_id = self.fs_id_to_int(fs_id)
|
||||
|
||||
return self.fs_status(fs_id)
|
||||
|
||||
@RESTController.Resource('GET')
|
||||
def clients(self, fs_id):
|
||||
fs_id = self.fs_id_to_int(fs_id)
|
||||
|
||||
return self._clients(fs_id)
|
||||
|
||||
@Endpoint()
|
||||
def data(self, fs_id):
|
||||
fs_id = self.fs_id_to_int(fs_id)
|
||||
|
||||
return self.fs_status(fs_id)
|
||||
|
||||
@Endpoint()
|
||||
@RESTController.Resource('GET')
|
||||
def mds_counters(self, fs_id):
|
||||
"""
|
||||
Result format: map of daemon name to map of counter to list of datapoints
|
||||
@ -79,7 +82,7 @@ class CephFS(BaseController):
|
||||
return int(fs_id)
|
||||
except ValueError:
|
||||
raise DashboardException(code='invalid_cephfs_id',
|
||||
msg="Invalid cephfs id {}".format(fs_id),
|
||||
msg="Invalid cephfs ID {}".format(fs_id),
|
||||
component='cephfs')
|
||||
|
||||
def _get_mds_names(self, filesystem_id=None):
|
||||
|
@ -7,15 +7,19 @@ export class CephfsService {
|
||||
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
list() {
|
||||
return this.http.get(`${this.baseURL}`);
|
||||
}
|
||||
|
||||
getCephfs(id) {
|
||||
return this.http.get(`${this.baseURL}/data/${id}`);
|
||||
return this.http.get(`${this.baseURL}/${id}`);
|
||||
}
|
||||
|
||||
getClients(id) {
|
||||
return this.http.get(`${this.baseURL}/clients/${id}`);
|
||||
return this.http.get(`${this.baseURL}/${id}/clients`);
|
||||
}
|
||||
|
||||
getMdsCounters(id) {
|
||||
return this.http.get(`${this.baseURL}/mds_counters/${id}`);
|
||||
return this.http.get(`${this.baseURL}/${id}/mds_counters`);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user