summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2005-02-14 20:52:58 +0000
committerNarayan Desai <desai@mcs.anl.gov>2005-02-14 20:52:58 +0000
commitf540f2f06c2c54c5b46b453cdd0b612921fa837b (patch)
treef73345a73e9098833b0d6e3143afe06a7179b7ad
parentce7f5ba146e6fc5dc366a02b76784d9ed53a2ed7 (diff)
downloadbcfg2-f540f2f06c2c54c5b46b453cdd0b612921fa837b.tar.gz
bcfg2-f540f2f06c2c54c5b46b453cdd0b612921fa837b.tar.bz2
bcfg2-f540f2f06c2c54c5b46b453cdd0b612921fa837b.zip
update for Gene
(Logical change 1.204) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@866 ce84e21b-d406-0410-9b95-82705330c041
-rw-r--r--src/lib/Server/Generators/Cfg.py37
1 files changed, 23 insertions, 14 deletions
diff --git a/src/lib/Server/Generators/Cfg.py b/src/lib/Server/Generators/Cfg.py
index 8f5aaff51..174879a34 100644
--- a/src/lib/Server/Generators/Cfg.py
+++ b/src/lib/Server/Generators/Cfg.py
@@ -114,21 +114,30 @@ class ConfigFileEntry(object):
if not self.specific.match('/' + event.filename):
syslog(LOG_INFO, 'Cfg: Suppressing event for bogus file %s' % event.filename)
return
- for entry in self.basefiles + self.deltas:
- if entry.name.split('/')[-1] == event.filename:
- if action == 'changed':
- syslog(LOG_INFO, "Cfg: File %s changed" % event.filename)
- entry.HandleEvent(event)
- elif action == 'exists' or action == 'created':
- entry.HandleEvent(event)
- elif action == 'deleted':
- [flist.remove(entry) for flist in [self.basefiles, self.deltas] if entry in flist]
- else:
- syslog(LOG_ERR, "Cfg: Unhandled Action '%s' for file %s" % (action, event.filename))
- return
- # This code is only reached when an event goes unhandled
- syslog(LOG_ERR, "Cfg: Event '%s' went unhandled for file '%s'" %(action, event.filename))
+ entries = [entry for entry in self.basefiles + self.deltas if
+ entry.name.split('/')[-1] == event.filename]
+
+ if len(entries) == 0:
+ syslog(LOG_ERR, "Cfg: Failed to match entry for spec %s" % (event.filename))
+ elif len(entries) > 1:
+ syslog(LOG_ERR, "Cfg: Matched multiple entries for spec %s" % (event.filename))
+
+ if action == 'deleted':
+ syslog(LOG_INFO, "Cfg: Removing entry %s" % event.filename)
+ for entry in entries:
+ syslog(LOG_INFO, "Cfg: Removing entry %s" % (entry.name))
+ if entry in self.basefiles:
+ self.basefiles.remove(entry)
+ if entry in self.deltas:
+ self.deltas.remove(entry)
+ syslog(LOG_INFO, "Cfg: Entry deletion completed")
+ elif action in ['changed', 'exists', 'created']:
+ if action == 'changed':
+ syslog(LOG_INFO, "Cfg: File %s changed" % event.filename)
+ [entry.HandleEvent(event) for entry in entries]
+ else:
+ syslog(LOG_ERR, "Cfg: Unhandled Action %s for file %s" % (action, event.filename))
def GetConfigFile(self, entry, metadata):
'''Fetch config file from repository'''