def fromJson(jsonObj): if 'class' in jsonObj: if jsonObj['class'] == 'Node': node = Node(jsonObj['server_id'], int(jsonObj['client_secure_port']), int(jsonObj['server_secure_port']), jsonObj['qualified_name'], jsonObj['hostname']) if "nodes" in jsonObj: node.setNodes(jsonObj['nodes']) if "priority" in jsonObj: node.setPriority(jsonObj['priority']) if "workerStates" in jsonObj: node.workerStates = jsonObj['workerStates'] return node if jsonObj['class'] == 'WorkerState': return WorkerState(jsonObj['host'], jsonObj['state'], jsonObj['workerId']) if jsonObj['class'] == 'Nodes': nodes = Nodes() for node in jsonObj['nodes'].itervalues(): nodes.addNode(node) return nodes if jsonObj['class'] == 'NodeConnectRequest': return NodeConnectRequest(jsonObj['server_id'], jsonObj['client_secure_port'], jsonObj['server_secure_port'], jsonObj['key'], jsonObj['qualified_name'], jsonObj['hostname']) return jsonObj
def fromJson(jsonObj): if "class" in jsonObj: if jsonObj["class"] == "Node": node = Node( jsonObj["server_id"], int(jsonObj["client_secure_port"]), int(jsonObj["server_secure_port"]), jsonObj["qualified_name"], jsonObj["hostname"], ) if "nodes" in jsonObj: node.setNodes(jsonObj["nodes"]) if "priority" in jsonObj: node.setPriority(jsonObj["priority"]) if "workerStates" in jsonObj: node.workerStates = jsonObj["workerStates"] return node if jsonObj["class"] == "WorkerState": return WorkerState(jsonObj["host"], jsonObj["state"], jsonObj["workerId"]) if jsonObj["class"] == "Nodes": nodes = Nodes() for node in jsonObj["nodes"].itervalues(): nodes.addNode(node) return nodes if jsonObj["class"] == "NodeConnectRequest": return NodeConnectRequest( jsonObj["server_id"], jsonObj["client_secure_port"], jsonObj["server_secure_port"], jsonObj["key"], jsonObj["qualified_name"], jsonObj["hostname"], ) return jsonObj