summaryrefslogtreecommitdiffstats
path: root/src/sbin/bcfg2-repo-validate
diff options
context:
space:
mode:
authorSol Jerome <solj@ices.utexas.edu>2008-08-22 16:13:48 +0000
committerSol Jerome <solj@ices.utexas.edu>2008-08-22 16:13:48 +0000
commit8ac787d2f018e6e69e9b15933656a62a99db55d9 (patch)
tree49a152a1f0bfd697666ef03d9f129d8417457b94 /src/sbin/bcfg2-repo-validate
parent213ba8f122249e52830c185e97d51d3cba89382b (diff)
downloadbcfg2-8ac787d2f018e6e69e9b15933656a62a99db55d9.tar.gz
bcfg2-8ac787d2f018e6e69e9b15933656a62a99db55d9.tar.bz2
bcfg2-8ac787d2f018e6e69e9b15933656a62a99db55d9.zip
Perform schema checks for all Xinclude files in groups.xml
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4890 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/sbin/bcfg2-repo-validate')
-rwxr-xr-xsrc/sbin/bcfg2-repo-validate45
1 files changed, 32 insertions, 13 deletions
diff --git a/src/sbin/bcfg2-repo-validate b/src/sbin/bcfg2-repo-validate
index d067d4e74..459032346 100755
--- a/src/sbin/bcfg2-repo-validate
+++ b/src/sbin/bcfg2-repo-validate
@@ -10,6 +10,14 @@ import glob, lxml.etree, os, sys
import Bcfg2.Options
+try:
+ pdlist = set
+except:
+ class pdlist(list):
+ def add(self, item):
+ if item not in self:
+ self.append(item)
+
if __name__ == '__main__':
opts = {'repo': Bcfg2.Options.SERVER_REPOSITORY,
'prefix': Bcfg2.Options.INSTALL_PREFIX,
@@ -31,16 +39,31 @@ if __name__ == '__main__':
if filename.endswith('info.xml'):
info_list.append(os.path.join(root, filename))
- # get all XIncluded bundles
- ref_bundles = []
- unref_bundles = []
+ # get metadata list (with all included files)
+ metadata_list = glob.glob("%s/Metadata/groups.xml" % repo)
+ ref_bundles = pdlist()
xdata = lxml.etree.parse("%s/Metadata/groups.xml" % repo)
+ included = pdlist([ent.get('href') for ent in \
+ xdata.findall('./{http://www.w3.org/2001/XInclude}include')])
+ while included:
+ try:
+ filename = included.pop()
+ except KeyError:
+ continue
+ metadata_list.append("%s/Metadata/%s" % (repo, filename))
+ groupdata = lxml.etree.parse("%s/Metadata/%s" % (repo, filename))
+ group_ents = [ent.get('href') for ent in \
+ groupdata.findall('./{http://www.w3.org/2001/XInclude}include')]
+ for ent in group_ents:
+ included.add(ent)
+ included.discard(filename)
+
+ # get all XIncluded bundles
xdata.xinclude()
for bundle in xdata.findall("//Bundle"):
- ref_bundles.append("%s/Bundler/%s.xml" % (repo,bundle.get('name')))
+ ref_bundles.add("%s/Bundler/%s.xml" % (repo, bundle.get('name')))
# get lists of all other xml files to validate
- metadata_list = glob.glob("%s/Metadata/groups.xml" % repo)
clients_list = glob.glob("%s/Metadata/clients.xml" % repo)
bundle_list = glob.glob("%s/Bundler/*.xml" % repo)
pkg_list = glob.glob("%s/Pkgmgr/*.xml" % repo)
@@ -50,11 +73,6 @@ if __name__ == '__main__':
services_list = glob.glob("%s/Svcmgr/*.xml" % repo)
deps_list = glob.glob("%s/Deps/*.xml" % repo)
- # find all unreferenced bundles
- for bundle in ref_bundles:
- if bundle not in bundle_list:
- unref_bundles.append(bundle)
-
filesets = {'metadata':(metadata_list, "%s/metadata.xsd"),
'clients':(clients_list, "%s/clients.xsd"),
'info':(info_list, "%s/info.xsd"),
@@ -104,8 +122,9 @@ if __name__ == '__main__':
# print out missing bundle information
if verbose:
print("")
- for bundle in unref_bundles:
- print ("*** Warning: Bundle %s referenced, but does not "
- "exist." % bundle)
+ for bundle in ref_bundles:
+ if bundle not in bundle_list:
+ print ("*** Warning: Bundle %s referenced, but does not "
+ "exist." % bundle)
raise SystemExit, failures