diff --git a/insights/parsers/os_release.py b/insights/parsers/os_release.py index 8f079e0ccc..e294578305 100644 --- a/insights/parsers/os_release.py +++ b/insights/parsers/os_release.py @@ -67,3 +67,11 @@ def data(self): Deprecated, it will be removed from 3.7.0 """ return self + + @property + def is_rhel_ai(self): + """ + Returns: + bool: True when the system is from RHEL AI image. + """ + return True if self.get("VARIANT", None) == "RHEL AI" and self.get("VARIANT_ID", None) == "rhel_ai" else False diff --git a/insights/tests/parsers/test_os_release.py b/insights/tests/parsers/test_os_release.py index a378f8c152..ee791d68a8 100644 --- a/insights/tests/parsers/test_os_release.py +++ b/insights/tests/parsers/test_os_release.py @@ -94,6 +94,7 @@ def test_rhel(): rls = OsRelease(context_wrap(REHL_OS_RELEASE)) assert rls.get("VARIANT_ID") is None assert rls.get("VERSION") == "7.2 (Maipo)" + assert rls.is_rhel_ai is False def test_rhevh(): @@ -115,6 +116,7 @@ def test_rhel_ai(): assert rls.get("VARIANT_ID") == "rhel_ai" assert rls.get("VARIANT") == "RHEL AI" assert rls.get("BUILD_ID") == "v1.1.3" + assert rls.is_rhel_ai is True def test_empty():