Add /node-list to the webapp

This change adds /node-list and /node-list.json to enable listing
current node list over http.

Change-Id: I256ebbba8692e78827a9104b08b433aafa26c71c
This commit is contained in:
Tristan Cacqueray 2017-09-01 10:57:46 +00:00 committed by mhuin
parent b7efdb36f2
commit f2ad9ee0bc
2 changed files with 8 additions and 0 deletions

View File

@ -102,6 +102,10 @@ def node_list(zk, node_id=None, detail=False):
return str(t)
def node_list_json(zk):
return json.dumps([node.toDict() for node in zk.nodeIterator()])
def dib_image_list(zk):
t = PrettyTable(["ID", "Image", "Builder", "Formats",
"State", "Age"])

View File

@ -83,6 +83,10 @@ class WebApp(threading.Thread):
output = status.dib_image_list(self.nodepool.getZK())
elif path == '/dib-image-list.json':
output = status.dib_image_list_json(self.nodepool.getZK())
elif path == '/node-list':
output = status.node_list(self.nodepool.getZK())
elif path == '/node-list.json':
output = status.node_list_json(self.nodepool.getZK())
else:
return None
return self.cache.put(path, output)