Skip to content

Commit

Permalink
Override applicability status for landscape
Browse files Browse the repository at this point in the history
Fixes: #3331
  • Loading branch information
dheyay committed Oct 3, 2024
1 parent 4027b9b commit 3ca8d59
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
22 changes: 21 additions & 1 deletion uaclient/entitlements/landscape.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

from uaclient import api, event_logger, exceptions, messages, system, util
from uaclient.entitlements.base import UAEntitlement
from uaclient.entitlements.entitlement_status import ApplicationStatus
from uaclient.entitlements.entitlement_status import (
ApplicabilityStatus,
ApplicationStatus,
)

LOG = logging.getLogger(util.replace_top_level_logger_name(__name__))
event = event_logger.get_event_logger()
Expand Down Expand Up @@ -74,6 +77,23 @@ def application_status(
messages.LANDSCAPE_SERVICE_NOT_ACTIVE,
)

def applicability_status(
self,
) -> Tuple[ApplicabilityStatus, Optional[messages.NamedMessage]]:
applicability_status = super().applicability_status()
if applicability_status[0] == ApplicabilityStatus.INAPPLICABLE:
affordance = self.entitlement_cfg["entitlement"].get(
"affordances", {}
)
affordance_series = affordance.get("series", None)
current_release = system.get_release_info()
if current_release not in affordance_series:
return (
ApplicabilityStatus.INAPPLICABLE,
messages.LANDSCAPE_INAPPLICABLE,
)
return applicability_status

def enabled_warning_status(
self,
) -> Tuple[bool, Optional[messages.NamedMessage]]:
Expand Down
8 changes: 8 additions & 0 deletions uaclient/messages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1837,6 +1837,14 @@ def __repr__(self):
Supported CPU vendors are: {supported_vendors}."""
),
)
LANDSCAPE_INAPPLICABLE = NamedMessage(
"landscape-inapplicable",
t.gettext(
"""\
Landscape cannot be enabled via Pro Client on Ubuntu 22.04 and earlier.
Please manually install Landscape: https://ubuntu.com/landscape/install"""
),
)
NO_ENTITLEMENT_AFFORDANCES_CHECKED = NamedMessage(
"no-entitlement-affordances-checked",
t.gettext("no entitlement affordances checked"),
Expand Down

0 comments on commit 3ca8d59

Please sign in to comment.