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
- 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
--------------------------------------------------------------------------------

View file

@ -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)