node listing

This commit is contained in:
dave 2019-04-09 21:45:19 -07:00
parent 5c15ae1bbc
commit 0b3b766ec6
3 changed files with 11 additions and 3 deletions

View File

@ -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)

View File

@ -155,8 +155,12 @@ 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),

View File

@ -4,7 +4,7 @@ from setuptools import setup
import os
__version__ = "0.0.0"
__version__ = "0.0.1"
with open(os.path.join(os.path.dirname(__file__), "requirements.txt")) as f:
__requirements__ = [line.strip() for line in f.readlines()]