From 5223ec6eedd1ba50843ec167a318c4217624cf48 Mon Sep 17 00:00:00 2001 From: Sol Jerome Date: Sat, 26 Sep 2009 20:31:42 +0000 Subject: 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 git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5464 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Client/Frame.py | 2 +- src/lib/Client/Tools/POSIX.py | 30 +++++++++++++++++++++++++----- src/lib/Server/Plugins/POSIXCompat.py | 2 +- 3 files changed, 27 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/lib/Client/Frame.py b/src/lib/Client/Frame.py index 8ab329e7b..3228ab2c2 100644 --- a/src/lib/Client/Frame.py +++ b/src/lib/Client/Frame.py @@ -118,7 +118,7 @@ class Frame: entry.get('name')) for entry in problems]) self.logger.error("") entries = [(entry.tag, entry.get('name')) for struct in config for entry in struct] - pkgs = [(entry.get('name'), entry.get('origin')) for struct in config for entry in struct if entry.tag == 'Package'] + pkgs = [(entry.get('name'), entry.get('origin')) for struct in config for entry in struct if entry.tag == 'Package'] multi = [] for entry in entries[:]: if entries.count(entry) > 1: 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: diff --git a/src/lib/Server/Plugins/POSIXCompat.py b/src/lib/Server/Plugins/POSIXCompat.py index 9964bf1f5..00fdbf65c 100644 --- a/src/lib/Server/Plugins/POSIXCompat.py +++ b/src/lib/Server/Plugins/POSIXCompat.py @@ -27,7 +27,7 @@ class POSIXCompat(Bcfg2.Server.Plugin.Plugin, def validate_goals(self, metadata, goals): for goal in goals: for entry in goal.getchildren(): - if entry.tag == 'Path': + if entry.tag == 'Path' and entry.get('type') != 'nonexistent': oldentry = entry entry.tag = entry.get('type') del entry.attrib['type'] -- cgit v1.2.3-1-g7c22