From 685ec61d35f8cad75a5e57014d7882e7040682ca Mon Sep 17 00:00:00 2001 From: Jiri Hnidek Date: Tue, 17 Sep 2024 14:00:19 +0200 Subject: [PATCH] fix: Removed show_autosubscribe_output() method * Card ID: CCT-734 * Removed show_autosubscribe_output() and usage of this method, because it does not make sense to use it in SCA mode --- src/subscription_manager/cli_command/list.py | 63 ------------------- .../cli_command/register.py | 11 ---- 2 files changed, 74 deletions(-) diff --git a/src/subscription_manager/cli_command/list.py b/src/subscription_manager/cli_command/list.py index 1e2b004ed1..af777cd5b7 100644 --- a/src/subscription_manager/cli_command/list.py +++ b/src/subscription_manager/cli_command/list.py @@ -17,36 +17,13 @@ import logging from rhsmlib.services import products - -from subscription_manager.cert_sorter import ( - FUTURE_SUBSCRIBED, - SUBSCRIBED, - NOT_SUBSCRIBED, - EXPIRED, - PARTIALLY_SUBSCRIBED, - UNKNOWN, -) - from subscription_manager.cli_command.cli import CliCommand from subscription_manager.i18n import ugettext as _ from subscription_manager.printing_utils import ( columnize, none_wrap_columnize_callback, - echo_columnize_callback, ) -from subscription_manager.utils import is_simple_content_access - -# Translates the cert sorter status constants: - -STATUS_MAP = { - FUTURE_SUBSCRIBED: _("Future Subscription"), - SUBSCRIBED: _("Subscribed"), - NOT_SUBSCRIBED: _("Not Subscribed"), - EXPIRED: _("Expired"), - PARTIALLY_SUBSCRIBED: _("Partially Subscribed"), - UNKNOWN: _("Unknown"), -} INSTALLED_PRODUCT_STATUS_SCA = [ _("Product Name:"), @@ -70,11 +47,6 @@ _("Enabled:"), ] -PRODUCT_STATUS = [ - _("Product Name:"), - _("Status:"), -] - ENVIRONMENT_LIST = [ _("Name:"), _("Description:"), @@ -89,41 +61,6 @@ log = logging.getLogger(__name__) -def show_autosubscribe_output(uep, identity): - """ - Try to show auto-attach output - :param uep: object with connection to candlepin - :param identity: object with identity - :return: return 1, when all installed products are subscribed, otherwise return 0 - """ - - if is_simple_content_access(uep=uep, identity=identity): - return 0 - - installed_products = products.InstalledProducts(uep).list() - - if not installed_products: - # Returning an error code here breaks registering when no products are installed, and the - # AttachCommand already performs this check before calling. - print(_("No products installed.")) - return 0 - - log.debug("Attempted to auto-attach/heal the system.") - print(_("Installed Product Current Status:")) - subscribed = 1 - all_subscribed = True - for product in installed_products: - if product[4] == SUBSCRIBED: - subscribed = 0 - status = STATUS_MAP[product[4]] - if product[4] == NOT_SUBSCRIBED: - all_subscribed = False - print(columnize(PRODUCT_STATUS, echo_columnize_callback, product[0], status) + "\n") - if not all_subscribed: - print(_("Unable to find available subscriptions for all your installed products.")) - return subscribed - - class ListCommand(CliCommand): def __init__(self): shortdesc = _("List subscription and product information for this system") diff --git a/src/subscription_manager/cli_command/register.py b/src/subscription_manager/cli_command/register.py index 8ba27731be..8752be5a94 100644 --- a/src/subscription_manager/cli_command/register.py +++ b/src/subscription_manager/cli_command/register.py @@ -36,7 +36,6 @@ from subscription_manager.cli import system_exit from subscription_manager.cli_command.cli import handle_exception, conf from subscription_manager.cli_command.environments import MULTI_ENV -from subscription_manager.cli_command.list import show_autosubscribe_output from subscription_manager.cli_command.user_pass import UserPassCommand from subscription_manager.entcertlib import CONTENT_ACCESS_CERT_CAPABILITY from subscription_manager.i18n import ugettext as _ @@ -356,16 +355,6 @@ def _do_command(self): self._upload_profile(consumer) - subscribed = 0 - if self.options.activation_keys: - # update with the latest cert info - self.sorter = inj.require(inj.CERT_SORTER) - self.sorter.force_cert_check() - subscribed = show_autosubscribe_output(self.cp, self.identity) - - self._request_validity_check() - return subscribed - def _prompt_for_environment(self): """ By breaking this code out, we can write cleaner tests