From 2bf2b408e1ea37a47d36d93a8980d1ba1784b123 Mon Sep 17 00:00:00 2001 From: Sol Jerome Date: Thu, 10 Dec 2009 16:01:05 +0000 Subject: Snapshots: Revert changes from [5582] so that old client compatibility is maintained Older clients (used via POSIXCompat) still have old-style posix entries. This commits allows for old or new client statistics to be uploaded to the snapshots database. Signed-off-by: Sol Jerome git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5619 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Plugins/Snapshots.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/lib/Server/Plugins/Snapshots.py b/src/lib/Server/Plugins/Snapshots.py index 0da9f6ffc..5ee1e6d62 100644 --- a/src/lib/Server/Plugins/Snapshots.py +++ b/src/lib/Server/Plugins/Snapshots.py @@ -14,10 +14,14 @@ import threading logger = logging.getLogger('Snapshots') +ftypes = ['ConfigFile', 'SymLink', 'Directory'] datafields = { 'Package': ['version'], 'Path': ['type'], 'Service': ['status'], + 'ConfigFile': ['owner', 'group', 'perms'], + 'Directory': ['owner', 'group', 'perms'], + 'SymLink': ['to'], } def build_snap_ent(entry): @@ -28,7 +32,8 @@ def build_snap_ent(entry): state = dict([(key, unicode(entry.get(key))) for key in basefields]) desired.update([(key, unicode(entry.get(key))) for key in \ datafields[entry.tag]]) - if (entry.tag == 'Path') and (entry.get('type') == 'file'): + if entry.tag == 'ConfigFile' or \ + ((entry.tag == 'Path') and (entry.get('type') == 'file')): if entry.text == None: desired['contents'] = None else: @@ -47,7 +52,7 @@ def build_snap_ent(entry): state.update([(key, unicode(entry.get('current_' + key, entry.get(key)))) \ for key in datafields[entry.tag]]) - if entry.tag == 'Path' and entry.get('exists', 'true') == 'false': + if entry.tag in ['ConfigFile', 'Path'] and entry.get('exists', 'true') == 'false': state = None return [desired, state] @@ -91,10 +96,16 @@ class Snapshots(Bcfg2.Server.Plugin.Statistics, for entry in state.find('.//Bad'): data = [False, False, unicode(entry.get('name'))] \ + build_snap_ent(entry) - etag = entry.tag + if entry.tag in ftypes: + etag = 'Path' + else: + etag = entry.tag entries[etag][entry.get('name')] = data for entry in state.find('.//Modified'): - etag = entry.tag + if entry.tag in ftypes: + etag = 'Path' + else: + etag = entry.tag if entry.get('name') in entries[etag]: data = [True, False, unicode(entry.get('name'))] + \ build_snap_ent(entry) -- cgit v1.2.3-1-g7c22