summaryrefslogtreecommitdiffstats
path: root/src
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:39:49 -0600
commitd656849aafeabcf9f92ce8068ccd404832f61735 (patch)
treeba140154c7f99b1f11196a7243aef3d073c21914 /src
parent5c6fb0091e72b127ff9ce9217ea0a0c9fb9c9a53 (diff)
downloadbcfg2-d656849aafeabcf9f92ce8068ccd404832f61735.tar.gz
bcfg2-d656849aafeabcf9f92ce8068ccd404832f61735.tar.bz2
bcfg2-d656849aafeabcf9f92ce8068ccd404832f61735.zip
Metadata: Reload clients.xml before writing if the Pseudo file monitor is used
Diffstat (limited to 'src')
-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 47c073bca..e351b75a7 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}
@@ -465,6 +468,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))
@@ -736,6 +746,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')