import os, json, re from clusterman.config import CONF from clusterman.commands.node import get_node_in_group def info(): nodes=None if os.path.exists(CONF.NODE_FILE): with open(CONF.NODE_FILE) as f: nodes=json.load(f) cache=None if os.path.exists(CONF.CACHE_FILE): with open(CONF.CACHE_FILE) as f: cache=json.load(f) # Node print("Node count: ",end="") print("NA") if nodes==None else print(len(nodes)) # Groups print("Node groups: ",end="") if len(CONF["cluster"]["groups"]) > 0: content=list() for group in CONF["cluster"]["groups"].keys(): content.append("{}({})".format(group,len(get_node_in_group(group)))) print(", ".join(content)) else: print("NA") # Cache print("Last node scan: ",end="") if cache!=None and "last_scan" in CONF["cache"]: print(CONF["cache"]["last_scan"]) else: print("NA") # Plugins print("Plugins list:") for name in CONF["plugins"]: print(" "+name+":\t"+CONF["plugins"][name])