]>
git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/controllers/crush_rule.py
1 # -*- coding: utf-8 -*-
2 from __future__
import absolute_import
4 from cherrypy
import NotFound
6 from . import ApiController
, ControllerDoc
, RESTController
, Endpoint
, ReadPermission
, \
8 from ..security
import Scope
9 from ..services
.ceph_service
import CephService
13 @ApiController('/crush_rule', Scope
.POOL
)
14 class CrushRule(RESTController
):
16 return mgr
.get('osd_map_crush')['rules']
19 rules
= mgr
.get('osd_map_crush')['rules']
21 if r
['rule_name'] == name
:
23 raise NotFound('No such crush rule')
25 def create(self
, name
, root
, failure_domain
, device_class
=None):
29 'type': failure_domain
,
32 CephService
.send_command('mon', 'osd crush rule create-replicated', **rule
)
34 def delete(self
, name
):
35 CephService
.send_command('mon', 'osd crush rule rm', name
=name
)
38 @UiApiController('/crush_rule', Scope
.POOL
)
39 @ControllerDoc("Dashboard UI helper function; not part of the public API", "CrushRuleUi")
40 class CrushRuleUi(CrushRule
):
44 '''Used for crush rule creation modal'''
46 'names': [r
['rule_name'] for r
in mgr
.get('osd_map_crush')['rules']],
47 'nodes': mgr
.get('osd_map_tree')['nodes']