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 = parser.add_subparsers(dest="action", help="action to take")
|
||||||
spr_action.add_parser("classlist", help="show list of classes")
|
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 = spr_action.add_parser("new", help="create a node")
|
||||||
spr_new.add_argument("node", help="name of node to create")
|
spr_new.add_argument("node", help="name of node to create")
|
||||||
|
@ -105,6 +106,9 @@ def main():
|
||||||
else:
|
else:
|
||||||
print("No changes, exiting")
|
print("No changes, exiting")
|
||||||
|
|
||||||
|
elif args.action == "nodelist":
|
||||||
|
print(r.get(args.host.rstrip("/") + "/api/node").text)
|
||||||
|
|
||||||
elif args.action == "classlist":
|
elif args.action == "classlist":
|
||||||
print(r.get(args.host.rstrip("/") + "/api/class").text)
|
print(r.get(args.host.rstrip("/") + "/api/class").text)
|
||||||
|
|
||||||
|
|
|
@ -155,15 +155,19 @@ class NodesApi(object):
|
||||||
def __init__(self, nodedb):
|
def __init__(self, nodedb):
|
||||||
self.nodes = nodedb
|
self.nodes = nodedb
|
||||||
|
|
||||||
def GET(self, node):
|
def GET(self, node=None):
|
||||||
with self.nodes.db.transaction() as c:
|
with self.nodes.db.transaction() as c:
|
||||||
|
if not node:
|
||||||
|
yield yamldump({"nodes": list(c.root.nodes.keys())})
|
||||||
|
return
|
||||||
|
|
||||||
node = c.root.nodes[node]
|
node = c.root.nodes[node]
|
||||||
output = {
|
output = {
|
||||||
"body": yaml.load(node.body),
|
"body": yaml.load(node.body),
|
||||||
"parents": node.parent_names(),
|
"parents": node.parent_names(),
|
||||||
"classes": {clsname: yaml.load(clsa.conf) for clsname, clsa in node.classes.items()}
|
"classes": {clsname: yaml.load(clsa.conf) for clsname, clsa in node.classes.items()}
|
||||||
}
|
}
|
||||||
yield yamldump(output)
|
yield yamldump(output)
|
||||||
|
|
||||||
def PUT(self, node):
|
def PUT(self, node):
|
||||||
nodeyaml = yaml.load(cherrypy.request.body.read().decode('utf-8'))
|
nodeyaml = yaml.load(cherrypy.request.body.read().decode('utf-8'))
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -4,7 +4,7 @@ from setuptools import setup
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
__version__ = "0.0.0"
|
__version__ = "0.0.1"
|
||||||
with open(os.path.join(os.path.dirname(__file__), "requirements.txt")) as f:
|
with open(os.path.join(os.path.dirname(__file__), "requirements.txt")) as f:
|
||||||
__requirements__ = [line.strip() for line in f.readlines()]
|
__requirements__ = [line.strip() for line in f.readlines()]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue