From bcf569ca082511fefa1552e623d1ce5095ef5399 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Tue, 17 Feb 2015 00:07:21 +0100 Subject: Server/Plugins/Decisions: Monitor files for changes. StructFile does not monitor the files by default and without the monitor we does not get the content. So we need to supply should_monitor=True to the StructFile. --- src/lib/Bcfg2/Server/Plugins/Decisions.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/lib/Bcfg2') diff --git a/src/lib/Bcfg2/Server/Plugins/Decisions.py b/src/lib/Bcfg2/Server/Plugins/Decisions.py index b30a9acea..957426ec8 100644 --- a/src/lib/Bcfg2/Server/Plugins/Decisions.py +++ b/src/lib/Bcfg2/Server/Plugins/Decisions.py @@ -27,8 +27,10 @@ class Decisions(Bcfg2.Server.Plugin.Plugin, def __init__(self, core): Bcfg2.Server.Plugin.Plugin.__init__(self, core) Bcfg2.Server.Plugin.Decision.__init__(self) - self.whitelist = DecisionFile(os.path.join(self.data, "whitelist.xml")) - self.blacklist = DecisionFile(os.path.join(self.data, "blacklist.xml")) + self.whitelist = DecisionFile(os.path.join(self.data, "whitelist.xml"), + should_monitor=True) + self.blacklist = DecisionFile(os.path.join(self.data, "blacklist.xml"), + should_monitor=True) def GetDecisions(self, metadata, mode): return getattr(self, mode).get_decisions(metadata) -- cgit v1.2.3-1-g7c22 From 54c4c8f55b80dcae08e00ff69ef4de2365cc0c7c Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Tue, 17 Feb 2015 00:12:02 +0100 Subject: FileMonitor/Pseudo: Only produce exists events, if file exists. The pseudo filemonitor created exists events, even if the file does not exists and the event handler raises an exception. Not it simply ignores non existing files and does not confuse the user with error messages. --- src/lib/Bcfg2/Server/FileMonitor/Pseudo.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/lib/Bcfg2') diff --git a/src/lib/Bcfg2/Server/FileMonitor/Pseudo.py b/src/lib/Bcfg2/Server/FileMonitor/Pseudo.py index b1e1adab7..9781e5b75 100644 --- a/src/lib/Bcfg2/Server/FileMonitor/Pseudo.py +++ b/src/lib/Bcfg2/Server/FileMonitor/Pseudo.py @@ -17,7 +17,8 @@ class Pseudo(FileMonitor): def AddMonitor(self, path, obj, handleID=None): if handleID is None: handleID = len(list(self.handles.keys())) - self.events.append(Event(handleID, path, 'exists')) + if os.path.exists(path): + self.events.append(Event(handleID, path, 'exists')) if os.path.isdir(path): dirlist = os.listdir(path) for fname in dirlist: -- cgit v1.2.3-1-g7c22