node listing
This commit is contained in:
parent
5c15ae1bbc
commit
0b3b766ec6
|
@ -55,6 +55,7 @@ def main():
|
|||
|
||||
spr_action = parser.add_subparsers(dest="action", help="action to take")
|
||||
spr_action.add_parser("classlist", help="show list of classes")
|
||||
spr_action.add_parser("nodelist", help="show list of nodes")
|
||||
|
||||
spr_new = spr_action.add_parser("new", help="create a node")
|
||||
spr_new.add_argument("node", help="name of node to create")
|
||||
|
@ -105,6 +106,9 @@ def main():
|
|||
else:
|
||||
print("No changes, exiting")
|
||||
|
||||
elif args.action == "nodelist":
|
||||
print(r.get(args.host.rstrip("/") + "/api/node").text)
|
||||
|
||||
elif args.action == "classlist":
|
||||
print(r.get(args.host.rstrip("/") + "/api/class").text)
|
||||
|
||||
|
|
|
@ -155,15 +155,19 @@ class NodesApi(object):
|
|||
def __init__(self, nodedb):
|
||||
self.nodes = nodedb
|
||||
|
||||
def GET(self, node):
|
||||
def GET(self, node=None):
|
||||
with self.nodes.db.transaction() as c:
|
||||
if not node:
|
||||
yield yamldump({"nodes": list(c.root.nodes.keys())})
|
||||
return
|
||||
|
||||
node = c.root.nodes[node]
|
||||
output = {
|
||||
"body": yaml.load(node.body),
|
||||
"parents": node.parent_names(),
|
||||
"classes": {clsname: yaml.load(clsa.conf) for clsname, clsa in node.classes.items()}
|
||||
}
|
||||
yield yamldump(output)
|
||||
yield yamldump(output)
|
||||
|
||||
def PUT(self, node):
|
||||
nodeyaml = yaml.load(cherrypy.request.body.read().decode('utf-8'))
|
||||
|
|
Loading…
Reference in New Issue