From bda0f01adda437a6bac1c5a890063bccbd1f5b78 Mon Sep 17 00:00:00 2001 From: Mike McCallister Date: Tue, 26 Jul 2011 09:34:39 -0500 Subject: Rewrote DirectoryBacked so it handles files contained in an arbitrary directory layout. Previously, DirectoryBacked (and as a result Bundler, Deps, Rules, Base, Pkgmgr, and others) only recognized XML files contained in the top-level plugin directory, for example: Deps/foo.xml Deps/subdir/foo.xml # <--- Ignored Bundler/bar.xml Bundler/subdir/baz.xml # <--- Ignored Now it can support the following as well: Deps/debian-lenny/foo.xml Deps/debian-squeeze/foo.xml Bundler/group-a/bar.xml Bundler/group-b/baz.xml Note that the directories and filenames do not factor into the semantic meaning of the configuration specification. The contents of foo.xml must stand alone, as if they were in the same single-level directory as before. In the case of Deps, Rules, Pkgmgr, and Svcmgr, you must use Groups and priorities within the XML files as needed to ensure that Bcfg2 can correctly resolve the configuration for your hosts. For example, prior to this change you would use a single file like the following: Deps/foo.xml: Now you can use a pair of files in separate directories like the following. Note how the groups within each file prevent there from being two sources for a single package: Deps/debian-lenny/foo.xml: Deps/debian-squeeze/foo.xml: In the case of Bundler, individual filenames must remain unique throughout the directory hierarchy, and they must match the bundle name. --- src/lib/Server/Plugins/Bundler.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/lib/Server/Plugins') diff --git a/src/lib/Server/Plugins/Bundler.py b/src/lib/Server/Plugins/Bundler.py index 01ad3c78b..bf0c42416 100644 --- a/src/lib/Server/Plugins/Bundler.py +++ b/src/lib/Server/Plugins/Bundler.py @@ -3,6 +3,7 @@ __revision__ = '$Revision$' import copy import lxml.etree +import os import re import sys @@ -74,8 +75,8 @@ class Bundler(Bcfg2.Server.Plugin.Plugin, """Build all structures for client (metadata).""" bundleset = [] for bundlename in metadata.bundles: - entries = [item for (key, item) in list(self.entries.items()) if \ - self.patterns.match(key).group('name') == bundlename] + entries = [item for (key, item) in self.entries.items() if \ + self.patterns.match(os.path.basename(key)).group('name') == bundlename] if len(entries) == 0: continue elif len(entries) == 1: -- cgit v1.2.3-1-g7c22