]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: remove confusing SyncObject stuff 15577/head
authorJohn Spray <john.spray@redhat.com>
Thu, 8 Jun 2017 12:57:50 +0000 (08:57 -0400)
committerJohn Spray <john.spray@redhat.com>
Thu, 8 Jun 2017 15:43:20 +0000 (11:43 -0400)
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 <john.spray@redhat.com>
src/pybind/mgr/dashboard/module.py
src/pybind/mgr/dashboard/types.py

index 948449f9b50d80686dbdb58f8ee1b9624bb7313b..79077ca84c3b60eeec9bcbb4298e12b939980536 100644 (file)
@@ -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()
                 }
index 9ed2629e5020980b872ce21a840199bcce0c04a8..79122266dc7260a1ecde50d5b98f6f8c60ea3069 100644 (file)
@@ -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'