Skip to content

Commit

Permalink
fix: Removed show_autosubscribe_output() method
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jirihnidek committed Sep 17, 2024
1 parent 843fcef commit 685ec61
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 74 deletions.
63 changes: 0 additions & 63 deletions src/subscription_manager/cli_command/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:"),
Expand All @@ -70,11 +47,6 @@
_("Enabled:"),
]

PRODUCT_STATUS = [
_("Product Name:"),
_("Status:"),
]

ENVIRONMENT_LIST = [
_("Name:"),
_("Description:"),
Expand All @@ -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")
Expand Down
11 changes: 0 additions & 11 deletions src/subscription_manager/cli_command/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 _
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 685ec61

Please sign in to comment.