Merge remote-tracking branch 'steven/master'

This commit is contained in:
Nico Schottelius 2011-11-15 09:20:48 +01:00
commit 5efb921980
5 changed files with 20 additions and 13 deletions

View file

@ -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
pgrep -x "$name" || true

View file

@ -121,10 +121,10 @@ 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():
raise cdist.Error(cdist_object.name + " requires non-existing " + requirement.name)
else
self.log.debug("Required object %s exists", requirement.name)
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", required_object.name)
self.object_run(required_object)

View file

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

View file

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

View file

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