diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2009-08-01 03:35:16 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2009-08-01 03:35:16 +0000 |
commit | 0602c41d8426df816f79daf55fcb49575e228c92 (patch) | |
tree | c75326f5a422f9266c0b455f8906c2a7636979e5 /src | |
parent | e9ba602ea0781d9cdf2683561e61309d6d6b8b12 (diff) | |
download | bcfg2-0602c41d8426df816f79daf55fcb49575e228c92.tar.gz bcfg2-0602c41d8426df816f79daf55fcb49575e228c92.tar.bz2 bcfg2-0602c41d8426df816f79daf55fcb49575e228c92.zip |
Packages: implement code to determine non-redundant package set
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5398 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/Server/Plugins/Packages.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/lib/Server/Plugins/Packages.py b/src/lib/Server/Plugins/Packages.py index bcc5e9d35..8d60b6e92 100644 --- a/src/lib/Server/Plugins/Packages.py +++ b/src/lib/Server/Plugins/Packages.py @@ -482,6 +482,23 @@ class Packages(Bcfg2.Server.Plugin.Plugin, type=ptype, version='auto') structures.append(news) + def make_non_redundant(self, meta, plname): + '''build a non-redundant version of a list of packages + + Arguments: + meta - client metadata instance + plname - name of file containing a list of packages + ''' + pkgnames = set([x.strip() for x in open(plname).readlines()]) + redundant = set() + sources = self.get_matching_sources(meta) + for source in sources: + for pkgname in pkgnames: + for rpkg in source.get_deps(meta, pkgname): + if rpkg in pkgnames: + redundant.add(rpkg) + return pkgnames.difference(redundant), redundant + if __name__ == '__main__': Bcfg2.Logger.setup_logging('Packages', to_console=True) aa = Packages(None, '/home/desai/tmp/bcfg2') |