Skip to content

Commit 42dc3ec

Browse files
authored
Fix: Add condition to check the output of "rpm-ostree status" firstly into combiner rhel_for_edge (#3657)
* Add rpm_ostree check into combiner rhel_for_edge Signed-off-by: jiazhang <[email protected]> * Fix typo Signed-off-by: jiazhang <[email protected]>
1 parent 613aeca commit 42dc3ec

File tree

2 files changed

+307
-15
lines changed

2 files changed

+307
-15
lines changed

insights/combiners/rhel_for_edge.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@
88
* :py:class:`insights.parsers.systemd.unitfiles.ListUnits`
99
* :py:class:`insights.parsers.redhat_release.RedhatRelease`
1010
"""
11+
from insights.core.exceptions import SkipComponent
1112
from insights.core.plugins import combiner
1213
from insights.parsers.cmdline import CmdLine
1314
from insights.parsers.installed_rpms import InstalledRpms
1415
from insights.parsers.systemd.unitfiles import ListUnits
1516
from insights.parsers.redhat_release import RedhatRelease
17+
from insights.parsers.rpm_ostree_status import RpmOstreeStatus
1618

1719

18-
@combiner(InstalledRpms, CmdLine, ListUnits, RedhatRelease)
20+
@combiner(ListUnits, optional=[RpmOstreeStatus, InstalledRpms, CmdLine, RedhatRelease])
1921
class RhelForEdge(object):
2022
"""Combiner for checking if the system is an edge computing system. Edge
2123
computing as well as the Red Hat CoreOS packages are managed via rpm-ostree.
@@ -58,13 +60,22 @@ class RhelForEdge(object):
5860
5961
"""
6062

61-
def __init__(self, rpms, cmdline, units, redhatrelease):
63+
def __init__(self, units, rpmostreestatus, rpms, cmdline, redhatrelease):
6264
self.is_edge = False
6365
self.is_automated = False
64-
65-
if ('rpm-ostree' in rpms and 'yum' not in rpms) and \
66-
('ostree' in cmdline) and \
67-
("red hat enterprise linux release" in redhatrelease.raw.lower()):
68-
self.is_edge = True
69-
if units.is_running("rhcd.service"):
70-
self.is_automated = True
66+
if rpmostreestatus:
67+
origin = rpmostreestatus.query.deployments.origin
68+
origin_check = [item.value.endswith("edge") for item in origin]
69+
if origin_check and all(origin_check):
70+
self.is_edge = True
71+
if units.is_running("rhcd.service"):
72+
self.is_automated = True
73+
elif rpms and cmdline and redhatrelease:
74+
if ('rpm-ostree' in rpms and 'yum' not in rpms) and \
75+
('ostree' in cmdline) and \
76+
("red hat enterprise linux release" in redhatrelease.raw.lower()):
77+
self.is_edge = True
78+
if units.is_running("rhcd.service"):
79+
self.is_automated = True
80+
else:
81+
raise SkipComponent("Unable to determine if this system is created from an edge image.")

0 commit comments

Comments
 (0)