]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/controllers/erasure_code_profile.py
bump version to 18.2.2-pve1
[ceph.git] / ceph / src / pybind / mgr / dashboard / controllers / erasure_code_profile.py
CommitLineData
11fdf7f2 1# -*- coding: utf-8 -*-
11fdf7f2
TL
2
3from cherrypy import NotFound
4
f67539c2 5from .. import mgr
11fdf7f2
TL
6from ..security import Scope
7from ..services.ceph_service import CephService
a4b75251 8from . import APIDoc, APIRouter, Endpoint, EndpointDoc, ReadPermission, RESTController, UIRouter
f67539c2
TL
9
10LIST_CODE__SCHEMA = {
11 "crush-failure-domain": (str, ''),
12 "k": (int, 'Number of data chunks'),
13 "m": (int, 'Number of coding chunks'),
14 "plugin": (str, 'Plugin Info'),
15 "technique": (str, ''),
16 "name": (str, 'Name of the profile')
17}
11fdf7f2
TL
18
19
a4b75251
TL
20@APIRouter('/erasure_code_profile', Scope.POOL)
21@APIDoc("Erasure Code Profile Management API", "ErasureCodeProfile")
11fdf7f2 22class ErasureCodeProfile(RESTController):
e306af50 23 """
11fdf7f2
TL
24 create() supports additional key-value arguments that are passed to the
25 ECP plugin.
e306af50 26 """
f67539c2
TL
27 @EndpointDoc("List Erasure Code Profile Information",
28 responses={'200': [LIST_CODE__SCHEMA]})
11fdf7f2 29 def list(self):
9f95a23c 30 return CephService.get_erasure_code_profiles()
11fdf7f2
TL
31
32 def get(self, name):
9f95a23c
TL
33 profiles = CephService.get_erasure_code_profiles()
34 for p in profiles:
35 if p['name'] == name:
36 return p
37 raise NotFound('No such erasure code profile')
11fdf7f2
TL
38
39 def create(self, name, **kwargs):
40 profile = ['{}={}'.format(key, value) for key, value in kwargs.items()]
41 CephService.send_command('mon', 'osd erasure-code-profile set', name=name,
42 profile=profile)
43
44 def delete(self, name):
45 CephService.send_command('mon', 'osd erasure-code-profile rm', name=name)
46
9f95a23c 47
a4b75251
TL
48@UIRouter('/erasure_code_profile', Scope.POOL)
49@APIDoc("Dashboard UI helper function; not part of the public API", "ErasureCodeProfileUi")
9f95a23c 50class ErasureCodeProfileUi(ErasureCodeProfile):
11fdf7f2
TL
51 @Endpoint()
52 @ReadPermission
9f95a23c 53 def info(self):
e306af50
TL
54 """
55 Used for profile creation and editing
56 """
11fdf7f2 57 config = mgr.get('config')
11fdf7f2 58 return {
adb31ebb
TL
59 # Because 'shec' and 'clay' are experimental they're not included
60 'plugins': config['osd_erasure_code_plugins'].split() + ['shec', 'clay'],
11fdf7f2 61 'directory': config['erasure_code_dir'],
e306af50 62 'nodes': mgr.get('osd_map_tree')['nodes'],
11fdf7f2
TL
63 'names': [name for name, _ in
64 mgr.get('osd_map').get('erasure_code_profiles', {}).items()]
65 }