diff --git a/nodepupper/cli.py b/nodepupper/cli.py index ad6eb98..437ba50 100644 --- a/nodepupper/cli.py +++ b/nodepupper/cli.py @@ -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) diff --git a/nodepupper/daemon.py b/nodepupper/daemon.py index 5d0832e..c0aca8a 100644 --- a/nodepupper/daemon.py +++ b/nodepupper/daemon.py @@ -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')) diff --git a/setup.py b/setup.py index 72cafde..f89b109 100644 --- a/setup.py +++ b/setup.py @@ -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()]