Skip to content

Commit

Permalink
feat: Add is_rhel_ai into parser os_release
Browse files Browse the repository at this point in the history
Signed-off-by: jiazhang <[email protected]>

rh-pre-commit.version: 2.3.1
rh-pre-commit.check-secrets: ENABLED
  • Loading branch information
wushiqinlou committed Dec 18, 2024
1 parent 952f219 commit 2430b52
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions insights/parsers/os_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions insights/tests/parsers/test_os_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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():
Expand Down

0 comments on commit 2430b52

Please sign in to comment.