summaryrefslogtreecommitdiff
path: root/lorrycontroller
diff options
context:
space:
mode:
authorBen Hutchings <ben.hutchings@codethink.co.uk>2020-05-06 22:45:42 +0100
committerBen Hutchings <ben.hutchings@codethink.co.uk>2020-06-01 15:26:47 +0100
commit14eac038d2fa7ac4845135a827ca8c2f2bab559c (patch)
tree516737a7c9f8bc176fee1f5e3b4ec4dd28ce9550 /lorrycontroller
parent5963f66a434d49a4a6e8dfc02cfe256c88d1e1e6 (diff)
downloadlorry-controller-14eac038d2fa7ac4845135a827ca8c2f2bab559c.tar.gz
Update terminology for hosts in internal APIs and web templates
This is intended to replace all uses of "Trove" that should really be "Downstream Host" or "Upstream Host", except in the database schema and the REST API (which will probably change later). * ARCH: Update example code to reflect API name change * yarns.webapp: Update test descriptions and uses of internal APIs * units: Update and rename the ls-troves units (although they still use the ls-troves endpoint for now) Some references that really are specific to Trove integration are retained. Related to #3.
Diffstat (limited to 'lorrycontroller')
-rw-r--r--lorrycontroller/__init__.py4
-rw-r--r--lorrycontroller/givemejob.py8
-rw-r--r--lorrycontroller/lsupstreams.py (renamed from lorrycontroller/lstroves.py)127
-rw-r--r--lorrycontroller/readconf.py33
-rw-r--r--lorrycontroller/statedb.py72
-rw-r--r--lorrycontroller/status.py22
6 files changed, 132 insertions, 134 deletions
diff --git a/lorrycontroller/__init__.py b/lorrycontroller/__init__.py
index c5bf0ad..64c4a6f 100644
--- a/lorrycontroller/__init__.py
+++ b/lorrycontroller/__init__.py
@@ -18,7 +18,7 @@ from .statedb import (
StateDB,
LorryNotFoundError,
WrongNumberLorriesRunningJob,
- TroveNotFoundError)
+ HostNotFoundError)
from .route import LorryControllerRoute
from .readconf import ReadConfiguration
from .status import Status, StatusHTML, StatusRenderer
@@ -34,7 +34,7 @@ from .listjobs import ListAllJobs, ListAllJobsHTML
from .showjob import ShowJob, ShowJobHTML, JobShower
from .removeghostjobs import RemoveGhostJobs
from .removejob import RemoveJob
-from .lstroves import LsTroves, ForceLsTrove
+from .lsupstreams import LsUpstreams, ForceLsUpstream
from .pretendtime import PretendTime
from .maxjobs import GetMaxJobs, SetMaxJobs
from .gitano import (
diff --git a/lorrycontroller/givemejob.py b/lorrycontroller/givemejob.py
index a893036..9d4d4d2 100644
--- a/lorrycontroller/givemejob.py
+++ b/lorrycontroller/givemejob.py
@@ -37,7 +37,7 @@ class GiveMeJob(lorrycontroller.LorryControllerRoute):
for lorry_info in lorry_infos:
if self.ready_to_run(lorry_info, now):
self.create_repository(statedb, lorry_info)
- if lorry_info['from_trovehost']:
+ if lorry_info['from_host']:
self.copy_repository_metadata(statedb, lorry_info)
self.give_job_to_minion(statedb, lorry_info, now)
logging.info(
@@ -120,14 +120,14 @@ class GiveMeJob(lorrycontroller.LorryControllerRoute):
def copy_repository_metadata(self, statedb, lorry_info):
'''Copy project.head and project.description to the local Trove.'''
- assert lorry_info['from_trovehost']
+ assert lorry_info['from_host']
assert lorry_info['from_path']
if self.app_settings['git-server-type'] != 'gitano':
# FIXME: would be good to have this info in Gerrit too
return
- remote = lorrycontroller.new_gitano_command(statedb, lorry_info['from_trovehost'])
+ remote = lorrycontroller.new_gitano_command(statedb, lorry_info['from_host'])
local = lorrycontroller.LocalTroveGitanoCommand()
try:
@@ -142,7 +142,7 @@ class GiveMeJob(lorrycontroller.LorryControllerRoute):
if not local_config['project.description']:
desc = '{host}: {desc}'.format(
- host=lorry_info['from_trovehost'],
+ host=lorry_info['from_host'],
desc=remote_config['project.description'])
local.set_gitano_config(
lorry_info['path'],
diff --git a/lorrycontroller/lstroves.py b/lorrycontroller/lsupstreams.py
index 34648cb..a64a496 100644
--- a/lorrycontroller/lstroves.py
+++ b/lorrycontroller/lsupstreams.py
@@ -33,49 +33,49 @@ class ServerLsError(Exception):
self.remote_host = remote_host
-class TroveRepositoryLister(object):
+class HostRepositoryLister(object):
def __init__(self, app_settings, route):
self.app_settings = app_settings
self.route = route
- def list_trove_into_statedb(self, statedb, trove_info):
- remote_paths = self.ls(statedb, trove_info)
- remote_paths = self.skip_ignored_repos(trove_info, remote_paths)
+ def list_host_into_statedb(self, statedb, host_info):
+ remote_paths = self.ls(statedb, host_info)
+ remote_paths = self.skip_ignored_repos(host_info, remote_paths)
repo_map = self.map_remote_repos_to_local_ones(
- trove_info, remote_paths)
+ host_info, remote_paths)
with statedb:
- self.update_lorries_for_trove(statedb, trove_info, repo_map)
+ self.update_lorries_for_host(statedb, host_info, repo_map)
now = statedb.get_current_time()
- statedb.set_trove_ls_last_run(trove_info['trovehost'], now)
+ statedb.set_host_ls_last_run(host_info['host'], now)
- def ls(self, statedb, trove_info):
- if self.app_settings['debug-fake-trove']:
- repo_paths = self.get_fake_ls_output(trove_info)
+ def ls(self, statedb, host_info):
+ if self.app_settings['debug-fake-upstream-host']:
+ repo_paths = self.get_fake_ls_output(host_info)
else:
- repo_paths = self.get_real_ls_output(statedb, trove_info)
+ repo_paths = self.get_real_ls_output(statedb, host_info)
return repo_paths
- def get_fake_ls_output(self, trove_info):
- trovehost = trove_info['trovehost']
- for item in self.app_settings['debug-fake-trove']:
- host, path = item.split('=', 1)
- if host == trovehost:
+ def get_fake_ls_output(self, host_info):
+ host = host_info['host']
+ for item in self.app_settings['debug-fake-upstream-host']:
+ fake_host, path = item.split('=', 1)
+ if fake_host == host:
with open(path) as f:
obj = json.load(f)
return obj['ls-output']
return None
- def get_real_ls_output(self, statedb, trove_info):
- gitlab_token = trove_info.get('gitlab_token')
+ def get_real_ls_output(self, statedb, host_info):
+ gitlab_token = host_info.get('gitlab_token')
if gitlab_token:
return lorrycontroller.Gitlab(
- trove_info['trovehost'], gitlab_token).list_projects()
+ host_info['host'], gitlab_token).list_projects()
gitano = lorrycontroller.new_gitano_command(
- statedb, trove_info['trovehost'])
+ statedb, host_info['host'])
output = gitano.ls()
return self.parse_ls_output(output)
@@ -87,8 +87,8 @@ class TroveRepositoryLister(object):
repo_paths.append(words[1])
return repo_paths
- def skip_ignored_repos(self, trovehost, repo_paths):
- ignored_patterns = json.loads(trovehost['ignore'])
+ def skip_ignored_repos(self, host, repo_paths):
+ ignored_patterns = json.loads(host['ignore'])
ignored_paths = set()
for pattern in ignored_patterns:
@@ -96,9 +96,9 @@ class TroveRepositoryLister(object):
return set(repo_paths).difference(ignored_paths)
- def map_remote_repos_to_local_ones(self, trove_info, remote_paths):
+ def map_remote_repos_to_local_ones(self, host_info, remote_paths):
'''Return a dict that maps each remote repo path to a local one.'''
- prefixmap = self.parse_prefixmap(trove_info['prefixmap'])
+ prefixmap = self.parse_prefixmap(host_info['prefixmap'])
repo_map = {}
for remote_path in remote_paths:
local_path = self.map_one_remote_repo_to_local_one(
@@ -124,29 +124,29 @@ class TroveRepositoryLister(object):
def path_starts_with_prefix(self, path, prefix):
return path.startswith(prefix) and path[len(prefix):].startswith('/')
- def update_lorries_for_trove(self, statedb, trove_info, repo_map):
- trovehost = trove_info['trovehost']
+ def update_lorries_for_host(self, statedb, host_info, repo_map):
+ host = host_info['host']
for remote_path, local_path in list(repo_map.items()):
- lorry = self.construct_lorry(trove_info, local_path, remote_path)
+ lorry = self.construct_lorry(host_info, local_path, remote_path)
statedb.add_to_lorries(
path=local_path,
text=json.dumps(lorry, indent=4),
- from_trovehost=trovehost,
+ from_host=host,
from_path=remote_path,
- interval=trove_info['lorry_interval'],
- timeout=trove_info['lorry_timeout'])
+ interval=host_info['lorry_interval'],
+ timeout=host_info['lorry_timeout'])
- all_local_paths = set(statedb.get_lorries_for_trove(trovehost))
+ all_local_paths = set(statedb.get_lorries_for_host(host))
wanted_local_paths = set(repo_map.values())
delete_local_paths = all_local_paths.difference(wanted_local_paths)
for local_path in delete_local_paths:
statedb.remove_lorry(local_path)
- def construct_lorry(self, trove_info, local_path, remote_path):
+ def construct_lorry(self, host_info, local_path, remote_path):
return {
local_path: {
'type': 'git',
- 'url': self.construct_lorry_url(trove_info, remote_path),
+ 'url': self.construct_lorry_url(host_info, remote_path),
'refspecs': [
"+refs/heads/*",
"+refs/tags/*",
@@ -154,27 +154,26 @@ class TroveRepositoryLister(object):
}
}
- def construct_lorry_url(self, trove_info, remote_path):
- gitlab_token = trove_info.get('gitlab_token')
+ def construct_lorry_url(self, host_info, remote_path):
+ gitlab_token = host_info.get('gitlab_token')
if gitlab_token:
return lorrycontroller.Gitlab(
- trove_info['trovehost'], gitlab_token).get_project_url(
- trove_info['protocol'], remote_path)
+ host_info['host'], gitlab_token).get_project_url(
+ host_info['protocol'], remote_path)
- vars = dict(trove_info)
+ vars = dict(host_info)
vars['remote_path'] = remote_path
patterns = {
- 'ssh': 'ssh://git@{trovehost}/{remote_path}',
- 'https':
- 'https://{username}:{password}@{trovehost}/git/{remote_path}',
- 'http': 'http://{trovehost}/git/{remote_path}',
+ 'ssh': 'ssh://git@{host}/{remote_path}',
+ 'https':'https://{username}:{password}@{host}/git/{remote_path}',
+ 'http': 'http://{host}/git/{remote_path}',
}
- return patterns[trove_info['protocol']].format(**vars)
+ return patterns[host_info['protocol']].format(**vars)
-class ForceLsTrove(lorrycontroller.LorryControllerRoute):
+class ForceLsUpstream(lorrycontroller.LorryControllerRoute):
http_method = 'POST'
path = '/1.0/force-ls-trove'
@@ -182,20 +181,20 @@ class ForceLsTrove(lorrycontroller.LorryControllerRoute):
def run(self, **kwargs):
logging.info('%s %s called', self.http_method, self.path)
- trovehost = bottle.request.forms.trovehost
+ host = bottle.request.forms.host
statedb = self.open_statedb()
- lister = TroveRepositoryLister(self.app_settings, self)
- trove_info = statedb.get_trove_info(trovehost)
+ lister = HostRepositoryLister(self.app_settings, self)
+ host_info = statedb.get_host_info(host)
try:
- updated = lister.list_trove_into_statedb(statedb, trove_info)
+ updated = lister.list_host_into_statedb(statedb, host_info)
except ServerLsError as e:
raise bottle.abort(500, str(e))
return { 'updated-troves': updated }
-class LsTroves(lorrycontroller.LorryControllerRoute):
+class LsUpstreams(lorrycontroller.LorryControllerRoute):
http_method = 'POST'
path = '/1.0/ls-troves'
@@ -204,30 +203,30 @@ class LsTroves(lorrycontroller.LorryControllerRoute):
logging.info('%s %s called', self.http_method, self.path)
statedb = self.open_statedb()
- lister = TroveRepositoryLister(self.app_settings, self)
+ lister = HostRepositoryLister(self.app_settings, self)
- trove_infos = self.get_due_troves(statedb)
- for trove_info in trove_infos:
- logging.info('Trove %r is due an ls', trove_info['trovehost'])
+ host_infos = self.get_due_hosts(statedb)
+ for host_info in host_infos:
+ logging.info('Host %r is due an ls', host_info['host'])
try:
- lister.list_trove_into_statedb(statedb, trove_info)
+ lister.list_host_into_statedb(statedb, host_info)
except ServerLsError as e:
bottle.abort(500, str(e))
return {
- 'updated-troves': [trove_info['trovehost'] for trove_info in trove_infos],
+ 'updated-troves': [host_info['host'] for host_info in host_infos],
}
- def get_due_troves(self, statedb):
- trove_infos = [
- statedb.get_trove_info(trovehost)
- for trovehost in statedb.get_troves()]
+ def get_due_hosts(self, statedb):
+ host_infos = [
+ statedb.get_host_info(host)
+ for host in statedb.get_hosts()]
now = statedb.get_current_time()
return [
- trove_info
- for trove_info in trove_infos
- if self.is_due(trove_info, now)]
+ host_info
+ for host_info in host_infos
+ if self.is_due(host_info, now)]
- def is_due(self, trove_info, now):
- ls_due = trove_info['ls_last_run'] + trove_info['ls_interval']
+ def is_due(self, host_info, now):
+ ls_due = host_info['ls_last_run'] + host_info['ls_interval']
return ls_due <= now
diff --git a/lorrycontroller/readconf.py b/lorrycontroller/readconf.py
index 4e162a9..b8b4a87 100644
--- a/lorrycontroller/readconf.py
+++ b/lorrycontroller/readconf.py
@@ -61,7 +61,7 @@ class ReadConfiguration(lorrycontroller.LorryControllerRoute):
statedb = self.open_statedb()
with statedb:
lorries_to_remove = set(statedb.get_lorries_paths())
- troves_to_remove = set(statedb.get_troves())
+ hosts_to_remove = set(statedb.get_hosts())
for section in conf_obj:
if not 'type' in section:
@@ -71,12 +71,12 @@ class ReadConfiguration(lorrycontroller.LorryControllerRoute):
statedb, section)
lorries_to_remove = lorries_to_remove.difference(added)
elif section['type'] in ('trove', 'troves', 'gitlab'):
- self.add_trove(statedb, section)
- trovehost = section.get('host') or section['trovehost']
- if trovehost in troves_to_remove:
- troves_to_remove.remove(trovehost)
+ self.add_host(statedb, section)
+ host = section.get('host') or section['trovehost']
+ if host in hosts_to_remove:
+ hosts_to_remove.remove(host)
lorries_to_remove = lorries_to_remove.difference(
- statedb.get_lorries_for_trove(trovehost))
+ statedb.get_lorries_for_host(host))
else:
logging.error(
'Unknown section in configuration: %r', section)
@@ -87,9 +87,9 @@ class ReadConfiguration(lorrycontroller.LorryControllerRoute):
for path in lorries_to_remove:
statedb.remove_lorry(path)
- for trovehost in troves_to_remove:
- statedb.remove_trove(trovehost)
- statedb.remove_lorries_for_trovehost(trovehost)
+ for host in hosts_to_remove:
+ statedb.remove_host(host)
+ statedb.remove_lorries_for_host(host)
if 'redirect' in bottle.request.forms:
bottle.redirect(bottle.request.forms.redirect)
@@ -215,7 +215,7 @@ class ReadConfiguration(lorrycontroller.LorryControllerRoute):
old_lorry_info = None
statedb.add_to_lorries(
- path=path, text=text, from_trovehost='', from_path='',
+ path=path, text=text, from_host='', from_path='',
interval=interval, timeout=timeout)
added_paths.add(path)
@@ -282,7 +282,7 @@ class ReadConfiguration(lorrycontroller.LorryControllerRoute):
new_obj = { path: obj }
return json.dumps(new_obj, indent=4)
- def add_trove(self, statedb, section):
+ def add_host(self, statedb, section):
username = None
password = None
if 'auth' in section:
@@ -294,8 +294,8 @@ class ReadConfiguration(lorrycontroller.LorryControllerRoute):
if section['type'] == 'gitlab':
gitlab_token = section['private-token']
- statedb.add_trove(
- trovehost=section.get('host') or section['trovehost'],
+ statedb.add_host(
+ host=section.get('host') or section['trovehost'],
protocol=section['protocol'],
username=username,
password=password,
@@ -326,7 +326,7 @@ class LorryControllerConfValidator(object):
raise ValidationError(
'section without type: %r' % section)
elif section['type'] in ('trove', 'troves'):
- self._check_troves_section(section)
+ self._check_host_section(section)
elif section['type'] == 'lorries':
self._check_lorries_section(section)
elif section['type'] == 'gitlab':
@@ -350,11 +350,10 @@ class LorryControllerConfValidator(object):
raise ValidationError('all items must be dicts')
def _check_gitlab_section(self, section):
- # gitlab section inherits trove configurations, perform the same checks.
- self._check_troves_section(section)
+ self._check_host_section(section)
self._check_has_required_fields(section, ['private-token'])
- def _check_troves_section(self, section):
+ def _check_host_section(self, section):
if not any(i in ('trovehost', 'host') for i in section):
self._check_has_required_fields(section, ['host'])
self._check_has_required_fields(
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(
diff --git a/lorrycontroller/status.py b/lorrycontroller/status.py
index 2e6334d..cca8e8a 100644
--- a/lorrycontroller/status.py
+++ b/lorrycontroller/status.py
@@ -36,7 +36,7 @@ class StatusRenderer(object):
'timestamp':
time.strftime('%Y-%m-%d %H:%M:%S UTC', time.gmtime(now)),
'run_queue': self.get_run_queue(statedb),
- 'troves': self.get_troves(statedb),
+ 'hosts': self.get_hosts(statedb),
'warning_msg': '',
'max_jobs': self.get_max_jobs(statedb),
'links': True,
@@ -148,20 +148,20 @@ class StatusRenderer(object):
return ' '.join(result)
- def get_troves(self, statedb):
- troves = []
- for trovehost in statedb.get_troves():
- trove_info = statedb.get_trove_info(trovehost)
+ def get_hosts(self, statedb):
+ hosts = []
+ for host in statedb.get_hosts():
+ host_info = statedb.get_host_info(host)
- trove_info['ls_interval_nice'] = self.format_secs_nicely(
- trove_info['ls_interval'])
+ host_info['ls_interval_nice'] = self.format_secs_nicely(
+ host_info['ls_interval'])
- ls_due = trove_info['ls_last_run'] + trove_info['ls_interval']
+ ls_due = host_info['ls_last_run'] + host_info['ls_interval']
now = int(statedb.get_current_time())
- trove_info['ls_due_nice'] = self.format_due_nicely(ls_due, now)
+ host_info['ls_due_nice'] = self.format_due_nicely(ls_due, now)
- troves.append(trove_info)
- return troves
+ hosts.append(host_info)
+ return hosts
def get_max_jobs(self, statedb):
max_jobs = statedb.get_max_jobs()