class SeverStatus: def __init__(self, conf): self.__redis = RedisWrapper(conf["redis"]) def on_get(self, req, resp): data = self.__redis.hgetall("node_data") resp.body = json.dumps(data if data else {"data": "No data"}) resp.content_type = "application/json" resp.status = falcon.HTTP_200
class NodeStatus: def __init__(self, conf): self.__redis = RedisWrapper(conf["redis"]) def on_get(self, req, resp, node): resp.body = self.get_data(node) resp.content_type = "application/json" resp.status = falcon.HTTP_200 def get_data(self, node): """ Gets the status information of the specified device :param node: Device code :return: json data """ data = self.__redis.hgetall("node_data") if data.get(node): url = "http://{}/status".format(data.get(node)['ip']) return requests.get(url).text else: return json.dumps({'data': "No data"})