summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2007-03-23 02:55:31 +0000
committerNarayan Desai <desai@mcs.anl.gov>2007-03-23 02:55:31 +0000
commit2658fb67af26cc2d0590e7d62244d61d3685c8f7 (patch)
treec8ada6c610beee364307c4ce08888c5d4f089ef6
parent41ba7f4412ca9f6d8ba9e180e0278b071d3b6c75 (diff)
downloadbcfg2-2658fb67af26cc2d0590e7d62244d61d3685c8f7.tar.gz
bcfg2-2658fb67af26cc2d0590e7d62244d61d3685c8f7.tar.bz2
bcfg2-2658fb67af26cc2d0590e7d62244d61d3685c8f7.zip
Fix child node issues in Pkgmgr (for Ignore/Instance)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2991 ce84e21b-d406-0410-9b95-82705330c041
-rw-r--r--src/lib/Server/Plugin.py9
-rw-r--r--src/lib/Server/Plugins/Pkgmgr.py11
2 files changed, 14 insertions, 6 deletions
diff --git a/src/lib/Server/Plugin.py b/src/lib/Server/Plugin.py
index 8bbf6cdac..9a4d8fb1e 100644
--- a/src/lib/Server/Plugin.py
+++ b/src/lib/Server/Plugin.py
@@ -1,7 +1,7 @@
'''This module provides the baseclass for Bcfg2 Server Plugins'''
__revision__ = '$Revision$'
-import logging, lxml.etree, re
+import logging, lxml.etree, re, copy
from lxml.etree import XML, XMLSyntaxError
@@ -356,7 +356,10 @@ class PrioDir(Plugin, XMLDirectoryBacked):
index = prio.index(max(prio))
data = matching[index].cache[1][entry.tag][name]
- [entry.attrib.__setitem__(key, data[key]) for key in data.keys()]
if data.has_key('__text__'):
- del entry.attrib['__text__']
entry.text = data['__text__']
+ del data['__text__']
+ if data.has_key('__children__'):
+ [entry.append(copy.deepcopy(item)) for item in data['__children__']]
+ del data['__children__']
+ [entry.attrib.__setitem__(key, data[key]) for key in data.keys()]
diff --git a/src/lib/Server/Plugins/Pkgmgr.py b/src/lib/Server/Plugins/Pkgmgr.py
index abf0f689b..f473240f5 100644
--- a/src/lib/Server/Plugins/Pkgmgr.py
+++ b/src/lib/Server/Plugins/Pkgmgr.py
@@ -30,9 +30,13 @@ class PNode(Bcfg2.Server.Plugin.INode):
for pkg in data.findall('./Package'):
if pkg.attrib.has_key('name') and pkg.get('name') not in pdict['Package']:
pdict['Package'].append(pkg.get('name'))
+ self.contents['Package'][pkg.get('name')] = {}
+ if pkg.getchildren():
+ self.contents['Package'][pkg.get('name')]['__children__'] \
+ = pkg.getchildren()
if pkg.attrib.has_key('simplefile'):
pkg.set('url', "%s/%s" % (pkg.get('uri'), pkg.get('simplefile')))
- self.contents['Package'][pkg.get('name')] = pkg.attrib
+ self.contents['Package'][pkg.get('name')].update(pkg.attrib)
else:
if pkg.attrib.has_key('file'):
if pkg.attrib.has_key('multiarch'):
@@ -49,7 +53,7 @@ class PNode(Bcfg2.Server.Plugin.INode):
logger.error("Failed to match pkg %s" % pkg.get('file'))
continue
pkgname = mdata.group('name')
- self.contents['Package'][pkgname] = mdata.groupdict()
+ self.contents['Package'][pkgname].update(mdata.groupdict())
if pkg.attrib.get('file'):
self.contents['Package'][pkgname]['url'] = pkg.get('url')
self.contents['Package'][pkgname]['type'] = pkg.get('type')
@@ -60,7 +64,8 @@ class PNode(Bcfg2.Server.Plugin.INode):
if pkgname not in pdict['Package']:
pdict['Package'].append(pkgname)
else:
- self.contents['Package'][pkg.get('name')] = pkg.attrib
+ self.contents['Package'][pkg.get('name')].update(pkg.attrib)
+
class PkgSrc(Bcfg2.Server.Plugin.XMLSrc):
'''PkgSrc files contain a PNode hierarchy that returns matching package entries'''