summaryrefslogtreecommitdiffstats
path: root/src/lib/Client/Tools/POSIX.py
diff options
context:
space:
mode:
authorSol Jerome <solj@ices.utexas.edu>2009-09-26 20:31:42 +0000
committerSol Jerome <solj@ices.utexas.edu>2009-09-26 20:31:42 +0000
commit5223ec6eedd1ba50843ec167a318c4217624cf48 (patch)
treedc97a7f18f2100e464c95afe214eb699870fbf28 /src/lib/Client/Tools/POSIX.py
parent16be5d99e87e106979cf0ba4b3cb78a91cf5cfa0 (diff)
downloadbcfg2-5223ec6eedd1ba50843ec167a318c4217624cf48.tar.gz
bcfg2-5223ec6eedd1ba50843ec167a318c4217624cf48.tar.bz2
bcfg2-5223ec6eedd1ba50843ec167a318c4217624cf48.zip
POSIX: Add support for nonexistent Path entry types
Allow specification of Path entries which should not exist on the client. This gives the user the ability to explicitly remove Path entries if they exist on the client. Signed-off-by: Sol Jerome <solj@ices.utexas.edu> git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5464 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Client/Tools/POSIX.py')
-rw-r--r--src/lib/Client/Tools/POSIX.py30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/lib/Client/Tools/POSIX.py b/src/lib/Client/Tools/POSIX.py
index 81471f910..d956abf3a 100644
--- a/src/lib/Client/Tools/POSIX.py
+++ b/src/lib/Client/Tools/POSIX.py
@@ -79,11 +79,17 @@ def isString(strng):
class POSIX(Bcfg2.Client.Tools.Tool):
'''POSIX File support code'''
name = 'POSIX'
- __handles__ = [('ConfigFile', None), ('Directory', None),
- ('Path', 'ConfigFile'), ('Path', 'Device'),
- ('Path', 'Directory'), ('Path', 'HardLink'),
- ('Path', 'Perms'), ('Path', 'SymLink'),
- ('Permissions', None), ('SymLink', None)]
+ __handles__ = [('ConfigFile', None),
+ ('Directory', None),
+ ('Path', 'ConfigFile'),
+ ('Path', 'Device'),
+ ('Path', 'Directory'),
+ ('Path', 'HardLink'),
+ ('Path', 'Perms'),
+ ('Path', 'SymLink'),
+ ('Path', 'nonexistent'),
+ ('Permissions', None),
+ ('SymLink', None)]
__req__ = {'ConfigFile': ['name', 'owner', 'group', 'perms'],
'Directory': ['name', 'owner', 'group', 'perms'],
'Path': ['name', 'type'],
@@ -376,6 +382,20 @@ class POSIX(Bcfg2.Client.Tools.Tool):
(entry.get('name')))
return False
+ def Verifynonexistent(self, entry, _):
+ '''Verify nonexistent entry'''
+ # return true if path does _not_ exist
+ return not os.path.lexists(entry.get('name'))
+
+ def Installnonexistent(self, entry):
+ '''Remove nonexistent entries'''
+ try:
+ os.remove(entry.get('name'))
+ return True
+ except OSError:
+ self.logger.error('Failed to remove %s' % entry.get('name'))
+ return False
+
def gatherCurrentData(self, entry):
if entry.tag == 'ConfigFile':
try: