From f95ee8062f6584d40eb0c54ee0397c554e8a411f Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Wed, 9 Nov 2011 20:28:04 +0100 Subject: [PATCH 1/8] --SyntaxError Signed-off-by: Steven Armstrong --- lib/cdist/config_install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cdist/config_install.py b/lib/cdist/config_install.py index 055a3b89..0391dbc5 100644 --- a/lib/cdist/config_install.py +++ b/lib/cdist/config_install.py @@ -123,7 +123,7 @@ class ConfigInstall(object): # The user may have created dependencies without satisfying them if not required_object.exists(): raise cdist.Error(cdist_object.name + " requires non-existing " + requirement.name) - else + else: self.log.debug("Required object %s exists", requirement.name) self.object_run(required_object) From ae23f1576f8ce8fa93d88a0b73820538c7d573c4 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Wed, 9 Nov 2011 20:28:51 +0100 Subject: [PATCH 2/8] --TypeError Signed-off-by: Steven Armstrong --- lib/cdist/config_install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cdist/config_install.py b/lib/cdist/config_install.py index 0391dbc5..fbb863c3 100644 --- a/lib/cdist/config_install.py +++ b/lib/cdist/config_install.py @@ -121,7 +121,7 @@ class ConfigInstall(object): required_object = cdist_object.object_from_name(requirement) # The user may have created dependencies without satisfying them - if not required_object.exists(): + if not required_object.exists: raise cdist.Error(cdist_object.name + " requires non-existing " + requirement.name) else: self.log.debug("Required object %s exists", requirement.name) From e1cf8d094b0ee74f62613ab5b81d1f08767986a0 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Wed, 9 Nov 2011 20:29:36 +0100 Subject: [PATCH 3/8] --AttributeError Signed-off-by: Steven Armstrong --- lib/cdist/config_install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cdist/config_install.py b/lib/cdist/config_install.py index fbb863c3..3b347eb1 100644 --- a/lib/cdist/config_install.py +++ b/lib/cdist/config_install.py @@ -122,7 +122,7 @@ class ConfigInstall(object): # The user may have created dependencies without satisfying them if not required_object.exists: - raise cdist.Error(cdist_object.name + " requires non-existing " + requirement.name) + raise cdist.Error(cdist_object.name + " requires non-existing " + required_object.name) else: self.log.debug("Required object %s exists", requirement.name) From b92ea62f72ad26a54c4a17dcfac688d714c1eb3a Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Wed, 9 Nov 2011 20:36:40 +0100 Subject: [PATCH 4/8] export OBJECT_MARKER for use in tests Signed-off-by: Steven Armstrong --- lib/cdist/core/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/cdist/core/__init__.py b/lib/cdist/core/__init__.py index ac5bbf2f..c61c659b 100644 --- a/lib/cdist/core/__init__.py +++ b/lib/cdist/core/__init__.py @@ -23,6 +23,7 @@ from cdist.core.type import Type from cdist.core.type import NoSuchTypeError from cdist.core.object import Object from cdist.core.object import IllegalObjectIdError +from cdist.core.object import OBJECT_MARKER from cdist.core.explorer import Explorer from cdist.core.manifest import Manifest from cdist.core.code import Code From 1729516414715d95ac71ac5c645ecd1683f6d279 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Wed, 9 Nov 2011 20:38:22 +0100 Subject: [PATCH 5/8] allow .cdist (OBJECT_MARKER) inside file names but not as _the_ file/folder name Signed-off-by: Steven Armstrong --- lib/cdist/core/object.py | 10 +++++----- lib/cdist/test/object/__init__.py | 10 ++++++++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/cdist/core/object.py b/lib/cdist/core/object.py index db818f11..9abb11eb 100644 --- a/lib/cdist/core/object.py +++ b/lib/cdist/core/object.py @@ -30,7 +30,7 @@ from cdist.util import fsproperty log = logging.getLogger(__name__) -DOT_CDIST = '.cdist' +OBJECT_MARKER = '.cdist' class IllegalObjectIdError(cdist.Error): @@ -72,7 +72,7 @@ class Object(object): def list_object_names(cls, object_base_path): """Return a list of object names""" for path, dirs, files in os.walk(object_base_path): - if DOT_CDIST in dirs: + if OBJECT_MARKER in dirs: yield os.path.relpath(path, object_base_path) @staticmethod @@ -100,13 +100,13 @@ class Object(object): if object_id: if object_id.startswith('/'): raise IllegalObjectIdError(object_id, 'object_id may not start with /') - if '.cdist' in object_id: - raise IllegalObjectIdError(object_id, 'object_id may not contain \'.cdist\'') + if OBJECT_MARKER in object_id.split(os.sep): + raise IllegalObjectIdError(object_id, 'object_id may not contain \'%s\'' % OBJECT_MARKER) self.type = cdist_type # instance of Type self.base_path = base_path self.object_id = object_id self.name = self.join_name(self.type.name, self.object_id) - self.path = os.path.join(self.type.path, self.object_id, DOT_CDIST) + self.path = os.path.join(self.type.path, self.object_id, OBJECT_MARKER) self.absolute_path = os.path.join(self.base_path, self.path) self.code_local_path = os.path.join(self.path, "code-local") self.code_remote_path = os.path.join(self.path, "code-remote") diff --git a/lib/cdist/test/object/__init__.py b/lib/cdist/test/object/__init__.py index 6681c916..f199ffb5 100644 --- a/lib/cdist/test/object/__init__.py +++ b/lib/cdist/test/object/__init__.py @@ -58,12 +58,18 @@ class ObjectIdTestCase(test.CdistTestCase): with self.assertRaises(core.IllegalObjectIdError): core.Object(cdist_type, object_base_path, illegal_object_id) - def test_object_id_contains_dotcdist(self): + def test_object_id_contains_object_marker(self): cdist_type = core.Type(type_base_path, '__third') - illegal_object_id = 'object_id/may/not/contain/.cdist/anywhere' + illegal_object_id = 'object_id/may/not/contain/%s/anywhere' % core.OBJECT_MARKER with self.assertRaises(core.IllegalObjectIdError): core.Object(cdist_type, object_base_path, illegal_object_id) + def test_object_id_contains_object_marker_string(self): + cdist_type = core.Type(type_base_path, '__third') + illegal_object_id = 'object_id/may/contain_%s_in_filename' % core.OBJECT_MARKER + core.Object(cdist_type, object_base_path, illegal_object_id) + # if we get here, the test passed + class ObjectTestCase(test.CdistTestCase): From 6dd1465aa8b43a31915002ddfbfc9dd79c3f536e Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Mon, 14 Nov 2011 15:29:07 +0100 Subject: [PATCH 6/8] --AttributeError Signed-off-by: Steven Armstrong --- lib/cdist/config_install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cdist/config_install.py b/lib/cdist/config_install.py index 3b347eb1..2d2ab949 100644 --- a/lib/cdist/config_install.py +++ b/lib/cdist/config_install.py @@ -124,7 +124,7 @@ class ConfigInstall(object): if not required_object.exists: raise cdist.Error(cdist_object.name + " requires non-existing " + required_object.name) else: - self.log.debug("Required object %s exists", requirement.name) + self.log.debug("Required object %s exists", required_object.name) self.object_run(required_object) From b9301c8194e5a2fcf153ac5e27d04047773ac64e Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Mon, 14 Nov 2011 23:05:13 +0100 Subject: [PATCH 7/8] bugfix: process names dont start with slash Signed-off-by: Steven Armstrong --- conf/type/__process/explorer/runs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/type/__process/explorer/runs b/conf/type/__process/explorer/runs index 2bfa8f84..240ebef9 100755 --- a/conf/type/__process/explorer/runs +++ b/conf/type/__process/explorer/runs @@ -24,7 +24,7 @@ if [ -f "$__object/parameter/name" ]; then name="$(cat "$__object/parameter/name")" else - name="/$__object_id" + name="$__object_id" fi pgrep -x -f "$name" || true From d7623fcf217e5872ab60794b567c97068566b6df Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Mon, 14 Nov 2011 23:18:44 +0100 Subject: [PATCH 8/8] pgrep -x -f is to restrictive -> impossible to guess/match Signed-off-by: Steven Armstrong --- conf/type/__process/explorer/runs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/type/__process/explorer/runs b/conf/type/__process/explorer/runs index 240ebef9..3ac9ce2f 100755 --- a/conf/type/__process/explorer/runs +++ b/conf/type/__process/explorer/runs @@ -27,4 +27,4 @@ else name="$__object_id" fi -pgrep -x -f "$name" || true +pgrep -x "$name" || true