forked from ungleich-public/cdist
Merge branch 'feature_object_override' of git://github.com/dheule/cdist
This commit is contained in:
commit
a9dd040164
3 changed files with 38 additions and 5 deletions
|
|
@ -2,6 +2,7 @@
|
|||
#
|
||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||
# 2011-2013 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
# 2014 Daniel Heule (hda at sfs.biz)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
|
|
@ -211,13 +212,13 @@ class CdistObject(object):
|
|||
"""Checks wether this cdist object exists on the file systems."""
|
||||
return os.path.exists(self.absolute_path)
|
||||
|
||||
def create(self):
|
||||
def create(self, allow_overwrite=False):
|
||||
"""Create this cdist object on the filesystem.
|
||||
"""
|
||||
try:
|
||||
os.makedirs(self.absolute_path, exist_ok=False)
|
||||
os.makedirs(self.absolute_path, exist_ok=allow_overwrite)
|
||||
absolute_parameter_path = os.path.join(self.base_path, self.parameter_path)
|
||||
os.makedirs(absolute_parameter_path, exist_ok=False)
|
||||
os.makedirs(absolute_parameter_path, exist_ok=allow_overwrite)
|
||||
except EnvironmentError as error:
|
||||
raise cdist.Error('Error creating directories for cdist object: %s: %s' % (self, error))
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#
|
||||
# 2011-2013 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
# 2012 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||
# 2014 Daniel Heule (hda at sfs.biz)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
|
|
@ -144,13 +145,17 @@ class Emulator(object):
|
|||
if value is not None:
|
||||
self.parameters[key] = value
|
||||
|
||||
if self.cdist_object.exists:
|
||||
if self.cdist_object.exists and os.environ.get('CDIST_ALLOW_OVERRIDE',"false") != 'true':
|
||||
if self.cdist_object.parameters != self.parameters:
|
||||
raise cdist.Error("Object %s already exists with conflicting parameters:\n%s: %s\n%s: %s"
|
||||
% (self.cdist_object.name, " ".join(self.cdist_object.source), self.cdist_object.parameters, self.object_source, self.parameters)
|
||||
)
|
||||
else:
|
||||
self.cdist_object.create()
|
||||
if self.cdist_object.exists:
|
||||
self.log.debug('Object %s override forced with CDIST_ALLOW_OVERRIDE=true',self.cdist_object.name)
|
||||
self.cdist_object.create(True)
|
||||
else:
|
||||
self.cdist_object.create()
|
||||
self.cdist_object.parameters = self.parameters
|
||||
|
||||
# Record / Append source
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue