1 From 059984de897fe2c8c48811ceb76a0331f94b3557 Mon Sep 17 00:00:00 2001
2 From: Jackie Huang <jackie.huang@windriver.com>
3 Date: Wed, 13 May 2020 22:10:01 +0800
4 Subject: [PATCH] patch_agent: do not do the packages_iter if pkggrp is None
6 Addn the handling of packages_iter to the else block to avoid:
7 AttributeError: 'NoneType' object has no attribute 'packages_iter'
9 Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
11 cgcs-patch/cgcs-patch/cgcs_patch/patch_agent.py | 44 ++++++++++++-------------
12 1 file changed, 22 insertions(+), 22 deletions(-)
14 diff --git a/cgcs-patch/cgcs-patch/cgcs_patch/patch_agent.py b/cgcs-patch/cgcs-patch/cgcs_patch/patch_agent.py
15 index d8bc375..489d484 100644
16 --- a/cgcs-patch/cgcs-patch/cgcs_patch/patch_agent.py
17 +++ b/cgcs-patch/cgcs-patch/cgcs_patch/patch_agent.py
18 @@ -490,29 +490,29 @@ class PatchAgent(PatchService):
22 - LOG.error("Could not find software group: %s", grp_id)
24 - for pkg in pkggrp.packages_iter():
26 - res = pkgs_installed.filter(name=pkg.name)
28 - found_pkg = avail.filter(name=pkg.name)
29 - self.missing_pkgs_dnf.append(found_pkg[0])
30 - self.missing_pkgs.append(found_pkg[0].name)
31 + LOG.warning("Could not find software group: %s", grp_id)
33 + for pkg in pkggrp.packages_iter():
35 + res = pkgs_installed.filter(name=pkg.name)
37 + found_pkg = avail.filter(name=pkg.name)
38 + self.missing_pkgs_dnf.append(found_pkg[0])
39 + self.missing_pkgs.append(found_pkg[0].name)
41 + except dnf.exceptions.PackageNotFoundError:
42 + self.missing_pkgs_dnf.append(pkg)
43 + self.missing_pkgs.append(pkg.name)
45 - except dnf.exceptions.PackageNotFoundError:
46 - self.missing_pkgs_dnf.append(pkg)
47 - self.missing_pkgs.append(pkg.name)
50 - self.installed = self.pkgobjs_to_list(self.installed_dnf)
51 - self.to_install = self.pkgobjs_to_list(self.to_install_dnf + self.to_downgrade_dnf)
53 - LOG.info("Patch state query returns %s", self.changes)
54 - LOG.info("Installed: %s", self.installed)
55 - LOG.info("To install: %s", self.to_install)
56 - LOG.info("To remove: %s", self.to_remove)
57 - LOG.info("Missing: %s", self.missing_pkgs)
59 + self.installed = self.pkgobjs_to_list(self.installed_dnf)
60 + self.to_install = self.pkgobjs_to_list(self.to_install_dnf + self.to_downgrade_dnf)
62 + LOG.info("Patch state query returns %s", self.changes)
63 + LOG.info("Installed: %s", self.installed)
64 + LOG.info("To install: %s", self.to_install)
65 + LOG.info("To remove: %s", self.to_remove)
66 + LOG.info("Missing: %s", self.missing_pkgs)