summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSol Jerome <solj@ices.utexas.edu>2009-07-16 00:24:56 +0000
committerSol Jerome <solj@ices.utexas.edu>2009-07-16 00:24:56 +0000
commit2db2d49ee254ef9140174682565b314b4be73259 (patch)
treeb6e2cdecb4bb988ae19f7a366f46568696c594ab /src
parent94f606a9b4c9b2922c867cf53955c4f87254ed96 (diff)
downloadbcfg2-2db2d49ee254ef9140174682565b314b4be73259.tar.gz
bcfg2-2db2d49ee254ef9140174682565b314b4be73259.tar.bz2
bcfg2-2db2d49ee254ef9140174682565b314b4be73259.zip
POSIX.py: Fix false error in InstallSymLink
We were falsely assuming that the path to the symlink existed when installing a new one. However, if a symlink has not yet been created, this path could simply not yet exist. Signed-off-by: Sol Jerome <solj@ices.utexas.edu> git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5331 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r--src/lib/Client/Tools/POSIX.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/lib/Client/Tools/POSIX.py b/src/lib/Client/Tools/POSIX.py
index 0ad9dacf6..016d8f32a 100644
--- a/src/lib/Client/Tools/POSIX.py
+++ b/src/lib/Client/Tools/POSIX.py
@@ -114,19 +114,20 @@ class POSIX(Bcfg2.Client.Tools.Tool):
def InstallSymLink(self, entry):
'''Install SymLink Entry'''
self.logger.info("Installing Symlink %s" % (entry.get('name')))
- try:
- fmode = os.lstat(entry.get('name'))[ST_MODE]
- if S_ISREG(fmode) or S_ISLNK(fmode):
- self.logger.debug("Non-directory entry already exists at %s" % \
- (entry.get('name')))
- os.unlink(entry.get('name'))
- elif S_ISDIR(fmode):
- self.logger.debug("Directory entry already exists at %s" % (entry.get('name')))
- self.cmd.run("mv %s/ %s.bak" % (entry.get('name'), entry.get('name')))
- else:
- os.unlink(entry.get('name'))
- except OSError:
- self.logger.info("Symlink %s cleanup failed" % (entry.get('name')))
+ if os.path.exists(entry.get('name')):
+ try:
+ fmode = os.lstat(entry.get('name'))[ST_MODE]
+ if S_ISREG(fmode) or S_ISLNK(fmode):
+ self.logger.debug("Non-directory entry already exists at %s" % \
+ (entry.get('name')))
+ os.unlink(entry.get('name'))
+ elif S_ISDIR(fmode):
+ self.logger.debug("Directory entry already exists at %s" % (entry.get('name')))
+ self.cmd.run("mv %s/ %s.bak" % (entry.get('name'), entry.get('name')))
+ else:
+ os.unlink(entry.get('name'))
+ except OSError:
+ self.logger.info("Symlink %s cleanup failed" % (entry.get('name')))
try:
os.symlink(entry.get('to'), entry.get('name'))
return True