]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/controllers/erasure_code_profile.py
import 15.2.0 Octopus source
[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
9f95a23c 6from . import ApiController, RESTController, Endpoint, ReadPermission, UiApiController
11fdf7f2
TL
7from ..security import Scope
8from ..services.ceph_service import CephService
9from .. import mgr
10
11
11fdf7f2
TL
12@ApiController('/erasure_code_profile', Scope.POOL)
13class ErasureCodeProfile(RESTController):
14 '''
15 create() supports additional key-value arguments that are passed to the
16 ECP plugin.
17 '''
18
19 def list(self):
9f95a23c 20 return CephService.get_erasure_code_profiles()
11fdf7f2
TL
21
22 def get(self, name):
9f95a23c
TL
23 profiles = CephService.get_erasure_code_profiles()
24 for p in profiles:
25 if p['name'] == name:
26 return p
27 raise NotFound('No such erasure code profile')
11fdf7f2
TL
28
29 def create(self, name, **kwargs):
30 profile = ['{}={}'.format(key, value) for key, value in kwargs.items()]
31 CephService.send_command('mon', 'osd erasure-code-profile set', name=name,
32 profile=profile)
33
34 def delete(self, name):
35 CephService.send_command('mon', 'osd erasure-code-profile rm', name=name)
36
9f95a23c
TL
37
38@UiApiController('/erasure_code_profile', Scope.POOL)
39class ErasureCodeProfileUi(ErasureCodeProfile):
11fdf7f2
TL
40 @Endpoint()
41 @ReadPermission
9f95a23c 42 def info(self):
11fdf7f2
TL
43 '''Used for profile creation and editing'''
44 config = mgr.get('config')
45 osd_map_crush = mgr.get('osd_map_crush')
46 return {
47 # Because 'shec' is experimental it's not included
48 'plugins': config['osd_erasure_code_plugins'].split() + ['shec'],
49 'directory': config['erasure_code_dir'],
50 'devices': list({device['class'] for device in osd_map_crush['devices']}),
51 'failure_domains': [domain['name'] for domain in osd_map_crush['types']],
52 'names': [name for name, _ in
53 mgr.get('osd_map').get('erasure_code_profiles', {}).items()]
54 }