Skip to content

Commit

Permalink
new node registration
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Sep 13, 2016
1 parent f2972de commit 5edc054
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/colony_print/controllers/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ class NodeController(appier.Controller):
def list(self):
return self.owner.nodes

@appier.route("/nodes/<str:id>", "POST", json = True)
def create(self, id):
node = appier.get_object()
self.owner.nodes[id] = node

@appier.route("/nodes/<str:id>", "GET", json = True)
def show(self, id, printer):
return self.owner.nodes[id]

@appier.route("/nodes/<str:id>/register", "POST", json = True)
def register(self, id):
node = appier.get_object()
self.owner.nodes[id] = node

@appier.route("/nodes/<str:id>/jobs", "GET", json = True)
def jobs(self, id):
self.request.set_content_type("application/json")
Expand Down
32 changes: 28 additions & 4 deletions src/colony_print/node.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,32 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

import logging

import appier

BASE_URL = "https://colony_print.bemisc.com/"

def loop():
logging.basicConfig(level = logging.DEBUG)

base_url = appier.conf("BASE_URL", BASE_URL)
node_id = appier.conf("NODE_ID", "node")
node_name = appier.conf("NODE_NAME", "node")
node_location = appier.conf("NODE_LOCATION", "undefined")

while True:
logging.info("Submitting node information")
appier.post(
base_url + "nodes/%s" % node_id,
data_j = dict(
name = node_name,
location = node_location
)
)
logging.info("Retrieving jobs for node '%s'" % node_id)
jobs = appier.get(base_url + "nodes/%s/jobs" % node_id)
logging.info("Retrieved %d jobs for node '%s'" % (len(jobs), node_id))

if __name__ == "__main__":
# @todo must connect with WS to the Server
# must wait for printing operations
# alternativelty may use
pass
loop()

0 comments on commit 5edc054

Please sign in to comment.