diff options
-rw-r--r-- | ARCH | 6 | ||||
-rwxr-xr-x | lorry-controller-webapp | 8 | ||||
-rw-r--r-- | lorrycontroller/__init__.py | 4 | ||||
-rw-r--r-- | lorrycontroller/givemejob.py | 8 | ||||
-rw-r--r-- | lorrycontroller/lsupstreams.py (renamed from lorrycontroller/lstroves.py) | 127 | ||||
-rw-r--r-- | lorrycontroller/readconf.py | 33 | ||||
-rw-r--r-- | lorrycontroller/statedb.py | 72 | ||||
-rw-r--r-- | lorrycontroller/status.py | 22 | ||||
-rw-r--r-- | templates/lorry.tpl | 2 | ||||
-rw-r--r-- | templates/status.tpl | 10 | ||||
-rw-r--r-- | units/lorry-controller-ls-upstreams.service (renamed from units/lorry-controller-ls-troves.service) | 2 | ||||
-rw-r--r-- | units/lorry-controller-ls-upstreams.timer (renamed from units/lorry-controller-ls-troves.timer) | 2 | ||||
-rw-r--r-- | yarns.webapp/020-status.yarn | 2 | ||||
-rw-r--r-- | yarns.webapp/050-hosts.yarn (renamed from yarns.webapp/050-troves.yarn) | 40 | ||||
-rw-r--r-- | yarns.webapp/900-implementations.yarn | 14 |
15 files changed, 175 insertions, 177 deletions
@@ -488,9 +488,9 @@ statements to provide locking. To access STATEDB with locking, use code such as this: with self.open_statedb() as statedb: - troves = statedb.get_troves() - for trove in troves: - statedb.remove_trove(troves) + hosts = statedb.get_hosts() + for host in hosts: + statedb.remove_host(hosts) The code executed by the `with` statement is run under lock, and the lock gets released automatically even if there is an exception. diff --git a/lorry-controller-webapp b/lorry-controller-webapp index c73333a..4c58f16 100755 --- a/lorry-controller-webapp +++ b/lorry-controller-webapp @@ -94,12 +94,12 @@ class WEBAPP(cliapp.Application): default='0.0.0.0') self.settings.string_list( - ['debug-fake-trove'], - 'fake access to remote Troves (to do gitano ls, etc) ' - 'using local files: get ls listing for TROVE from $PATH, ' + ['debug-fake-upstream-host'], + 'fake access to Upstream Hosts (to do gitano ls, etc) ' + 'using local files: get ls listing for HOST from $PATH, ' 'where PATH names a file in JSON with the necessary info; ' 'may be used multiple times', - metavar='TROVE=PATH') + metavar='HOST=PATH') self.settings.string( ['templates'], 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() diff --git a/templates/lorry.tpl b/templates/lorry.tpl index 7c475e0..22760d4 100644 --- a/templates/lorry.tpl +++ b/templates/lorry.tpl @@ -17,7 +17,7 @@ <tr> <th>Interval</th> <td>{{lorry['interval_nice']}} ({{lorry['interval']}} s)</td> </tr> <tr> <th>Last run</th> <td>{{lorry['last_run_nice']}}</td> </tr> <tr> <th>Due</th> <td>{{lorry['due_nice']}}</td> </tr> -<tr> <th>From Trove</th> <td>{{lorry['from_trovehost']}}</td> </tr> +<tr> <th>From Host</th> <td>{{lorry['from_host']}}</td> </tr> <tr> <th>Disk usage</th> <td>{{lorry['disk_usage_nice']}}</td> </tr> <tr> <th>Job?</th> diff --git a/templates/status.tpl b/templates/status.tpl index 46fe034..277b4b8 100644 --- a/templates/status.tpl +++ b/templates/status.tpl @@ -48,17 +48,17 @@ <p>Free disk space: {{disk_free_gib}} GiB.</p> -<h2>Remote Troves</h2> +<h2>Upstream Hosts</h2> <table> <tr> -<th>Trove host</th> +<th>Host</th> <th>Due for re-scan of remote repositories</th> </tr> -% for trove_info in troves: +% for host_info in hosts: <tr> -<td>{{trove_info['trovehost']}}</td> -<td>{{trove_info['ls_due_nice']}}</td> +<td>{{host_info['host']}}</td> +<td>{{host_info['ls_due_nice']}}</td> </tr> % end </table> diff --git a/units/lorry-controller-ls-troves.service b/units/lorry-controller-ls-upstreams.service index f7db2e7..8dd6187 100644 --- a/units/lorry-controller-ls-troves.service +++ b/units/lorry-controller-ls-upstreams.service @@ -2,7 +2,7 @@ WantedBy=multi-user.target [Unit] -Description=Lorry Controller ls-troves +Description=Lorry Controller ls-upstreams After=lighttpd-lorry-controller-webapp.service [Service] diff --git a/units/lorry-controller-ls-troves.timer b/units/lorry-controller-ls-upstreams.timer index c5e5ae3..eea5070 100644 --- a/units/lorry-controller-ls-troves.timer +++ b/units/lorry-controller-ls-upstreams.timer @@ -2,7 +2,7 @@ WantedBy=multi-user.target [Unit] -Description=Lorry Controller ls-troves +Description=Lorry Controller ls-upstreams [Timer] OnUnitInactiveSec=60 diff --git a/yarns.webapp/020-status.yarn b/yarns.webapp/020-status.yarn index 5749920..8fb8593 100644 --- a/yarns.webapp/020-status.yarn +++ b/yarns.webapp/020-status.yarn @@ -3,7 +3,7 @@ WEBAPP status reporting WEBAPP reports it status via an HTTP request. We verify that when it starts up, the status is that it is doing nothing: there are no jobs, -it has no Lorry or Trove specs. +it has no Lorry or Host specs. SCENARIO WEBAPP is idle when it starts GIVEN a running WEBAPP diff --git a/yarns.webapp/050-troves.yarn b/yarns.webapp/050-hosts.yarn index 503ac09..dfa9e5b 100644 --- a/yarns.webapp/050-troves.yarn +++ b/yarns.webapp/050-hosts.yarn @@ -1,16 +1,16 @@ -Handling of remote Troves -========================= +Handling of Upstream Hosts +========================== -This chapter has tests for WEBAPP's handling of remote Troves: getting -the listing of repositories to mirror from the Trove, and creating +This chapter has tests for WEBAPP's handling of Upstream Hosts: getting +the listing of repositories to mirror from the Host, and creating entries in the run-queue for them. -Reading a remote Trove specification from CONFGIT -------------------------------------------------- +Reading a Host specification from CONFGIT +----------------------------------------- When there's a `troves` section in the Lorry Controller configuration -file, the WEBAPP should include that in the list of Troves when +file, the WEBAPP should include that in the list of Hosts when reported. SCENARIO a Trove is listed in CONFGIT @@ -18,55 +18,55 @@ reported. AND an empty lorry-controller.conf in CONFGIT AND WEBAPP uses CONFGIT as its configuration directory -Note that we need to fake a remote Trove, using static files, to keep +Note that we need to fake an Upstream Host, using static files, to keep test setup simpler. - AND WEBAPP fakes Trove example-trove + AND WEBAPP fakes Upstream Host example-trove AND a running WEBAPP -Initially WEBAPP should report no known Troves, and have an empty +Initially WEBAPP should report no known Hosts, and have an empty run-queue. WHEN admin makes request GET /1.0/status THEN response has run_queue set to [] - AND response has troves set to [] + AND response has hosts set to [] Let's add a `troves` section to the configuration file. After WEBAPP -reads that, it should list the added Trove in status. +reads that, it should list the added Host in status. GIVEN lorry-controller.conf in CONFGIT adds trove example-trove AND lorry-controller.conf in CONFGIT has prefixmap example:example for example-trove WHEN admin makes request POST /1.0/read-configuration AND admin makes request GET /1.0/status - THEN response has troves item 0 field trovehost set to "example-trove" + THEN response has hosts item 0 field host set to "example-trove" However, this should not have made WEBAPP to fetch a new list of -repositories from the remote Trove. +repositories from the Upstream Host. THEN response has run_queue set to [] If we tell WEBAPP to fetch the list, we should see repositories. - GIVEN remote Trove example-trove has repository example/foo + GIVEN Upstream Host example-trove has repository example/foo WHEN admin makes request POST /1.0/ls-troves AND admin makes request GET /1.0/list-queue THEN response has queue set to ["example/foo"] If we re-read the configuration again, without any changes to it or to -the fake Trove's repository list, the same Troves and Lorry specs +the fake Upstream Host's repository list, the same Host and Lorry specs should remain in STATEDB. (It wasn't always thus, due to a bug.) WHEN admin makes request POST /1.0/read-configuration AND admin makes request GET /1.0/status - THEN response has troves item 0 field trovehost set to "example-trove" + THEN response has hosts item 0 field host set to "example-trove" WHEN admin makes request GET /1.0/list-queue THEN response has queue set to ["example/foo"] -If the Trove deletes a repository, we should still keep it locally, to -avoid disasters. However, it will be removed from the Trove's STATEDB, +If the Upstream Host deletes a repository, we should still keep it locally, to +avoid disasters. However, it will be removed from the Host's STATEDB, and it won't be lorried anymore. - GIVEN remote Trove example-trove doesn't have repository example/foo + GIVEN Upstream Host example-trove doesn't have repository example/foo WHEN admin makes request POST /1.0/ls-troves AND admin makes request GET /1.0/list-queue THEN response has queue set to [] diff --git a/yarns.webapp/900-implementations.yarn b/yarns.webapp/900-implementations.yarn index 245cd73..9a759ba 100644 --- a/yarns.webapp/900-implementations.yarn +++ b/yarns.webapp/900-implementations.yarn @@ -227,15 +227,15 @@ configuration directory is. add_to_config_file "$DATADIR/webapp.conf" \ configuration-directory "$DATADIR/$MATCH_1" -Make WEBAPP fake access to a Trove using a static file. +Make WEBAPP fake access to an Upstream Host using a static file. - IMPLEMENTS GIVEN WEBAPP fakes Trove (\S+) + IMPLEMENTS GIVEN WEBAPP fakes Upstream Host (\S+) add_to_config_file "$DATADIR/webapp.conf" \ - debug-fake-trove "$MATCH_1=$DATADIR/$MATCH_1.trove" + debug-fake-upstream-host "$MATCH_1=$DATADIR/$MATCH_1.trove" -Control the ls listing of a remote Trove. +Control the ls listing of an Upstream Host. - IMPLEMENTS GIVEN remote Trove (\S+) has repository (\S+) + IMPLEMENTS GIVEN Upstream Host (\S+) has repository (\S+) filename="$DATADIR/$MATCH_1.trove" if [ ! -e "$filename" ] then @@ -253,9 +253,9 @@ Control the ls listing of a remote Trove. json.dump(data, f) ' "$filename" -Remove a repository from the fake remote Trove. +Remove a repository from the fake Upstream Host. - IMPLEMENTS GIVEN remote Trove (\S+) doesn't have repository (\S+) + IMPLEMENTS GIVEN Upstream Host (\S+) doesn't have repository (\S+) filename="$DATADIR/$MATCH_1.trove" if [ ! -e "$filename" ] then |