From 9c281e003d3f6f048f065879f5504803f1ec85b3 Mon Sep 17 00:00:00 2001 From: Tiago Gomes Date: Fri, 16 Aug 2013 14:07:55 +0000 Subject: Add initial code to support clusters in morphloader Although clusters morphologies are still loaded using the old code, `checkout` in the new branch-and-merge plugin tries to load and validate the morphology using morphloader. --- morphlib/morphloader.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'morphlib/morphloader.py') diff --git a/morphlib/morphloader.py b/morphlib/morphloader.py index 9b00ded5..70f46064 100644 --- a/morphlib/morphloader.py +++ b/morphlib/morphloader.py @@ -109,6 +109,10 @@ class MorphologyLoader(object): 'name', 'arch', ], + 'cluster': [ + 'name', + 'systems', + ], } _static_defaults = { @@ -144,6 +148,7 @@ class MorphologyLoader(object): 'configuration-extensions': [], 'disk-size': '1G', }, + 'cluster': {}, } def parse_morphology_text(self, text, whence): @@ -217,8 +222,10 @@ class MorphologyLoader(object): # The rest of the validation is dependent on the kind. + # FIXME: move validation of clusters from morph2 to + # here, and use morphload to load the morphology kind = morph['kind'] - if kind not in ('system', 'stratum', 'chunk'): + if kind not in ('system', 'stratum', 'chunk', 'cluster'): raise UnknownKindError(morph['kind'], morph.filename) required = ['kind'] + self._required_fields[kind] @@ -230,9 +237,10 @@ class MorphologyLoader(object): self._validate_system(morph) elif kind == 'stratum': self._validate_stratum(morph) - else: - assert kind == 'chunk' + elif kind == 'chunk': self._validate_chunk(morph) + else: + assert kind == 'cluster' def _validate_system(self, morph): # All stratum names should be unique within a system. @@ -322,9 +330,10 @@ class MorphologyLoader(object): self._set_system_defaults(morphology) elif kind == 'stratum': self._set_stratum_defaults(morphology) - else: - assert kind == 'chunk' + elif kind == 'chunk': self._set_chunk_defaults(morphology) + else: + assert kind == 'cluster' def _set_system_defaults(self, morph): pass -- cgit v1.2.1