From ab565dc3d90e8f2de14976e0e902bc52e3669af0 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 13 Feb 2012 07:45:10 +0100 Subject: [PATCH] cleanup / emulator Signed-off-by: Nico Schottelius --- doc/dev/todo/niconext | 12 ++++-------- lib/cdist/emulator.py | 17 ++++------------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/doc/dev/todo/niconext b/doc/dev/todo/niconext index 167f124a..34c2f7b0 100644 --- a/doc/dev/todo/niconext +++ b/doc/dev/todo/niconext @@ -1,12 +1,8 @@ - cleanup object_id handling - - problems - - __file/foo/bar//bar - - fails later - - right strip __foo/bar/ last slash - - only emulator creates objects - - strip slashes in object creation? - - + - have a look at singletons + - double check verification + - cleanup emulator to create object + - adjust tests -------------------------------------------------------------------------------- diff --git a/lib/cdist/emulator.py b/lib/cdist/emulator.py index 72ed3b9b..67f6d373 100644 --- a/lib/cdist/emulator.py +++ b/lib/cdist/emulator.py @@ -115,18 +115,13 @@ class Emulator(object): def setup_object(self): - # FIXME: verify object id - - # Setup object_id + # Setup object_id - FIXME: unset / do not setup anymore! if self.cdist_type.is_singleton: self.object_id = "singleton" else: self.object_id = self.args.object_id[0] del self.args.object_id - # strip leading slash from object_id - self.object_id = self.object_id.lstrip('/') - # Instantiate the cdist object we are defining self.cdist_object = core.CdistObject(self.cdist_type, self.object_base_path, self.object_id) @@ -160,13 +155,9 @@ class Emulator(object): # Instantiate type which fails if type does not exist requirement_type = core.CdistType(self.type_base_path, requirement_type_name) - if requirement_object_id: - # Validate object_id if any - core.CdistObject.validate_object_id(requirement_object_id) - elif not requirement_type.is_singleton: - # Only singeltons have no object_id - raise IllegalRequirementError(requirement, "Missing object_id and type is not a singleton.") - + # FIXME: need try/catch here or pass exception from core.CdistObject? + # Instantiate object, which fails if object id is broken + requirement_object = core.CdistObject(requirement_type, self.object_base_path, requirement_object_id) self.log.debug("Recording requirement: " + requirement) self.cdist_object.requirements.append(requirement)