def clients(self, fscid_str): try: fscid = int(fscid_str) except ValueError: raise cherrypy.HTTPError(400, "Invalid filesystem id {0}".format(fscid_str)) try: fs_name = FsMap(global_instance().get( "fs_map")).get_filesystem(fscid)['mdsmap']['fs_name'] except NotFound: log.warning("Missing FSCID, dumping fsmap:\n{0}".format( json.dumps(global_instance().get("fs_map"), indent=2) )) raise cherrypy.HTTPError(404, "No filesystem with id {0}".format(fscid)) clients = self._clients(fscid) global_instance().log.debug(json.dumps(clients, indent=2)) content_data = { "clients": clients, "fs_name": fs_name, "fscid": fscid, "fs_url": get_prefixed_url("/filesystem/" + fscid_str + "/") } template = env.get_template("clients.html") return template.render( url_prefix = global_instance().url_prefix, ceph_version=global_instance().version, path_info=cherrypy.request.path_info, toplevel_data=json.dumps(self._toplevel_data(), indent=2), content_data=json.dumps(content_data, indent=2) )
def get_sync_object(self, object_type, path=None): if object_type == OsdMap: data = self.get("osd_map") assert data is not None data['tree'] = self.get("osd_map_tree") 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) elif object_type == Config: data = self.get("config") obj = Config( data) elif object_type == MonMap: data = self.get("mon_map") obj = MonMap(data) elif object_type == FsMap: data = self.get("fs_map") obj = FsMap(data) elif object_type == PgSummary: data = self.get("pg_summary") self.log.debug("JSON: {0}".format(data)) obj = PgSummary(data) elif object_type == Health: data = self.get("health") obj = Health(json.loads(data['json'])) elif object_type == MonStatus: data = self.get("mon_status") obj = MonStatus(json.loads(data['json'])) else: raise NotImplementedError(object_type) # TODO: move 'path' handling up into C++ land so that we only # Pythonize the part we're interested in if path: try: for part in path: if isinstance(obj, dict): obj = obj[part] else: obj = getattr(obj, part) except (AttributeError, KeyError): raise NotFound(object_type, path) return obj
def get_sync_object(self, object_type): if object_type == OsdMap: data = self.get("osd_map") assert data is not None data['tree'] = self.get("osd_map_tree") 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) elif object_type == Config: data = self.get("config") obj = Config( data) elif object_type == MonMap: data = self.get("mon_map") obj = MonMap(data) elif object_type == FsMap: data = self.get("fs_map") obj = FsMap(data) elif object_type == PgSummary: data = self.get("pg_summary") #self.log.debug("JSON: {0}".format(data)) obj = PgSummary(data) elif object_type == Health: data = self.get("health") obj = Health(json.loads(data['json'])) elif object_type == MonStatus: data = self.get("mon_status") obj = MonStatus(json.loads(data['json'])) elif object_type == ServiceMap: data = self.get("service_map") obj = ServiceMap(data) else: raise NotImplementedError(object_type) return obj