summaryrefslogtreecommitdiffstats
path: root/func
diff options
context:
space:
mode:
authorAdrian Likins <alikins@redhat.com>2008-07-23 15:48:50 -0400
committerAdrian Likins <alikins@redhat.com>2008-07-23 15:48:50 -0400
commit416a465e84a02d6885067ba9c3cf7f2fdd268d6d (patch)
tree89651f226b96a9314725404e91b6997778e66fbb /func
parentf608ad4d25cf7121e829ed50ed69ee4b866a8450 (diff)
downloadfunc-416a465e84a02d6885067ba9c3cf7f2fdd268d6d.tar.gz
func-416a465e84a02d6885067ba9c3cf7f2fdd268d6d.tar.xz
func-416a465e84a02d6885067ba9c3cf7f2fdd268d6d.zip
apply patch from awood@redhat.com thats adds a filter to the yumcmd.check_update call
also add awood to Authors, and add a few unit tests
Diffstat (limited to 'func')
-rw-r--r--func/minion/modules/yumcmd.py24
1 files changed, 21 insertions, 3 deletions
diff --git a/func/minion/modules/yumcmd.py b/func/minion/modules/yumcmd.py
index f06c504..3f30ec9 100644
--- a/func/minion/modules/yumcmd.py
+++ b/func/minion/modules/yumcmd.py
@@ -1,5 +1,6 @@
# Copyright 2007, Red Hat, Inc
# James Bowes <jbowes@redhat.com>
+# Alex Wood <awood@redhat.com>
#
# This software may be freely redistributed under the terms of the GNU
# general public license.
@@ -43,11 +44,28 @@ class Yum(func_module.FuncModule):
ayum.doUnlock()
return True
- def check_update(self, repo=None):
- """Returns a list of packages due to be updated"""
+ def check_update(self, filter=[], repo=None):
+ """Returns a list of packages due to be updated
+ You can specify a filter using the standard yum wildcards
+ """
+ # parsePackages expects a list and doesn't react well if you send in a plain string with a wildcard in it
+ # (the string is broken into a list and one of the list elements is "*" which matches every package)
+ if type(filter) not in [list, tuple]:
+ filter = [filter]
+
ayum = yum.YumBase()
ayum.doConfigSetup()
ayum.doTsSetup()
if repo is not None:
ayum.repos.enableRepo(repo)
- return map(str, ayum.doPackageLists('updates').updates)
+
+ pkg_list = ayum.doPackageLists('updates').updates
+
+ if filter:
+ # exactmatch are all the packages with exactly the same name as one in the filter list
+ # matched are all the packages that matched under any wildcards
+ # unmatched are all the items in the filter list that didn't match anything
+ exactmatch, matched, unmatched = yum.packages.parsePackages(pkg_list, filter)
+ pkg_list = exactmatch + matched
+
+ return map(str, pkg_list)