diff options
-rw-r--r-- | lorrycontroller/readconf.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/lorrycontroller/readconf.py b/lorrycontroller/readconf.py index b6f7333..4a193b1 100644 --- a/lorrycontroller/readconf.py +++ b/lorrycontroller/readconf.py @@ -59,8 +59,8 @@ class ReadConfiguration(lorrycontroller.LorryControllerRoute): statedb = self.open_statedb() with statedb: - existing_lorries = set(statedb.get_lorries_paths()) - existing_troves = set(statedb.get_troves()) + lorries_to_remove = set(statedb.get_lorries_paths()) + troves_to_remove = set(statedb.get_troves()) for section in conf_obj: if not 'type' in section: @@ -68,13 +68,13 @@ class ReadConfiguration(lorrycontroller.LorryControllerRoute): if section['type'] == 'lorries': added = self.add_matching_lorries_to_statedb( statedb, section) - existing_lorries = existing_lorries.difference(added) + lorries_to_remove = lorries_to_remove.difference(added) elif section['type'] in ('trove', 'troves'): self.add_trove(statedb, section) - if section['trovehost'] in existing_troves: - existing_troves.remove(section['trovehost']) - existing_lorries = self.without_lorries_for_trovehost( - statedb, existing_lorries, section['trovehost']) + if section['trovehost'] in troves_to_remove: + troves_to_remove.remove(section['trovehost']) + lorries_to_remove = self.without_lorries_for_trovehost( + statedb, lorries_to_remove, section['trovehost']) else: logging.error( 'Unknown section in configuration: %r', section) @@ -82,14 +82,13 @@ class ReadConfiguration(lorrycontroller.LorryControllerRoute): 'ERROR: Unknown section type in configuration: %r' % section) - for path in existing_lorries: + for path in lorries_to_remove: statedb.remove_lorry(path) - for trovehost in existing_troves: + for trovehost in troves_to_remove: statedb.remove_trove(trovehost) statedb.remove_lorries_for_trovehost(trovehost) - if 'redirect' in bottle.request.forms: bottle.redirect(bottle.request.forms.redirect) |