From a834e8999a261b8612c2c35f0f2103ae5ac99070 Mon Sep 17 00:00:00 2001 From: Javi Polo Date: Thu, 8 Aug 2024 14:56:58 +0200 Subject: [PATCH] RHELAI-838 Enforce insights registration in ilab wrapper Signed-off-by: Javi Polo --- training/ilab-wrapper/ilab | 28 ++++++++++++++++++- .../nvidia-bootc/duplicated/ilab-wrapper/ilab | 28 ++++++++++++++++++- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/training/ilab-wrapper/ilab b/training/ilab-wrapper/ilab index 3b2bf40e..93c0c59b 100755 --- a/training/ilab-wrapper/ilab +++ b/training/ilab-wrapper/ilab @@ -2,7 +2,7 @@ echo-err() { echo "$@" >&2; } -function verify_range() { +verify_range() { subuid_range="$1" username="$2" NUMBER_OF_MATCHING_SUBUID_RANGES=$(if [[ -z "$subuid_range" ]]; then echo 0; else wc -l <<<"$subuid_range"; fi) @@ -18,6 +18,32 @@ function verify_range() { fi } +check_insights() { + if [[ -f /etc/insights-client/machine-id ]]; then + return + fi + if [[ -f /etc/ilab-skip-insights ]]; then + return + fi + local ID + eval "$(grep ^ID= /etc/os-release)" + if [[ "$ID" != "rhel" ]]; then + return + fi + cat << EOF +This host is not connected to Red Hat Insights. + +To connect this host to Red Hat Insights run the following command: +sudo rhc connect --organization --activation-key + +For more information on how to manage your activation keys, please visit: +https://docs.redhat.com/en/documentation/subscription_central/1-latest/html/getting_started_with_activation_keys_on_the_hybrid_cloud_console/assembly-creating-managing-activation-keys +EOF + exit 1 +} + +check_insights + # Template values replaced by container build CONTAINER_DEVICE="__REPLACE_CONTAINER_DEVICE__" IMAGE_NAME="__REPLACE_IMAGE_NAME__" diff --git a/training/nvidia-bootc/duplicated/ilab-wrapper/ilab b/training/nvidia-bootc/duplicated/ilab-wrapper/ilab index 3b2bf40e..93c0c59b 100755 --- a/training/nvidia-bootc/duplicated/ilab-wrapper/ilab +++ b/training/nvidia-bootc/duplicated/ilab-wrapper/ilab @@ -2,7 +2,7 @@ echo-err() { echo "$@" >&2; } -function verify_range() { +verify_range() { subuid_range="$1" username="$2" NUMBER_OF_MATCHING_SUBUID_RANGES=$(if [[ -z "$subuid_range" ]]; then echo 0; else wc -l <<<"$subuid_range"; fi) @@ -18,6 +18,32 @@ function verify_range() { fi } +check_insights() { + if [[ -f /etc/insights-client/machine-id ]]; then + return + fi + if [[ -f /etc/ilab-skip-insights ]]; then + return + fi + local ID + eval "$(grep ^ID= /etc/os-release)" + if [[ "$ID" != "rhel" ]]; then + return + fi + cat << EOF +This host is not connected to Red Hat Insights. + +To connect this host to Red Hat Insights run the following command: +sudo rhc connect --organization --activation-key + +For more information on how to manage your activation keys, please visit: +https://docs.redhat.com/en/documentation/subscription_central/1-latest/html/getting_started_with_activation_keys_on_the_hybrid_cloud_console/assembly-creating-managing-activation-keys +EOF + exit 1 +} + +check_insights + # Template values replaced by container build CONTAINER_DEVICE="__REPLACE_CONTAINER_DEVICE__" IMAGE_NAME="__REPLACE_IMAGE_NAME__"