new method to create object on the file system

Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
Steven Armstrong 2011-10-11 10:29:06 +02:00
parent 5a082058e5
commit 904396f6a5
1 changed files with 10 additions and 0 deletions

View File

@ -102,3 +102,13 @@ class Object(object):
def exists(self):
"""Checks wether this cdist object exists on the file systems."""
return os.path.exists(self.absolute_path)
def create(self):
"""Create this cdist object on the filesystem.
"""
try:
os.makedirs(self.absolute_path, exist_ok=False)
absolute_parameter_path = os.path.join(self.base_path, self.parameter_path)
os.makedirs(absolute_parameter_path, exist_ok=False)
except EnvironmentError as error:
raise cdist.Error('Error creating directories for cdist object: %s: %s' % (self, error))