diff options
author | Daniel Silverstone <daniel.silverstone@codethink.co.uk> | 2012-10-03 16:35:52 +0100 |
---|---|---|
committer | Daniel Silverstone <daniel.silverstone@codethink.co.uk> | 2012-10-03 16:50:35 +0100 |
commit | fb032af65309be0770cc5b75e1730123ad6f3734 (patch) | |
tree | b509fbf7f85cce2fc560842a3938cb663fe877fc /lorrycontroller | |
parent | e19f1e813de714c17d148b0a7440650ef1b8bf3e (diff) | |
download | lorry-controller-fb032af65309be0770cc5b75e1730123ad6f3734.tar.gz |
Beginnings of rework to remove serial and make behaviour better in general
Diffstat (limited to 'lorrycontroller')
-rw-r--r-- | lorrycontroller/confparser.py | 15 | ||||
-rw-r--r-- | lorrycontroller/workingstate.py | 3 |
2 files changed, 11 insertions, 7 deletions
diff --git a/lorrycontroller/confparser.py b/lorrycontroller/confparser.py index 8179a61..b78dc54 100644 --- a/lorrycontroller/confparser.py +++ b/lorrycontroller/confparser.py @@ -9,7 +9,6 @@ import os import time default_values = [ - ( u'serial', 0 ), ( u'create', u'never' ), ( u'destroy', u'never' ), ( u'interval', u'1m' ), @@ -55,7 +54,7 @@ class LorryControllerConfig(object): # Set the defaults for key, defval in default_values: entry[key] = entry.get(key, defval) - # And validate the generic values such as serial + # And validate the generic values self._validate__generics(entry) # Now validate the rest validator = getattr(self, '_validate_' + entry['type'], None) @@ -65,9 +64,12 @@ class LorryControllerConfig(object): validator(entry) def _validate__generics(self, entry): - '''Validate the generic entries such as 'serial'.''' + '''Validate the generic entries such as 'uuid'.''' if type(entry.get('uuid', None)) != unicode: self._give_up("UUID missing, cannot reconcile without it!") + if entry['uuid'] in self.configs: + self._give_up("UUID is not unique") + self.configs[entry['uuid']] = entry for key, defval in default_values: if type(defval) != type(entry[key]): self._give_up("Invalid type for '%s': %r" % (key, entry[key])) @@ -129,10 +131,9 @@ class LorryControllerConfig(object): fullname = os.path.join(entry['prefix'], name) if self.lorries.get(fullname, None) is not None: self._give_up("Lorry repeated: %s" % fullname) - content['serial'] = entry['serial'] + content['controller-uuid'] = entry['uuid'] my_lorry_names.add(fullname) self.lorries[fullname] = content - self.configs[fullname] = entry except Exception, e: logging.debug("Unable to parse %s, because of %s. Moving on" % (lorry, e)) @@ -210,7 +211,8 @@ class LorryControllerConfig(object): lorry = { "type": "git", "url": "ssh://git@%s/%s.git" % (trove['trovehost'], - remotereponame) + remotereponame), + "controller-uuid": trove['uuid'] } if localreponame in self.lorries: logging.warn("Skipping %s (%s from %s) because we already " @@ -218,7 +220,6 @@ class LorryControllerConfig(object): localreponame, remotereponame, trove['trovehost'])) else: self.lorries[localreponame] = lorry - self.configs[localreponame] = trove lorries_made.add(localreponame) # 3. Now schedule all those lorries in case they're new diff --git a/lorrycontroller/workingstate.py b/lorrycontroller/workingstate.py index 1ef2e9b..68d2ef9 100644 --- a/lorrycontroller/workingstate.py +++ b/lorrycontroller/workingstate.py @@ -64,6 +64,9 @@ class WorkingStateManager(object): logging.debug("Loading state file: %s" % 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() |