diff --git a/nodepool/status.py b/nodepool/status.py index 033ab9fd8..71f3f6318 100755 --- a/nodepool/status.py +++ b/nodepool/status.py @@ -106,6 +106,23 @@ def node_list_json(zk): return json.dumps([node.toDict() for node in zk.nodeIterator()]) +def label_list(zk): + labels = set() + for node in zk.nodeIterator(): + labels.add(node.type) + t = PrettyTable(["Label"]) + for label in sorted(labels.keys()): + t.add_row((label,)) + return str(t) + + +def label_list_json(zk): + labels = set() + for node in zk.nodeIterator(): + labels.add(node.type) + return json.dumps(labels) + + def dib_image_list(zk): t = PrettyTable(["ID", "Image", "Builder", "Formats", "State", "Age"]) diff --git a/nodepool/webapp.py b/nodepool/webapp.py index 385b9871b..f6c7ef795 100644 --- a/nodepool/webapp.py +++ b/nodepool/webapp.py @@ -87,6 +87,10 @@ class WebApp(threading.Thread): output = status.node_list(self.nodepool.getZK()) elif path == '/node-list.json': output = status.node_list_json(self.nodepool.getZK()) + elif path == '/label-list': + output = status.label_list(self.nodepool.getZK()) + elif path == '/label-list.json': + output = status.label_list_json(self.nodepool.getZK()) else: return None return self.cache.put(path, output)