From 2c0565e265f2141002f955eca880b71c1487f43a Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Thu, 20 Feb 2014 15:13:48 +0000 Subject: Add start of CONFGIT reading --- lorry-controller-webapp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/lorry-controller-webapp b/lorry-controller-webapp index e37420b..f1d6456 100755 --- a/lorry-controller-webapp +++ b/lorry-controller-webapp @@ -17,6 +17,7 @@ import logging +import json import os import sqlite3 import time @@ -171,6 +172,41 @@ class StatusHTML(LorryControllerRoute): return renderer.render_status_as_html(status) +class ReadConfiguration(LorryControllerRoute): + + http_method = 'GET' + path = '/1.0/read-configuration' + + def run(self, **kwargs): + # FIXME: This doesn't update the git repo from upstream, yet. + + filename = os.path.join( + self.app_settings['configuration-directory'], + 'trove.conf') + with open(filename) as f: + conf_obj = json.load(f) + troves = [x for x in conf_obj if x['type'] == 'trove'] + lorries = [x for x in conf_obj if x['type'] == 'lorries'] + + # FIXME: put the troves and the lorries into STATEDB, but + # don't generate lorries from troves, yet. Don't, in fact, + # scan for local lorries either, yet. Just make sure STATEDB + # has the right tables and columns so that /1.0/list-queue + # will return something reasonable-looking. + return { 'troves': troves, 'lorries': lorries } + + +class ListQueue(LorryControllerRoute): + + http_method = 'GET' + path = '/1.0/list-queue' + + def run(self, **kwargs): + return { + 'queue': [], + } + + class StartQueue(LorryControllerRoute): http_method = 'GET' @@ -199,6 +235,12 @@ class WEBAPP(cliapp.Application): 'use FILE as the state database', metavar='FILE') + self.settings.string( + ['configuration-directory'], + 'use DIR as the configuration directory', + metavar='DIR', + default='.') + self.settings.string( ['status-html'], 'write a static HTML page to FILE to describe overall status', -- cgit v1.2.1