summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlorry-controller8
-rw-r--r--lorrycontroller/workingstate.py3
2 files changed, 7 insertions, 4 deletions
diff --git a/lorry-controller b/lorry-controller
index b1f4d86..ba793ad 100755
--- a/lorry-controller
+++ b/lorry-controller
@@ -91,7 +91,11 @@ class LorryController(cliapp.Application):
for dead_lorry in prev_lorries - cur_lorries:
logging.info("Dead lorry: %s" % dead_lorry)
conf_uuid = mgr.lorry_state[dead_lorry]['conf']
- should_delete = self.conf.configs[conf_uuid]['destroy']
+ if conf_uuid in self.conf.configs:
+ should_delete = self.conf.configs[conf_uuid]['destroy']
+ else:
+ # Could not find UUID in config, switch to 'never'
+ should_delete = "never"
# TODO: also handle 'unchanged'
if should_delete == "always":
logging.warning("TODO: Delete from Trove")
@@ -121,6 +125,7 @@ class LorryController(cliapp.Application):
store_state = False
if store_state:
mgr.lorry_state[new_lorry] = {
+ 'destroy': conf['destroy'],
'conf': conf_uuid,
'lorry': lorry,
'next-due': nextdue,
@@ -140,6 +145,7 @@ class LorryController(cliapp.Application):
conf_uuid = lorry['controller-uuid']
nextdue = self.conf.duetimes[upd_lorry]
mgr.lorry_state[upd_lorry] = {
+ 'destroy': conf['destroy'],
'conf': conf_uuid,
'lorry': lorry,
'next-due': nextdue,
diff --git a/lorrycontroller/workingstate.py b/lorrycontroller/workingstate.py
index f6f8128..1812ad5 100644
--- a/lorrycontroller/workingstate.py
+++ b/lorrycontroller/workingstate.py
@@ -65,9 +65,6 @@ class WorkingStateManager(object):
self.lorry_state_file)
with open(self.lorry_state_file, "r") as fh:
self.lorry_state = json.load(fh)
- for lorry_name, dct in self.lorry_state.iteritems():
- if type(dct['conf']) == dict:
- dct['conf'] = dct['uuid']
else:
self.lorry_state = dict()