From f1814ce35f678e14fe7e843c1a74b5ff31945447 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Wed, 11 Jul 2018 15:35:04 -0700 Subject: [PATCH] List individual package install failures Previously it was impossible to know which package in a blueprint caused a failure, if it was just one of them, or all of them, etc. This catches the error when calling yb.install and lists all the failures in the error message that is raised. --- src/pylorax/api/projects.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/pylorax/api/projects.py b/src/pylorax/api/projects.py index 6830e350..ec4ffd78 100644 --- a/src/pylorax/api/projects.py +++ b/src/pylorax/api/projects.py @@ -203,10 +203,20 @@ def projects_depsolve(yb, projects): try: # This resets the transaction yb.closeRpmDB() + install_errors = [] for name, version in projects: if not version: version = "*" - yb.install(pattern="%s-%s" % (name, version)) + pattern = "%s-%s" % (name, version) + try: + yb.install(pattern=pattern) + except YumBaseError as e: + install_errors.append((pattern, str(e))) + + # Were there problems installing these packages? + if install_errors: + raise ProjectsError("The following package(s) had problems: %s" % ",".join(["%s (%s)" % (pattern, err) for pattern, err in install_errors])) + (rc, msg) = yb.buildTransaction() if rc not in [0, 1, 2]: raise ProjectsError("There was a problem depsolving %s: %s" % (projects, msg)) @@ -252,10 +262,20 @@ def projects_depsolve_with_size(yb, projects, with_core=True): try: # This resets the transaction yb.closeRpmDB() + install_errors = [] for name, version in projects: if not version: version = "*" - yb.install(pattern="%s-%s" % (name, version)) + pattern = "%s-%s" % (name, version) + try: + yb.install(pattern=pattern) + except YumBaseError as e: + install_errors.append((pattern, str(e))) + + # Were there problems installing these packages? + if install_errors: + raise ProjectsError("The following package(s) had problems: %s" % ",".join(["%s (%s)" % (pattern, err) for pattern, err in install_errors])) + if with_core: yb.selectGroup("core", group_package_types=['mandatory', 'default', 'optional']) (rc, msg) = yb.buildTransaction()