]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/restful/api/mon.py
import quincy beta 17.1.0
[ceph.git] / ceph / src / pybind / mgr / restful / api / mon.py
1 from pecan import expose, response
2 from pecan.rest import RestController
3
4 from restful import context
5 from restful.decorators import auth
6
7
8 class MonName(RestController):
9 def __init__(self, name):
10 self.name = name
11
12
13 @expose(template='json')
14 @auth
15 def get(self, **kwargs):
16 """
17 Show the information for the monitor name
18 """
19 mon = [x for x in context.instance.get_mons()
20 if x['name'] == self.name]
21 if len(mon) != 1:
22 response.status = 500
23 return {'message': 'Failed to identify the monitor node "{}"'.format(self.name)}
24 return mon[0]
25
26
27
28 class Mon(RestController):
29 @expose(template='json')
30 @auth
31 def get(self, **kwargs):
32 """
33 Show the information for all the monitors
34 """
35 return context.instance.get_mons()
36
37
38 @expose()
39 def _lookup(self, name, *remainder):
40 return MonName(name), remainder