From 1b6f7ca2b56ac4cfc04ddc0709c9ac9613f3dd9a Mon Sep 17 00:00:00 2001 From: Michal Bocek Date: Thu, 7 Nov 2024 22:43:27 +0100 Subject: [PATCH 1/2] Add more conversion fields to schema The change follows up on the rh_cloud plugin sending more conversion facts to Insights. Related: https://github.com/theforeman/foreman_rh_cloud/pull/914 --- schemas/system_profile/v1.yaml | 57 ++++++++++++++++++++++++++++++++-- tests/utils/invalids.py | 16 ++++++++-- tests/utils/valids.py | 16 +++++++++- 3 files changed, 83 insertions(+), 6 deletions(-) diff --git a/schemas/system_profile/v1.yaml b/schemas/system_profile/v1.yaml index 563632a..57be81c 100644 --- a/schemas/system_profile/v1.yaml +++ b/schemas/system_profile/v1.yaml @@ -769,9 +769,60 @@ $defs: type: object properties: activity: - description: Whether the conversion activity has been done or not - type: boolean - example: true + description: 'conversion' for an attempted conversion to RHEL and 'analysis' for an attempted pre-conversion analysis + type: string + example: "conversion, analysis" + activity_started: + description: UTC timestamp of when the activity started + type: string + example: "2024-07-11T17:28:54.281664Z" + activity_ended: + description: UTC timestamp of when the activity started + type: string + example: "2024-07-11T17:48:47.026664Z" + success: + description: Whether the activity has finished successfully or not + type: string + # Ideally should have been boolean - discussed under https://github.com/RedHatInsights/inventory-schemas/pull/129 + example: "true, false" + source_os: + description: Name and version of the Linux distribution that's being converted to RHEL + type: object + properties: + name: + description: Name of the Linux distribution that's being converted to RHEL + type: string + example: "AlmaLinux, Oracle Linux" + version: + description: Version of the Linux distribution that's being converted to RHEL + type: string + example: "8.10" + target_os: + description: Name and version of RHEL to which the system is being converted to + type: object + properties: + name: + description: Target Linux distribution + type: string + example: "Red Hat Enterprise Linux" + version: + description: What version of RHEL the system is being converted to + type: string + example: "8.10" + convert2rhel_through_foreman: + description: Whether the activity has been performed using a Red Hat Satellite conversion job template. If not the property is not present. + type: integer + format: int16 + minimum: 1 + maximum: 1 + packages_0_nevra: + description: convert2rhel rpm name, epoch, version, release, and architecture + type: string + example: "convert2rhel-0:2.0.0-1.el8.noarch" + packages_0_signature: + description: The convert2rhel rpm signature + type: string + example: "RSA/SHA256, Thu May 30 13:31:33 2024, Key ID 199e2f91fd431d51" rhel_ai: description: Object containing information about RHEL AI type: object diff --git a/tests/utils/invalids.py b/tests/utils/invalids.py index 96c8009..25995b4 100644 --- a/tests/utils/invalids.py +++ b/tests/utils/invalids.py @@ -366,8 +366,20 @@ "version": "x" * 35, }}, {"system_update_method": "inv_method"}, - {"conversions": { # Must be a boolean, not a string - "activity": "wrong" + {"conversions": { # The activity must be either "conversion" or "analysis" + "activity": true, + }}, + {"conversions": { + "source_os": { # The version must be a string + "name": "AlmaLinux", + "version": 8.10 + }, + }}, + {"conversions": { # Currently must be a "true" or "false" string. + "success": false + }}, + {"conversions": { # Must be an integer with value 1 + "convert2rhel_through_foreman": true, }}, {"rhel_ai": { # Must be a string, not a number "variant": "RHEL AI", diff --git a/tests/utils/valids.py b/tests/utils/valids.py index 7c2a23a..72eb64f 100644 --- a/tests/utils/valids.py +++ b/tests/utils/valids.py @@ -186,7 +186,21 @@ }}, {"system_update_method": "yum"}, {"conversions": { - "activity": True + "source_os": { + "name": "AlmaLinux", + "version": "8.10" + }, + "target_os": { + "name": "Red Hat Enterprise Linux", + "version": "8.10" + }, + "convert2rhel_through_foreman": 1, + "activity": "conversion", + "packages_0_nevra": "convert2rhel-0:2.0.0-1.el8.noarch", + "packages_0_signature": "RSA/SHA256, Thu May 30 13:31:33 2024, Key ID 199e2f91fd431d51", + "activity_started": "2024-07-11T17:28:54.281664Z", + "activity_ended": "2024-07-11T17:48:47.026664Z", + "success": "true" }}, {"rhel_ai": { "variant": "RHEL AI", From 84f23509e2fec115a882dc8f27c2990c2fa83464 Mon Sep 17 00:00:00 2001 From: Michal Bocek Date: Fri, 13 Dec 2024 15:47:50 +0100 Subject: [PATCH 2/2] Switched conversion "success" from string to bool Based on https://github.com/theforeman/foreman_rh_cloud/pull/925. --- schemas/system_profile/v1.yaml | 5 ++--- tests/utils/invalids.py | 8 ++++---- tests/utils/valids.py | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/schemas/system_profile/v1.yaml b/schemas/system_profile/v1.yaml index 57be81c..63df297 100644 --- a/schemas/system_profile/v1.yaml +++ b/schemas/system_profile/v1.yaml @@ -782,9 +782,8 @@ $defs: example: "2024-07-11T17:48:47.026664Z" success: description: Whether the activity has finished successfully or not - type: string - # Ideally should have been boolean - discussed under https://github.com/RedHatInsights/inventory-schemas/pull/129 - example: "true, false" + type: boolean + example: true source_os: description: Name and version of the Linux distribution that's being converted to RHEL type: object diff --git a/tests/utils/invalids.py b/tests/utils/invalids.py index 25995b4..d3faa6e 100644 --- a/tests/utils/invalids.py +++ b/tests/utils/invalids.py @@ -367,7 +367,7 @@ }}, {"system_update_method": "inv_method"}, {"conversions": { # The activity must be either "conversion" or "analysis" - "activity": true, + "activity": True, }}, {"conversions": { "source_os": { # The version must be a string @@ -375,11 +375,11 @@ "version": 8.10 }, }}, - {"conversions": { # Currently must be a "true" or "false" string. - "success": false + {"conversions": { # Shall be boolean, not a stringpy + "success": "false" }}, {"conversions": { # Must be an integer with value 1 - "convert2rhel_through_foreman": true, + "convert2rhel_through_foreman": True, }}, {"rhel_ai": { # Must be a string, not a number "variant": "RHEL AI", diff --git a/tests/utils/valids.py b/tests/utils/valids.py index 72eb64f..af1f3af 100644 --- a/tests/utils/valids.py +++ b/tests/utils/valids.py @@ -200,7 +200,7 @@ "packages_0_signature": "RSA/SHA256, Thu May 30 13:31:33 2024, Key ID 199e2f91fd431d51", "activity_started": "2024-07-11T17:28:54.281664Z", "activity_ended": "2024-07-11T17:48:47.026664Z", - "success": "true" + "success": True }}, {"rhel_ai": { "variant": "RHEL AI",