summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/controllers/erasure_code_profile.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/pybind/mgr/dashboard/controllers/erasure_code_profile.py
parentInitial commit. (diff)
downloadceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.tar.xz
ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/pybind/mgr/dashboard/controllers/erasure_code_profile.py')
-rw-r--r--src/pybind/mgr/dashboard/controllers/erasure_code_profile.py66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/pybind/mgr/dashboard/controllers/erasure_code_profile.py b/src/pybind/mgr/dashboard/controllers/erasure_code_profile.py
new file mode 100644
index 000000000..c5fb449d6
--- /dev/null
+++ b/src/pybind/mgr/dashboard/controllers/erasure_code_profile.py
@@ -0,0 +1,66 @@
+# -*- coding: utf-8 -*-
+from __future__ import absolute_import
+
+from cherrypy import NotFound
+
+from .. import mgr
+from ..security import Scope
+from ..services.ceph_service import CephService
+from . import APIDoc, APIRouter, Endpoint, EndpointDoc, ReadPermission, RESTController, UIRouter
+
+LIST_CODE__SCHEMA = {
+ "crush-failure-domain": (str, ''),
+ "k": (int, 'Number of data chunks'),
+ "m": (int, 'Number of coding chunks'),
+ "plugin": (str, 'Plugin Info'),
+ "technique": (str, ''),
+ "name": (str, 'Name of the profile')
+}
+
+
+@APIRouter('/erasure_code_profile', Scope.POOL)
+@APIDoc("Erasure Code Profile Management API", "ErasureCodeProfile")
+class ErasureCodeProfile(RESTController):
+ """
+ create() supports additional key-value arguments that are passed to the
+ ECP plugin.
+ """
+ @EndpointDoc("List Erasure Code Profile Information",
+ responses={'200': [LIST_CODE__SCHEMA]})
+ def list(self):
+ return CephService.get_erasure_code_profiles()
+
+ def get(self, name):
+ 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()]
+ CephService.send_command('mon', 'osd erasure-code-profile set', name=name,
+ profile=profile)
+
+ def delete(self, name):
+ CephService.send_command('mon', 'osd erasure-code-profile rm', name=name)
+
+
+@UIRouter('/erasure_code_profile', Scope.POOL)
+@APIDoc("Dashboard UI helper function; not part of the public API", "ErasureCodeProfileUi")
+class ErasureCodeProfileUi(ErasureCodeProfile):
+ @Endpoint()
+ @ReadPermission
+ def info(self):
+ """
+ Used for profile creation and editing
+ """
+ config = mgr.get('config')
+ return {
+ # Because 'shec' and 'clay' are experimental they're not included
+ 'plugins': config['osd_erasure_code_plugins'].split() + ['shec', 'clay'],
+ 'directory': config['erasure_code_dir'],
+ 'nodes': mgr.get('osd_map_tree')['nodes'],
+ 'names': [name for name, _ in
+ mgr.get('osd_map').get('erasure_code_profiles', {}).items()]
+ }