From ec68be0335d057badc416489a9d1a8bfedaea69d Mon Sep 17 00:00:00 2001 From: pkoprda Date: Thu, 6 Feb 2025 16:33:28 +0100 Subject: [PATCH] fix(client): Update logging messages * Card ID: CCT-265 This patch updates the logging messages shown to the user when the host is registered/not-registered with subscription-manager or when the host is registered/not-registered with insights-client. Signed-off-by: pkoprda --- insights/client/connection.py | 4 +++- insights/client/phase/v1.py | 25 +++++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/insights/client/connection.py b/insights/client/connection.py index 656ba1b448..c7fc9419c2 100644 --- a/insights/client/connection.py +++ b/insights/client/connection.py @@ -1143,7 +1143,9 @@ def checkin(self): logger.info("Checking in...") if not self._fetch_system_by_machine_id(): - logger.error("This host is not registered. To register, run 'insights-client --register'.") + logger.error("This host is not registered. " + "Use --register to register this host.\n" + "# insights-client --register") return False try: diff --git a/insights/client/phase/v1.py b/insights/client/phase/v1.py index 9ec5e9870e..322920c4a9 100644 --- a/insights/client/phase/v1.py +++ b/insights/client/phase/v1.py @@ -11,7 +11,7 @@ from insights.client.config import InsightsConfig from insights.client.constants import InsightsConstants as constants from insights.client.support import InsightsSupport -from insights.client.utilities import validate_remove_file, print_egg_versions +from insights.client.utilities import validate_remove_file, print_egg_versions, _get_rhsm_identity from insights.client.schedule import get_scheduler logger = logging.getLogger(__name__) @@ -56,9 +56,16 @@ def get_phases(): @phase def pre_update(client, config): - # Check if BASIC auth is used to print a WARNING message - if config.authmethod == 'BASIC': - logger.warning('WARN: BASIC authentication method is being deprecated. Please consider using CERT authentication method.') + # Check if the host is registered with subscription-manager + if config.authmethod == 'BASIC' or not _get_rhsm_identity(): + logger.error('This host has not yet been registered, please ensure ' + 'that the system is\nregistered with subscription-manager ' + 'and then with insights-client.\n' + '\n1. Register with subscription-manager' + '\n# subscription-manager register\n' + '\n2. Register with insights-client' + '\n# insights-client --register') + sys.exit(constants.sig_kill_bad) if config.version: logger.info(constants.version) @@ -264,8 +271,9 @@ def post_update(client, config): # halt here if unregistered if not reg_check and not config.register: - logger.info('This host has not been registered. ' - 'Use --register to register this host.') + logger.error('This host is not registered. ' + 'Use --register to register this host.\n' + '# insights-client --register') sys.exit(constants.sig_kill_bad) # --register was called @@ -274,8 +282,9 @@ def post_update(client, config): # system creation and upload are a single event on the platform if reg_check is False and isfile(constants.machine_id_file): # Do not register if a machine_id file is found - logger.info("Machine-id found, insights-client can not be registered." - " Please, unregister insights-client first: `insights-client --unregister`") + logger.error('Machine-id found, insights-client can not be registered. ' + 'Use --unregister to unregister this host first.\n' + '# insights-client --unregister') sys.exit(constants.sig_kill_bad) if reg_check: logger.info('This host has already been registered.')