From be50939c9e5732c626e17762eeea52cb5909d130 Mon Sep 17 00:00:00 2001 From: Ben Brown Date: Mon, 25 Apr 2016 15:51:06 +0100 Subject: Allow host to be specified instead of trovehost Change-Id: I23c23886b5389d75032c64bf4e78db7edca1af63 --- README | 5 ++--- lorrycontroller/readconf.py | 8 +++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README b/README index 5fe1d93..e3ba0f4 100644 --- a/README +++ b/README @@ -81,7 +81,7 @@ exist). "delta": "delta" }, "protocol": "http", - "trovehost": "git.baserock.org", + "host": "git.baserock.org", "type": "trove" }, { @@ -98,8 +98,7 @@ A Trove specification (map) uses the following mandatory keys: * `type: trove` -- specify it's a Trove specification. -* `trovehost` -- the other Trove to mirror; a domain name or IP - address. +* `host` -- the other Trove to mirror; a domain name or IP address. * `protocol` -- specify how Lorry Controller (and Lorry) should talk to other Troves. Allowed values are `ssh`, `https`, `http`. diff --git a/lorrycontroller/readconf.py b/lorrycontroller/readconf.py index 5323a3f..aee2462 100644 --- a/lorrycontroller/readconf.py +++ b/lorrycontroller/readconf.py @@ -71,7 +71,7 @@ class ReadConfiguration(lorrycontroller.LorryControllerRoute): lorries_to_remove = lorries_to_remove.difference(added) elif section['type'] in ('trove', 'troves', 'gitlab'): self.add_trove(statedb, section) - trovehost = section['trovehost'] + trovehost = section.get('host') or section['trovehost'] if trovehost in troves_to_remove: troves_to_remove.remove(trovehost) lorries_to_remove = lorries_to_remove.difference( @@ -291,7 +291,7 @@ class ReadConfiguration(lorrycontroller.LorryControllerRoute): gitlab_token = section['private-token'] statedb.add_trove( - trovehost=section['trovehost'], + trovehost=section.get('host') or section['trovehost'], protocol=section['protocol'], username=username, password=password, @@ -351,9 +351,11 @@ class LorryControllerConfValidator(object): self._check_has_required_fields(section, ['private-token']) def _check_troves_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( section, - ['trovehost', 'protocol', 'interval', 'ls-interval', 'prefixmap']) + ['protocol', 'interval', 'ls-interval', 'prefixmap']) self._check_protocol(section) self._check_prefixmap(section) if 'ignore' in section: -- cgit v1.2.1