From 0602c41d8426df816f79daf55fcb49575e228c92 Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Sat, 1 Aug 2009 03:35:16 +0000 Subject: 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 --- src/lib/Server/Plugins/Packages.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src') 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') -- cgit v1.2.3-1-g7c22