summaryrefslogtreecommitdiff
path: root/lorrycontroller/statedb.py
diff options
context:
space:
mode:
Diffstat (limited to 'lorrycontroller/statedb.py')
-rw-r--r--lorrycontroller/statedb.py72
1 files changed, 36 insertions, 36 deletions
diff --git a/lorrycontroller/statedb.py b/lorrycontroller/statedb.py
index 8659fc8..69538ed 100644
--- a/lorrycontroller/statedb.py
+++ b/lorrycontroller/statedb.py
@@ -39,11 +39,11 @@ class WrongNumberLorriesRunningJob(Exception):
(row_count, job_id))
-class TroveNotFoundError(Exception):
+class HostNotFoundError(Exception):
- def __init__(self, trovehost):
+ def __init__(self, host):
Exception.__init__(
- self, 'Trove %s not known in STATEDB' % trovehost)
+ self, 'Host %s not known in STATEDB' % host)
class StateDB(object):
@@ -59,7 +59,7 @@ class StateDB(object):
self.initial_lorries_fields = [
('path', 'TEXT PRIMARY KEY', None),
('text', 'TEXT', None),
- ('from_trovehost', 'TEXT', None),
+ ('from_trovehost', 'TEXT', 'from_host'),
('from_path', 'TEXT', None),
('running_job', 'INT', None),
('last_run', 'INT', None),
@@ -114,7 +114,7 @@ class StateDB(object):
c.execute('CREATE TABLE running_queue (running INT)')
c.execute('INSERT INTO running_queue VALUES (1)')
- # Table for known remote Troves.
+ # Table for known remote Hosts.
c.execute(
'CREATE TABLE troves ('
@@ -232,19 +232,19 @@ class StateDB(object):
self.get_cursor().execute(
'UPDATE running_queue SET running = ?', str(new_value))
- def get_trove_info(self, trovehost):
+ def get_host_info(self, host):
c = self.get_cursor()
c.execute(
'SELECT protocol, username, password, lorry_interval, '
'lorry_timeout, ls_interval, ls_last_run, '
'prefixmap, ignore, gitlab_token '
'FROM troves WHERE trovehost IS ?',
- (trovehost,))
+ (host,))
row = c.fetchone()
if row is None:
- raise lorrycontroller.TroveNotFoundError(trovehost)
+ raise lorrycontroller.HostNotFoundError(host)
return {
- 'trovehost': trovehost,
+ 'host': host,
'protocol': row[0],
'username': row[1],
'password': row[2],
@@ -257,16 +257,16 @@ class StateDB(object):
'gitlab_token': row[9]
}
- def add_trove(self, trovehost=None, protocol=None, username=None,
+ def add_host(self, host=None, protocol=None, username=None,
password=None, lorry_interval=None,
lorry_timeout=None, ls_interval=None,
prefixmap=None, ignore=None, gitlab_token=None):
logging.debug(
- 'StateDB.add_trove(%r,%r,%r,%r,%r,%r) called',
- trovehost, lorry_interval, lorry_timeout, ls_interval,
+ 'StateDB.add_host(%r,%r,%r,%r,%r,%r) called',
+ host, lorry_interval, lorry_timeout, ls_interval,
prefixmap, ignore)
- assert trovehost is not None
+ assert host is not None
assert protocol is not None
assert lorry_interval is not None
assert lorry_timeout is not None
@@ -276,8 +276,8 @@ class StateDB(object):
assert self.in_transaction
try:
- self.get_trove_info(trovehost)
- except lorrycontroller.TroveNotFoundError:
+ self.get_host_info(host)
+ except lorrycontroller.HostNotFoundError:
c = self.get_cursor()
c.execute(
'INSERT INTO troves '
@@ -286,7 +286,7 @@ class StateDB(object):
'ls_interval, ls_last_run, '
'prefixmap, ignore, gitlab_token) '
'VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
- (trovehost, protocol, username, password,
+ (host, protocol, username, password,
lorry_interval, lorry_timeout, ls_interval, 0,
prefixmap, ignore, gitlab_token))
else:
@@ -297,28 +297,28 @@ class StateDB(object):
'prefixmap=?, ignore=?, protocol=?, gitlab_token=? '
'WHERE trovehost IS ?',
(lorry_interval, lorry_timeout, ls_interval, prefixmap,
- ignore, protocol, gitlab_token, trovehost))
+ ignore, protocol, gitlab_token, host))
- def remove_trove(self, trovehost):
- logging.debug('StateDB.remove_trove(%r) called', trovehost)
+ def remove_host(self, host):
+ logging.debug('StateDB.remove_host(%r) called', host)
assert self.in_transaction
c = self.get_cursor()
- c.execute('DELETE FROM troves WHERE trovehost=?', (trovehost,))
+ c.execute('DELETE FROM troves WHERE trovehost=?', (host,))
- def get_troves(self):
+ def get_hosts(self):
c = self.get_cursor()
c.execute('SELECT trovehost FROM troves')
return [row[0] for row in c.fetchall()]
- def set_trove_ls_last_run(self, trovehost, ls_last_run):
+ def set_host_ls_last_run(self, host, ls_last_run):
logging.debug(
- 'StateDB.set_trove_ls_last_run(%r,%r) called',
- trovehost, ls_last_run)
+ 'StateDB.set_host_ls_last_run(%r,%r) called',
+ host, ls_last_run)
assert self.in_transaction
c = self.get_cursor()
c.execute(
'UPDATE troves SET ls_last_run=? WHERE trovehost=?',
- (ls_last_run, trovehost))
+ (ls_last_run, host))
def make_lorry_info_from_row(self, row):
result = dict(
@@ -348,27 +348,27 @@ class StateDB(object):
for row in c.execute(
'SELECT path FROM lorries ORDER BY (last_run + interval)')]
- def get_lorries_for_trove(self, trovehost):
+ def get_lorries_for_host(self, host):
c = self.get_cursor()
c.execute(
- 'SELECT path FROM lorries WHERE from_trovehost IS ?', (trovehost,))
+ 'SELECT path FROM lorries WHERE from_trovehost IS ?', (host,))
return [row[0] for row in c.fetchall()]
- def add_to_lorries(self, path=None, text=None, from_trovehost=None,
+ def add_to_lorries(self, path=None, text=None, from_host=None,
from_path=None, interval=None, timeout=None):
logging.debug(
'StateDB.add_to_lorries('
- 'path=%r, text=%r, from_trovehost=%r, interval=%s, '
+ 'path=%r, text=%r, from_host=%r, interval=%s, '
'timeout=%r called',
path,
text,
- from_trovehost,
+ from_host,
interval,
timeout)
assert path is not None
assert text is not None
- assert from_trovehost is not None
+ assert from_host is not None
assert from_path is not None
assert interval is not None
assert timeout is not None
@@ -383,7 +383,7 @@ class StateDB(object):
'(path, text, from_trovehost, from_path, last_run, interval, '
'lorry_timeout, running_job) '
'VALUES (?, ?, ?, ?, ?, ?, ?, ?)',
- (path, text, from_trovehost, from_path, 0,
+ (path, text, from_host, from_path, 0,
interval, timeout, None))
else:
c = self.get_cursor()
@@ -392,7 +392,7 @@ class StateDB(object):
'SET text=?, from_trovehost=?, from_path=?, interval=?, '
'lorry_timeout=? '
'WHERE path IS ?',
- (text, from_trovehost, from_path, interval, timeout, path))
+ (text, from_host, from_path, interval, timeout, path))
def remove_lorry(self, path):
logging.debug('StateDB.remove_lorry(%r) called', path)
@@ -400,12 +400,12 @@ class StateDB(object):
c = self.get_cursor()
c.execute('DELETE FROM lorries WHERE path IS ?', (path,))
- def remove_lorries_for_trovehost(self, trovehost):
+ def remove_lorries_for_host(self, host):
logging.debug(
- 'StateDB.remove_lorries_for_trovest(%r) called', trovehost)
+ 'StateDB.remove_lorries_for_host(%r) called', host)
assert self.in_transaction
c = self.get_cursor()
- c.execute('DELETE FROM lorries WHERE from_trovehost IS ?', (trovehost,))
+ c.execute('DELETE FROM lorries WHERE from_trovehost IS ?', (host,))
def set_running_job(self, path, job_id):
logging.debug(