From 7205cd5ecf927f02aa6ec4883e81c603b6102b5b Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Wed, 10 Jul 2013 16:31:58 +0200 Subject: [PATCH] remove that crappy old singleton object_id thingy Signed-off-by: Steven Armstrong --- cdist/core/cdist_object.py | 3 +-- cdist/emulator.py | 14 ++++++-------- cdist/test/emulator/__init__.py | 2 +- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/cdist/core/cdist_object.py b/cdist/core/cdist_object.py index 04fb404c..e3c1c532 100644 --- a/cdist/core/cdist_object.py +++ b/cdist/core/cdist_object.py @@ -65,7 +65,7 @@ class CdistObject(object): STATE_RUNNING = "running" STATE_DONE = "done" - def __init__(self, cdist_type, base_path, object_id=None): + def __init__(self, cdist_type, base_path, object_id=''): self.cdist_type = cdist_type # instance of Type self.base_path = base_path self.object_id = object_id @@ -107,7 +107,6 @@ class CdistObject(object): """ type_name = object_name.split(os.sep)[0] - # FIXME: allow object without object_id? e.g. for singleton object_id = os.sep.join(object_name.split(os.sep)[1:]) return type_name, object_id diff --git a/cdist/emulator.py b/cdist/emulator.py index 5a23fca5..add20e70 100644 --- a/cdist/emulator.py +++ b/cdist/emulator.py @@ -34,7 +34,7 @@ class Emulator(object): self.stdin = stdin self.env = env - self.object_id = False + self.object_id = '' self.global_path = self.env['__global'] self.target_host = self.env['__target_host'] @@ -54,10 +54,10 @@ class Emulator(object): """Add hostname and object to logs via logging Filter""" prefix = self.target_host + ": (emulator)" - - if self.object_id: - prefix = prefix + " " + self.type_name + "/" + self.object_id - + prefix = '{0}: emulator {1}'.format( + self.target_host, + core.CdistObject.join_name(self.type_name, self.object_id) + ) record.msg = prefix + ": " + record.msg return True @@ -122,9 +122,7 @@ class Emulator(object): def setup_object(self): # Setup object_id - FIXME: unset / do not setup anymore! - if self.cdist_type.is_singleton: - self.object_id = "singleton" - else: + if not self.cdist_type.is_singleton: self.object_id = self.args.object_id[0] del self.args.object_id diff --git a/cdist/test/emulator/__init__.py b/cdist/test/emulator/__init__.py index a9746f99..b3661bd7 100644 --- a/cdist/test/emulator/__init__.py +++ b/cdist/test/emulator/__init__.py @@ -118,7 +118,7 @@ class AutoRequireEmulatorTestCase(test.CdistTestCase): initial_manifest = os.path.join(self.local.manifest_path, "init") self.manifest.run_initial_manifest(initial_manifest) cdist_type = core.CdistType(self.local.type_path, '__saturn') - cdist_object = core.CdistObject(cdist_type, self.local.object_path, 'singleton') + cdist_object = core.CdistObject(cdist_type, self.local.object_path) self.manifest.run_type_manifest(cdist_object) expected = ['__planet/Saturn', '__moon/Prometheus'] self.assertEqual(sorted(cdist_object.autorequire), sorted(expected))