summaryrefslogtreecommitdiffstats
path: root/src/lib/Client
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2006-03-29 16:21:36 +0000
committerNarayan Desai <desai@mcs.anl.gov>2006-03-29 16:21:36 +0000
commitf8a6863ba54f9e97a47fba1526fbc6508059ba18 (patch)
treec0af7085b5e3beeca003bae69de6e2e986677775 /src/lib/Client
parente3ff37b12ad69f4cd4da7ca69a84873d9b8145fd (diff)
downloadbcfg2-f8a6863ba54f9e97a47fba1526fbc6508059ba18.tar.gz
bcfg2-f8a6863ba54f9e97a47fba1526fbc6508059ba18.tar.bz2
bcfg2-f8a6863ba54f9e97a47fba1526fbc6508059ba18.zip
* Fix parent directory creation for directory entries (resolving Ticket #37)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@1813 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Client')
-rw-r--r--src/lib/Client/Toolset.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/lib/Client/Toolset.py b/src/lib/Client/Toolset.py
index 470395d5a..9e5c8c97a 100644
--- a/src/lib/Client/Toolset.py
+++ b/src/lib/Client/Toolset.py
@@ -305,6 +305,28 @@ class Toolset(object):
exists = False
if not exists:
+ parent = "/".join(entry.get('name').split('/')[:-1])
+ if parent:
+ try:
+ os.lstat(parent)
+ except:
+ self.logger.debug('Creating parent path for directory %s' % (entry.get('name')))
+ for idx in xrange(len(parent.split('/')[:-1])):
+ current = '/'+'/'.join(parent.split('/')[1:2+idx])
+ try:
+ sloc = os.lstat(current)
+ try:
+ if not S_ISDIR(sloc[ST_MODE]):
+ os.unlink(current)
+ os.mkdir(current)
+ except OSError:
+ return False
+ except OSError:
+ try:
+ os.mkdir(current)
+ except OSError:
+ return False
+
try:
os.mkdir(entry.get('name'))
except OSError: