self.assertStatus(204)
def test_ecp_info(self):
- self._get('/api/erasure_code_profile/_info')
+ self._get('/ui-api/erasure_code_profile/info')
self.assertSchemaBody(JObj({
'names': JList(six.string_types),
'failure_domains': JList(six.string_types),
from cherrypy import NotFound
-from . import ApiController, RESTController, Endpoint, ReadPermission
+from . import ApiController, RESTController, Endpoint, ReadPermission, UiApiController
from ..security import Scope
from ..services.ceph_service import CephService
from .. import mgr
-def _serialize_ecp(name, ecp):
- def serialize_numbers(key):
- value = ecp.get(key)
- if value is not None:
- ecp[key] = int(value)
-
- ecp['name'] = name
- serialize_numbers('k')
- serialize_numbers('m')
- return ecp
-
-
@ApiController('/erasure_code_profile', Scope.POOL)
class ErasureCodeProfile(RESTController):
'''
'''
def list(self):
- ret = []
- for name, ecp in mgr.get('osd_map').get('erasure_code_profiles', {}).items():
- ret.append(_serialize_ecp(name, ecp))
- return ret
+ return CephService.get_erasure_code_profiles()
def get(self, name):
- try:
- ecp = mgr.get('osd_map')['erasure_code_profiles'][name]
- return _serialize_ecp(name, ecp)
- except KeyError:
- raise NotFound('No such erasure code profile')
+ profiles = CephService.get_erasure_code_profiles()
+ for p in profiles:
+ if p['name'] == name:
+ return p
+ raise NotFound('No such erasure code profile')
def create(self, name, **kwargs):
profile = ['{}={}'.format(key, value) for key, value in kwargs.items()]
def delete(self, name):
CephService.send_command('mon', 'osd erasure-code-profile rm', name=name)
+
+@UiApiController('/erasure_code_profile', Scope.POOL)
+class ErasureCodeProfileUi(ErasureCodeProfile):
@Endpoint()
@ReadPermission
- def _info(self):
+ def info(self):
'''Used for profile creation and editing'''
config = mgr.get('config')
osd_map_crush = mgr.get('osd_map_crush')
expect(req.request.method).toBe('POST');
});
- it('should call update', () => {
- service.update(testProfile).subscribe();
- const req = httpTesting.expectOne(`${apiPath}/test`);
- expect(req.request.method).toBe('PUT');
- });
-
it('should call delete', () => {
service.delete('test').subscribe();
const req = httpTesting.expectOne(`${apiPath}/test`);
expect(req.request.method).toBe('DELETE');
});
- it('should call get', () => {
- service.get('test').subscribe();
- const req = httpTesting.expectOne(`${apiPath}/test`);
- expect(req.request.method).toBe('GET');
- });
-
it('should call getInfo', () => {
service.getInfo().subscribe();
- const req = httpTesting.expectOne(`${apiPath}/_info`);
+ const req = httpTesting.expectOne(`ui-${apiPath}/info`);
expect(req.request.method).toBe('GET');
});
});
apiPath = 'api/erasure_code_profile';
formTooltips = {
- // Copied from /srv/cephmgr/ceph-dev/doc/rados/operations/erasure-code.*.rst
+ // Copied from /doc/rados/operations/erasure-code.*.rst
k: this.i18n(`Each object is split in data-chunks parts, each stored on a different OSD.`),
m: this.i18n(`Compute coding chunks for each object and store them on different OSDs.
return this.http.post(this.apiPath, ecp, { observe: 'response' });
}
- update(ecp: ErasureCodeProfile) {
- return this.http.put(`${this.apiPath}/${ecp.name}`, ecp, { observe: 'response' });
- }
-
delete(name: string) {
return this.http.delete(`${this.apiPath}/${name}`, { observe: 'response' });
}
- get(name: string) {
- return this.http.get(`${this.apiPath}/${name}`);
- }
-
getInfo() {
- return this.http.get(`${this.apiPath}/_info`);
+ return this.http.get(`ui-${this.apiPath}/info`);
}
}
pools_w_stats.append(pool)
return pools_w_stats
+ @classmethod
+ def get_erasure_code_profiles(cls):
+ def _serialize_ecp(name, ecp):
+ def serialize_numbers(key):
+ value = ecp.get(key)
+ if value is not None:
+ ecp[key] = int(value)
+
+ ecp['name'] = name
+ serialize_numbers('k')
+ serialize_numbers('m')
+ return ecp
+
+ ret = []
+ for name, ecp in mgr.get('osd_map').get('erasure_code_profiles', {}).items():
+ ret.append(_serialize_ecp(name, ecp))
+ return ret
+
@classmethod
def get_pool_name_from_id(cls, pool_id):
pool_list = cls.get_pool_list()
self._get('/api/erasure_code_profile')
self.assertStatus(200)
self.assertJsonBody([{'k': 2, 'm': 1, 'name': 'test'}])
-
- def test_get(self):
- self._get('/api/erasure_code_profile/test')
- self.assertStatus(200)
- self.assertJsonBody({'k': 2, 'm': 1, 'name': 'test'})