summaryrefslogtreecommitdiffstats
path: root/src/lib/Client
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2009-03-19 16:31:17 +0000
committerNarayan Desai <desai@mcs.anl.gov>2009-03-19 16:31:17 +0000
commit50017e71e2811f8c8b699a4da0bad22ee37a3c5a (patch)
treebe5865757737ae55a6dfb84bd6a1b591b046a165 /src/lib/Client
parent2b822c36ae87802b744a908e57e1ef7bdc485d16 (diff)
downloadbcfg2-50017e71e2811f8c8b699a4da0bad22ee37a3c5a.tar.gz
bcfg2-50017e71e2811f8c8b699a4da0bad22ee37a3c5a.tar.bz2
bcfg2-50017e71e2811f8c8b699a4da0bad22ee37a3c5a.zip
YUMng: Switch to yum lib calls instead of parsing command output (thanks to Seth for pointers)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5130 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Client')
-rw-r--r--src/lib/Client/Tools/YUMng.py30
1 files changed, 11 insertions, 19 deletions
diff --git a/src/lib/Client/Tools/YUMng.py b/src/lib/Client/Tools/YUMng.py
index 3baacb32a..0ebf35313 100644
--- a/src/lib/Client/Tools/YUMng.py
+++ b/src/lib/Client/Tools/YUMng.py
@@ -5,6 +5,8 @@ import Bcfg2.Client.XML
import Bcfg2.Client.Tools.RPMng
import ConfigParser, sys, os.path, copy
+import yum
+
try:
set
except NameError:
@@ -55,26 +57,16 @@ class YUMng(Bcfg2.Client.Tools.RPMng.RPMng):
Bcfg2.Client.Tools.RPMng.RPMng.__init__(self, logger, setup, config)
self.yum_avail = dict()
self.yum_installed = dict()
- for line in self.cmd.run('yum list updates --noplugins')[1][1:]:
- try:
- pinfo, vers, _ = line.split()
- pkg, arch = pinfo.split('.')
- if pkg in self.yum_avail:
- self.yum_avail[pkg].update([(arch, vers)])
- else:
- self.yum_avail[pkg] = dict([(arch, vers)])
- except:
- continue
- for line in self.cmd.run('yum list installed --noplugins')[1][1:]:
- try:
- pinfo, vers, _ = line.split()
- pkg, arch = pinfo.split('.')
- if pkg in self.yum_installed:
- self.yum_installed[pkg].update([(arch, vers)])
+ self.yb = yum.YumBase()
+ yup = self.yb.doPackageLists(pkgnarrow='updates')
+ for dest, source in [(self.yum_avail, yup.updates),
+ (self.yum_installed, self.yb.rpmdb)]:
+ for pkg in source:
+ data = [(pkg.arch, '-'.join((pkg.version, pkg.release)))]
+ if pkg.name in dest:
+ dest[pkg.name].update(data)
else:
- self.yum_installed[pkg] = dict([(arch, vers)])
- except:
- continue
+ dest[pkg.name] = dict(data)
def VerifyPackage(self, entry, modlist):
pinned_version = None