From b48011d60b72f0b8a87340ad0e406a099a902032 Mon Sep 17 00:00:00 2001 From: John Spray Date: Thu, 8 Jun 2017 08:57:50 -0400 Subject: [PATCH] mgr/dashboard: remove confusing SyncObject stuff This was a hangover from when these wrapper classes were borrowed from Calamari, which used these versions/equality functions to work out when to go fetch data from the ceph cluster. Signed-off-by: John Spray --- src/pybind/mgr/dashboard/module.py | 15 ++++---- src/pybind/mgr/dashboard/types.py | 58 ++++++++---------------------- 2 files changed, 23 insertions(+), 50 deletions(-) diff --git a/src/pybind/mgr/dashboard/module.py b/src/pybind/mgr/dashboard/module.py index 948449f9b50d..79077ca84c3b 100644 --- a/src/pybind/mgr/dashboard/module.py +++ b/src/pybind/mgr/dashboard/module.py @@ -129,26 +129,26 @@ class Module(MgrModule): data['crush'] = self.get("osd_map_crush") data['crush_map_text'] = self.get("osd_map_crush_map_text") data['osd_metadata'] = self.get("osd_metadata") - obj = OsdMap(data['epoch'], data) + obj = OsdMap(data) elif object_type == Config: data = self.get("config") - obj = Config(0, data) + obj = Config( data) elif object_type == MonMap: data = self.get("mon_map") - obj = MonMap(data['epoch'], data) + obj = MonMap(data) elif object_type == FsMap: data = self.get("fs_map") - obj = FsMap(data['epoch'], data) + obj = FsMap(data) elif object_type == PgSummary: data = self.get("pg_summary") self.log.debug("JSON: {0}".format(data)) - obj = PgSummary(0, data) + obj = PgSummary(data) elif object_type == Health: data = self.get("health") - obj = Health(0, json.loads(data['json'])) + obj = Health(json.loads(data['json'])) elif object_type == MonStatus: data = self.get("mon_status") - obj = MonStatus(0, json.loads(data['json'])) + obj = MonStatus(json.loads(data['json'])) else: raise NotImplementedError(object_type) @@ -577,6 +577,7 @@ class Module(MgrModule): ) def _servers(self): + servers = global_instance().list_servers() return { 'servers': global_instance().list_servers() } diff --git a/src/pybind/mgr/dashboard/types.py b/src/pybind/mgr/dashboard/types.py index 9ed2629e5020..79122266dc72 100644 --- a/src/pybind/mgr/dashboard/types.py +++ b/src/pybind/mgr/dashboard/types.py @@ -33,47 +33,19 @@ def memoize(function): return wrapper -class SyncObject(object): - """ - An object from a Ceph cluster that we are maintaining - a copy of on the Calamari server. - - We wrap these JSON-serializable objects in a python object to: - - - Decorate them with things like id-to-entry dicts - - Have a generic way of seeing the version of an object +OSD_FLAGS = ('pause', 'noup', 'nodown', 'noout', 'noin', 'nobackfill', + 'norecover', 'noscrub', 'nodeep-scrub') - """ - def __init__(self, version, data): - self.version = version +class DataWrapper(object): + def __init__(self, data): self.data = data - @classmethod - def cmp(cls, a, b): - """ - Slight bastardization of cmp. Takes two versions, - and returns a cmp-like value, except that if versions - are not sortable we only return 0 or 1. - """ - # Version is something unique per version (like a hash) - return 1 if a != b else 0 - - -class VersionedSyncObject(SyncObject): - @classmethod - def cmp(cls, a, b): - # Version is something numeric like an epoch - return cmp(a, b) - - -OSD_FLAGS = ('pause', 'noup', 'nodown', 'noout', 'noin', 'nobackfill', 'norecover', 'noscrub', 'nodeep-scrub') - -class OsdMap(VersionedSyncObject): +class OsdMap(DataWrapper): str = OSD_MAP - def __init__(self, version, data): - super(OsdMap, self).__init__(version, data) + def __init__(self, data): + super(OsdMap, self).__init__(data) if data is not None: self.osds_by_id = dict([(o['osd'], o) for o in data['osds']]) self.pools_by_id = dict([(p['pool'], p) for p in data['pools']]) @@ -204,37 +176,37 @@ class OsdMap(VersionedSyncObject): return osds -class FsMap(VersionedSyncObject): +class FsMap(DataWrapper): str = 'fs_map' -class MonMap(VersionedSyncObject): +class MonMap(DataWrapper): str = 'mon_map' -class MonStatus(VersionedSyncObject): +class MonStatus(DataWrapper): str = 'mon_status' - def __init__(self, version, data): - super(MonStatus, self).__init__(version, data) + def __init__(self, data): + super(MonStatus, self).__init__(data) if data is not None: self.mons_by_rank = dict([(m['rank'], m) for m in data['monmap']['mons']]) else: self.mons_by_rank = {} -class PgSummary(SyncObject): +class PgSummary(DataWrapper): """ A summary of the state of PGs in the cluster, reported by pool and by OSD. """ str = 'pg_summary' -class Health(SyncObject): +class Health(DataWrapper): str = 'health' -class Config(SyncObject): +class Config(DataWrapper): str = 'config' -- 2.47.3