From 84607ab721061a0930db5342df9b18bf88e70e2a Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Wed, 13 Jul 2005 19:26:11 +0000 Subject: Rename: tools/ValidateBcfg2Repo -> src/sbin/ValidateBcfg2Repo (Logical change 1.257) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@1060 ce84e21b-d406-0410-9b95-82705330c041 --- src/sbin/ValidateBcfg2Repo | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'src') diff --git a/src/sbin/ValidateBcfg2Repo b/src/sbin/ValidateBcfg2Repo index e69de29bb..32385c1cb 100644 --- a/src/sbin/ValidateBcfg2Repo +++ b/src/sbin/ValidateBcfg2Repo @@ -0,0 +1,40 @@ +#!/usr/bin/env python + +from glob import glob +from sys import argv, exit +from validate import validate, ValidationException +from ConfigParser import ConfigParser + +if __name__ == '__main__': + cf = ConfigParser() + cf.read(['/etc/bcfgd.conf']) + try: + repo = cf.get('server', 'repository') + except: + if len(argv) == 1: + print "Usage: validate_repo " + raise SystemExit, 1 + repo = argv[1] + if len(argv) == 3: + schemadir = argv[2] + else: + schemadir = '/usr/share/bcfg2/schemas' + + # add more validation as more schemas get written + filesets = {'metadata':("%s/etc/metadata.xml", "%s/metadata.xsd"), + 'bundle':("%s/Bundler/*.xml", "%s/bundle.xsd"), + 'pkglist':("%s/Pkgmgr/*.xml", "%s/pkglist.xsd"), + 'base':("%s/etc/base.xml", "%s/base.xsd"), + 'imageinfo':("%s/etc/imageinfo.xml", "%s/translation.xsd"), + 'imageinfo':("%s/etc/reports.xml", "%s/report-configuration.xsd"), + 'services':("%s/etc/services.xml", "%s/services.xsd")} + + for k, (spec, schema) in filesets.iteritems(): + for filename in glob(spec%(repo)): + try: + validate(open(filename).read(), schema%(schemadir)) + print "%s checks out"%(filename) + except ValidationException, v: + print "file %s fails to verify:\n%s"%(filename, v) + except IOError: + print "failed to open file %s"%(filename) -- cgit v1.2.3-1-g7c22