Skip to content

Commit

Permalink
pybind/mgr/rest: fix "sync_object" API endpoint
Browse files Browse the repository at this point in the history
Signed-off-by: John Spray <john.spray@redhat.com>
  • Loading branch information
John Spray committed Sep 29, 2016
1 parent 592bb9c commit 9a33766
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/pybind/mgr/rest/app/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def __str__(self):


# 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'
Expand Down
8 changes: 6 additions & 2 deletions src/pybind/mgr/rest/app/views/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
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
Expand Down Expand Up @@ -472,7 +472,11 @@ class SyncObject(RPCViewSet):
"""

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])
Expand Down

0 comments on commit 9a33766

Please sign in to comment.