diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-08-03 14:28:34 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-08-03 14:28:34 -0400 |
commit | 7ab620571cbf135aa3bfb0e1e3c6112e9a0b2f35 (patch) | |
tree | 99e2dd2f1dcbc9636f2c66c6d3010096ed4786c8 /src/lib | |
parent | 047006a2c404b1ebd5eb0b643a6530a99a88b5ea (diff) | |
download | bcfg2-7ab620571cbf135aa3bfb0e1e3c6112e9a0b2f35.tar.gz bcfg2-7ab620571cbf135aa3bfb0e1e3c6112e9a0b2f35.tar.bz2 bcfg2-7ab620571cbf135aa3bfb0e1e3c6112e9a0b2f35.zip |
fixed calculation of new packages list
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Packages/Collection.py | 7 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Packages/Yum.py | 13 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Packages/__init__.py | 2 |
3 files changed, 21 insertions, 1 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Collection.py b/src/lib/Bcfg2/Server/Plugins/Packages/Collection.py index d38a6e714..da88a1315 100644 --- a/src/lib/Bcfg2/Server/Plugins/Packages/Collection.py +++ b/src/lib/Bcfg2/Server/Plugins/Packages/Collection.py @@ -200,6 +200,13 @@ class Collection(Bcfg2.Server.Plugin.Debuggable): default="auto"), type=self.ptype, origin='Packages') + def get_new_packages(self, initial, complete): + """ compute the difference between the complete package list + and the initial package list. this is necessary because the + format may be different between the two lists due to + packages_{to,from}_entry() """ + return list(packages.difference(initial)) + def complete(self, packagelist): '''Build the transitive closure of all package dependencies diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py b/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py index 27523f2ab..ce1d9886f 100644 --- a/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py +++ b/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py @@ -466,6 +466,19 @@ class YumCollection(Collection): attrs.update(pkgattrs) lxml.etree.SubElement(entry, 'BoundPackage', **attrs) + def get_new_packages(self, initial, complete): + initial_names = [] + for pkg in initial: + if isinstance(pkg, tuple): + initial_names.append(pkg[0]) + else: + initial_names.append(pkg) + new = [] + for pkg in complete: + if pkg[0] not in initial_names: + new.append(pkg) + return new + def complete(self, packagelist): if not self.use_yum: return Collection.complete(self, packagelist) diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/__init__.py b/src/lib/Bcfg2/Server/Plugins/Packages/__init__.py index 3a7ec2920..2742a674d 100644 --- a/src/lib/Bcfg2/Server/Plugins/Packages/__init__.py +++ b/src/lib/Bcfg2/Server/Plugins/Packages/__init__.py @@ -192,7 +192,7 @@ class Packages(Bcfg2.Server.Plugin.Plugin, if unknown: self.logger.info("Packages: Got %d unknown entries" % len(unknown)) self.logger.info("Packages: %s" % list(unknown)) - newpkgs = list(packages.difference(initial)) + newpkgs = collection.get_new_packages(initial, packages) self.debug_log("Packages: %d initial, %d complete, %d new" % (len(initial), len(packages), len(newpkgs))) newpkgs.sort() |