summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Plugins/Metadata.py
diff options
context:
space:
mode:
authorAndrew Brestick <brestick@mcs.anl.gov>2008-06-19 15:11:06 +0000
committerAndrew Brestick <brestick@mcs.anl.gov>2008-06-19 15:11:06 +0000
commitc4de45d84a95ec7e3b61780eae6a591885fc9bbf (patch)
tree34fdab3104bd25c1d53955a47b24ad00f1fb87ff /src/lib/Server/Plugins/Metadata.py
parentaf4dffe87b4c185fb0b5f43cdfdd8a05cb2b0ab6 (diff)
downloadbcfg2-c4de45d84a95ec7e3b61780eae6a591885fc9bbf.tar.gz
bcfg2-c4de45d84a95ec7e3b61780eae6a591885fc9bbf.tar.bz2
bcfg2-c4de45d84a95ec7e3b61780eae6a591885fc9bbf.zip
Resolves ticket #541 and fixes client adding/deleting
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4701 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server/Plugins/Metadata.py')
-rw-r--r--src/lib/Server/Plugins/Metadata.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/lib/Server/Plugins/Metadata.py b/src/lib/Server/Plugins/Metadata.py
index f79aa4d03..67959c968 100644
--- a/src/lib/Server/Plugins/Metadata.py
+++ b/src/lib/Server/Plugins/Metadata.py
@@ -1,7 +1,7 @@
'''This file stores persistent metadata for the BCFG Configuration Repository'''
__revision__ = '$Revision$'
-import lxml.etree, re, socket, time
+import lxml.etree, re, socket, time, fcntl, copy
import Bcfg2.Server.Plugin
class MetadataConsistencyError(Exception):
@@ -267,9 +267,20 @@ class Metadata(Bcfg2.Server.Plugin.MetadataPlugin,
except IOError:
self.logger.error("Failed to write clients.xml")
raise MetadataRuntimeError
+ fd = datafile.fileno()
+ while self.locked(fd) == True:
+ pass
datafile.write(lxml.etree.tostring(self.clientdata.getroot()))
+ fcntl.lockf(fd, fcntl.LOCK_UN)
datafile.close()
-
+
+ def locked(self, fd):
+ try:
+ fcntl.lockf(fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
+ except IOError:
+ return True
+ return False
+
def write_probedata(self):
'''write probe data out for use with bcfg2-info'''
if self.pdirty:
@@ -362,8 +373,10 @@ class Metadata(Bcfg2.Server.Plugin.MetadataPlugin,
[newbundles.append(b) for b in nbundles if b not in newbundles]
[newgroups.append(g) for g in ngroups if g not in newgroups]
newcategories.update(ncategories)
+ groupscopy = copy.deepcopy(self.groups)
+ profilescopy = copy.deepcopy(self.profiles)
return ClientMetadata(client, newgroups, newbundles, newcategories,
- probed, uuid, password, self)
+ probed, uuid, password, (groupscopy, profilescopy))
def GetProbes(self, meta, force=False):
'''Return a set of probes for execution on client'''