summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2014-02-20 17:34:11 +0000
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2014-02-20 17:34:11 +0000
commit93859df18806f4edc1f225ebddd804d6e81d2c58 (patch)
treecc5dd84d48fb48f607b0bdc7d2282c46efa831b3
parentbd22adc77cb1172dfed88299fbb1bb5abc53d83f (diff)
downloadlorry-controller-93859df18806f4edc1f225ebddd804d6e81d2c58.tar.gz
Add lorries table to STATEDB, implement /1.0/list-queue
The queue will, for now, always be empty, of course.
-rw-r--r--ARCH13
-rwxr-xr-xlorry-controller-webapp11
2 files changed, 23 insertions, 1 deletions
diff --git a/ARCH b/ARCH
index 7a81fbb..4151076 100644
--- a/ARCH
+++ b/ARCH
@@ -335,6 +335,19 @@ whether WEBAPP is giving out jobs to run from the run-queue. This
value is controlled by `/1.0/start-queue` and `/1.0/stop-queue`
requests.
+The `lorries` table implements the run-queue: all the Lorry specs that
+WEBAPP knows about. It has the following columns:
+
+* `path` is the path of the git repository on the local Trove, i.e.,
+ the git repository to which Lorry will push. This is a unique
+ identifier. It is used, for example, to determine if a Lorry spec
+ is obsolete after a CONFGIT update.
+* `text` has the text of the Lorry spec. This may be read from a file
+ or generated by Lorry Controller itself. This text will be given to
+ Lorry when a job is run.
+* `generated` is set to 0 or 1, depending on if the Lorry came from an
+ actual `.lorry` file or was generated by Lorry Controller.
+
Implementation plan
===================
diff --git a/lorry-controller-webapp b/lorry-controller-webapp
index ab4e343..a8c7fdd 100755
--- a/lorry-controller-webapp
+++ b/lorry-controller-webapp
@@ -66,8 +66,12 @@ class StateDB(object):
def _initialise_tables(self):
c = self._conn.cursor()
c.execute('BEGIN TRANSACTION')
+
c.execute('CREATE TABLE IF NOT EXISTS running_queue (running INT)')
c.execute('INSERT INTO running_queue VALUES (0)')
+
+ c.execute('CREATE TABLE IF NOT EXISTS lorries (path TEXT, text TEXT, generated INT)')
+
self._conn.commit()
def get_running_queue(self):
@@ -86,6 +90,11 @@ class StateDB(object):
c.execute('UPDATE running_queue SET running = ?', str(new_value))
self._conn.commit()
+ def get_lorries(self):
+ self._open()
+ c = self._conn.cursor()
+ return c.execute('SELECT * FROM lorries')
+
class LorryControllerRoute(object):
@@ -208,7 +217,7 @@ class ListQueue(LorryControllerRoute):
def run(self, **kwargs):
return {
- 'queue': [],
+ 'queue': [row.path for row in self.statedb.get_lorries()],
}