test the repos in enablerepo/disablerepo and error out if they are broken

This commit is contained in:
Seth Vidal 2013-01-31 17:23:10 -05:00
parent 46d0ba335c
commit 818f8c7de6

20
yum
View file

@ -174,7 +174,7 @@ def is_available(module, repoq, pkgspec, conf_file, qf=def_qf, en_repos=[], dis_
if rc == 0:
return [ p for p in out.split('\n') if p.strip() ]
else:
module.fail_json(msg='Error from repoquery: %s: %s' % (cmd, err + err2))
module.fail_json(msg='Error from repoquery: %s: %s' % (cmd, err))
return []
@ -216,7 +216,7 @@ def is_update(module, repoq, pkgspec, conf_file, qf=def_qf, en_repos=[], dis_rep
if rc == 0:
return set([ p for p in out.split('\n') if p.strip() ])
else:
module.fail_json(msg='Error from repoquery: %s: %s' % (cmd, err + err2))
module.fail_json(msg='Error from repoquery: %s: %s' % (cmd, err))
return []
@ -549,6 +549,22 @@ def ensure(module, state, pkgspec, conf_file, enablerepo, disablerepo):
if repoq:
repoq.extend(r_cmd)
if state in ['installed', 'present', 'latest']:
my = yum_base(conf_file)
try:
for r in dis_repos:
my.repos.disableRepo(r)
for r in en_repos:
try:
my.repos.enableRepo(r)
rid = my.repos.getRepo(r)
a = rid.repoXML.repoid
except yum.Errors.YumBaseError, e:
module.fail_json(msg="Error setting/accessing repo %s: %s" % (r, e))
except yum.Errors.YumBaseError, e:
module.fail_json(msg="Error accessing repos: %s" % e)
if state in ['installed', 'present']:
install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos)
elif state in ['removed', 'absent']: