]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/controllers/erasure_code_profile.py
import 15.2.9
[ceph.git] / ceph / src / pybind / mgr / dashboard / controllers / erasure_code_profile.py
CommitLineData
11fdf7f2
TL
1# -*- coding: utf-8 -*-
2from __future__ import absolute_import
3
4from cherrypy import NotFound
5
f6b5b4d7
TL
6from . import ApiController, ControllerDoc, RESTController, Endpoint, ReadPermission, \
7 UiApiController
11fdf7f2
TL
8from ..security import Scope
9from ..services.ceph_service import CephService
10from .. import mgr
11
12
11fdf7f2
TL
13@ApiController('/erasure_code_profile', Scope.POOL)
14class ErasureCodeProfile(RESTController):
e306af50 15 """
11fdf7f2
TL
16 create() supports additional key-value arguments that are passed to the
17 ECP plugin.
e306af50 18 """
11fdf7f2
TL
19
20 def list(self):
9f95a23c 21 return CephService.get_erasure_code_profiles()
11fdf7f2
TL
22
23 def get(self, name):
9f95a23c
TL
24 profiles = CephService.get_erasure_code_profiles()
25 for p in profiles:
26 if p['name'] == name:
27 return p
28 raise NotFound('No such erasure code profile')
11fdf7f2
TL
29
30 def create(self, name, **kwargs):
31 profile = ['{}={}'.format(key, value) for key, value in kwargs.items()]
32 CephService.send_command('mon', 'osd erasure-code-profile set', name=name,
33 profile=profile)
34
35 def delete(self, name):
36 CephService.send_command('mon', 'osd erasure-code-profile rm', name=name)
37
9f95a23c
TL
38
39@UiApiController('/erasure_code_profile', Scope.POOL)
f6b5b4d7 40@ControllerDoc("Dashboard UI helper function; not part of the public API", "ErasureCodeProfileUi")
9f95a23c 41class ErasureCodeProfileUi(ErasureCodeProfile):
11fdf7f2
TL
42 @Endpoint()
43 @ReadPermission
9f95a23c 44 def info(self):
e306af50
TL
45 """
46 Used for profile creation and editing
47 """
11fdf7f2 48 config = mgr.get('config')
11fdf7f2 49 return {
adb31ebb
TL
50 # Because 'shec' and 'clay' are experimental they're not included
51 'plugins': config['osd_erasure_code_plugins'].split() + ['shec', 'clay'],
11fdf7f2 52 'directory': config['erasure_code_dir'],
e306af50 53 'nodes': mgr.get('osd_map_tree')['nodes'],
11fdf7f2
TL
54 'names': [name for name, _ in
55 mgr.get('osd_map').get('erasure_code_profiles', {}).items()]
56 }