mgr/dashboard: simplify URL routing, /rgw/detail/<id> -> /rgw/<id>

Signed-off-by: Chang Liu <liuchang0812@gmail.com>
This commit is contained in:
Chang Liu 2017-12-22 11:36:12 +08:00
parent f5b3bb3560
commit c7e2ab548d
2 changed files with 26 additions and 24 deletions

View File

@ -1117,24 +1117,37 @@ class Module(MgrModule):
content_data=json.dumps(content_data, indent=2)
)
@cherrypy.popargs('rgw_id')
class RGWEndpoint(EndPoint):
@cherrypy.expose
def index(self):
""" List all RGW servers """
def index(self, rgw_id=None):
if rgw_id is not None:
template = env.get_template("rgw_detail.html")
toplevel_data = self._toplevel_data()
return template.render(
url_prefix=global_instance().url_prefix,
ceph_version=global_instance().version,
path_info='/rgw' + cherrypy.request.path_info,
toplevel_data=json.dumps(toplevel_data, indent=2),
content_data=json.dumps(self.rgw_data(rgw_id), indent=2)
)
else:
template = env.get_template("rgw.html")
toplevel_data = self._toplevel_data()
""" List all RGW servers """
content_data = self._rgw_daemons()
template = env.get_template("rgw.html")
toplevel_data = self._toplevel_data()
return template.render(
url_prefix = global_instance().url_prefix,
ceph_version=global_instance().version,
path_info='/rgw' + cherrypy.request.path_info,
toplevel_data=json.dumps(toplevel_data, indent=2),
content_data=json.dumps(content_data, indent=2)
)
content_data = self._rgw_daemons()
return template.render(
url_prefix = global_instance().url_prefix,
ceph_version=global_instance().version,
path_info='/rgw' + cherrypy.request.path_info,
toplevel_data=json.dumps(toplevel_data, indent=2),
content_data=json.dumps(content_data, indent=2)
)
def _rgw_daemons(self):
status, data = global_instance().rgw_daemons.get()
@ -1168,17 +1181,6 @@ class Module(MgrModule):
}
@cherrypy.expose
def detail(self, rgw_id):
template = env.get_template("rgw_detail.html")
toplevel_data = self._toplevel_data()
return template.render(
url_prefix=global_instance().url_prefix,
ceph_version=global_instance().version,
path_info='/rgw' + cherrypy.request.path_info,
toplevel_data=json.dumps(toplevel_data, indent=2),
content_data=json.dumps(self.rgw_data(rgw_id), indent=2)
)
@cherrypy.expose
@cherrypy.tools.json_out()
def rgw_data(self, rgw_id):
return self._rgw(rgw_id)

View File

@ -38,7 +38,7 @@ class RGWDaemons(RemoteViewCache):
'server': server,
'metadata': metadata,
'status': status,
'url': "/rgw/detail/{0}".format(service['id'])
'url': "/rgw/{0}".format(service['id'])
}
daemons.append(daemon)