From: John Spray Date: Tue, 27 Sep 2016 13:17:26 +0000 (+0100) Subject: pybind/mgr/rest: fix "sync_object" API endpoint X-Git-Tag: v11.0.1~60^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=9a33766bd882dd5747e5c95967edb58fdca43f59;p=ceph-ci.git pybind/mgr/rest: fix "sync_object" API endpoint Signed-off-by: John Spray --- diff --git a/src/pybind/mgr/rest/app/types.py b/src/pybind/mgr/rest/app/types.py index 33cdafaed53..331c7c94140 100644 --- a/src/pybind/mgr/rest/app/types.py +++ b/src/pybind/mgr/rest/app/types.py @@ -235,7 +235,7 @@ class NotFound(Exception): # The objects that ClusterMonitor keeps copies of from the mon -SYNC_OBJECT_TYPES = [FsMap, OsdMap, MonMap, PgSummary, Health, Config] +SYNC_OBJECT_TYPES = [FsMap, OsdMap, MonMap, MonStatus, PgSummary, Health, Config] SYNC_OBJECT_STR_TYPE = dict((t.str, t) for t in SYNC_OBJECT_TYPES) USER_REQUEST_COMPLETE = 'complete' diff --git a/src/pybind/mgr/rest/app/views/v2.py b/src/pybind/mgr/rest/app/views/v2.py index 26380778078..411c3552917 100644 --- a/src/pybind/mgr/rest/app/views/v2.py +++ b/src/pybind/mgr/rest/app/views/v2.py @@ -21,7 +21,7 @@ from rest.app.views.rpc_view import RPCViewSet, DataObject from rest.app.types import CRUSH_RULE, POOL, OSD, USER_REQUEST_COMPLETE, \ USER_REQUEST_SUBMITTED, OSD_IMPLEMENTED_COMMANDS, MON, OSD_MAP, \ SYNC_OBJECT_TYPES, ServiceId, severity_from_str, SEVERITIES, \ - OsdMap, Config, MonMap, MonStatus + OsdMap, Config, MonMap, MonStatus, SYNC_OBJECT_STR_TYPE from rest.logger import logger @@ -472,7 +472,11 @@ such as the cluster maps """ def retrieve(self, request, sync_type): - return Response(self.client.get_sync_object(sync_type)) + try: + sync_type_cls = SYNC_OBJECT_STR_TYPE[sync_type] + except KeyError: + return Response("Unknown type '{0}'".format(sync_type), status=404) + return Response(self.client.get_sync_object(sync_type_cls).data) def describe(self, request): return Response([s.str for s in SYNC_OBJECT_TYPES])