summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Laszlo <tim.laszlo@gmail.com>2011-01-24 11:37:24 -0600
committerTim Laszlo <tim.laszlo@gmail.com>2011-01-24 11:41:15 -0600
commit38fcd5004eb130bcafc5a5ed3fd6913260abb4ef (patch)
tree12a1286baef88b020faa385c4dda6ab04f1fade4
parent7aaa4269a1fca4e6bdd36b05356290fc266e487d (diff)
downloadbcfg2-38fcd5004eb130bcafc5a5ed3fd6913260abb4ef.tar.gz
bcfg2-38fcd5004eb130bcafc5a5ed3fd6913260abb4ef.tar.bz2
bcfg2-38fcd5004eb130bcafc5a5ed3fd6913260abb4ef.zip
Metadata: Reload clients.xml before writing if the Pseudo file monitor is used
(cherry picked from commit d656849aafeabcf9f92ce8068ccd404832f61735)
-rw-r--r--src/lib/Server/Plugins/Metadata.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/lib/Server/Plugins/Metadata.py b/src/lib/Server/Plugins/Metadata.py
index 00395fa23..a708b0ad6 100644
--- a/src/lib/Server/Plugins/Metadata.py
+++ b/src/lib/Server/Plugins/Metadata.py
@@ -9,6 +9,7 @@ import os
import os.path
import socket
import time
+import Bcfg2.Server.FileMonitor
import Bcfg2.Server.Plugin
class MetadataConsistencyError(Exception):
@@ -83,6 +84,8 @@ class Metadata(Bcfg2.Server.Plugin.Plugin,
except:
print("Unable to add file monitor for groups.xml or clients.xml")
raise Bcfg2.Server.Plugin.PluginInitError
+
+ self.pseudo_monitor = isinstance(core.fam, Bcfg2.Server.FileMonitor.Pseudo)
self.states = {}
if watch_clients:
self.states = {"groups.xml":False, "clients.xml":False}
@@ -460,6 +463,13 @@ class Metadata(Bcfg2.Server.Plugin.Plugin,
if profile not in self.public:
self.logger.error("Failed to set client %s to private group %s" % (client, profile))
raise MetadataConsistencyError
+ if self.pseudo_monitor:
+ # if we aren't using fam reload the clients.xml file in case its changed
+ try:
+ self.clientdata_original = lxml.etree.parse(self.data + "/clients.xml")
+ except Exception, e:
+ self.logger.error("Metadata: Failed to relad clients.xml. %s" % e)
+ raise MetadataConsistencyError
if client in self.clients:
self.logger.info("Changing %s group from %s to %s" % (client, self.clients[client], profile))
cli = self.clientdata_original.xpath('.//Client[@name="%s"]' % (client))
@@ -727,6 +737,13 @@ class Metadata(Bcfg2.Server.Plugin.Plugin,
client = meta.hostname
if client in self.auth and self.auth[client] == 'bootstrap':
self.logger.info("Asserting client %s auth mode to cert" % client)
+ if self.pseudo_monitor:
+ # if we aren't using fam reload the clients.xml file in case its changed
+ try:
+ self.clientdata_original = lxml.etree.parse(self.data + "/clients.xml")
+ except Exception, e:
+ self.logger.error("Metadata: Failed to relad clients.xml. %s" % e)
+ raise MetadataConsistencyError
cli = self.clientdata_original.xpath('.//Client[@name="%s"]' \
% (client))
cli[0].set('auth', 'cert')