cleanup / emulator

Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
This commit is contained in:
Nico Schottelius 2012-02-13 07:45:10 +01:00
parent 0c990e1756
commit ab565dc3d9
2 changed files with 8 additions and 21 deletions

View file

@ -1,12 +1,8 @@
- cleanup object_id handling - cleanup object_id handling
- problems - have a look at singletons
- __file/foo/bar//bar - double check verification
- fails later - cleanup emulator to create object
- right strip __foo/bar/ last slash - adjust tests
- only emulator creates objects
- strip slashes in object creation?
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View file

@ -115,18 +115,13 @@ class Emulator(object):
def setup_object(self): def setup_object(self):
# FIXME: verify object id # Setup object_id - FIXME: unset / do not setup anymore!
# Setup object_id
if self.cdist_type.is_singleton: if self.cdist_type.is_singleton:
self.object_id = "singleton" self.object_id = "singleton"
else: else:
self.object_id = self.args.object_id[0] self.object_id = self.args.object_id[0]
del self.args.object_id 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 # Instantiate the cdist object we are defining
self.cdist_object = core.CdistObject(self.cdist_type, self.object_base_path, self.object_id) 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 # Instantiate type which fails if type does not exist
requirement_type = core.CdistType(self.type_base_path, requirement_type_name) requirement_type = core.CdistType(self.type_base_path, requirement_type_name)
if requirement_object_id: # FIXME: need try/catch here or pass exception from core.CdistObject?
# Validate object_id if any # Instantiate object, which fails if object id is broken
core.CdistObject.validate_object_id(requirement_object_id) requirement_object = core.CdistObject(requirement_type, self.object_base_path, 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.")
self.log.debug("Recording requirement: " + requirement) self.log.debug("Recording requirement: " + requirement)
self.cdist_object.requirements.append(requirement) self.cdist_object.requirements.append(requirement)