From 2a7947f29bf9d530ff42e86c4a811bf4a6f64088 Mon Sep 17 00:00:00 2001 From: Sol Jerome Date: Mon, 7 Jun 2010 14:51:44 -0500 Subject: repo-validate: Warn when missing attributes for Path entries Signed-off-by: Sol Jerome --- src/sbin/bcfg2-repo-validate | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/sbin/bcfg2-repo-validate b/src/sbin/bcfg2-repo-validate index 1bdcf4180..8675b9ac1 100755 --- a/src/sbin/bcfg2-repo-validate +++ b/src/sbin/bcfg2-repo-validate @@ -84,6 +84,39 @@ if __name__ == '__main__': pkgcfg_list = glob.glob("%s/Packages/config.xml" % repo) gp_list = glob.glob('%s/GroupPatterns/config.xml' % repo) + # verify attributes for configuration entries + # (as defined in doc/server/configurationentries) + # TODO: See if it is possible to do this in the schema instead + configuration_attrs = { + 'device':['name', 'owner', 'group', 'dev_type'], + 'directory':['name', 'owner', 'group', 'perms'], + 'file':['name', 'owner', 'group', 'perms', 'encoding', 'empty'], + 'hardlink':['name', 'to'], + 'symlink':['name', 'to'], + 'ignore':['name'], + 'nonexist':['name'], + 'permissions':['name', 'owner', 'group', 'perms']} + for rfile in rules_list: + try: + xdata = lxml.etree.parse(rfile) + except lxml.etree.XMLSyntaxError, e: + print("Failed to parse %s: %s" % (plist, e)) + for posixpath in xdata.findall("//Path"): + pathname = posixpath.get('name') + pathtype = posixpath.get('type') + pathset = set(posixpath.attrib.keys()) + try: + required_attrs = set(configuration_attrs[pathtype] \ + + ['type']) + except KeyError: + continue + if pathset.issuperset(required_attrs): + continue + else: + print("The following required attributes are missing for" + " Path %s in %s: %s" % (pathname, rfile, + [attr for attr in required_attrs.difference(pathset)])) + # warn on duplicate Pkgmgr entries with the same priority pset = set() for plist in pkg_list: -- cgit v1.2.3-1-g7c22