diff --git a/uaclient/entitlements/landscape.py b/uaclient/entitlements/landscape.py index 7231e5a0c3..00ec9de834 100644 --- a/uaclient/entitlements/landscape.py +++ b/uaclient/entitlements/landscape.py @@ -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() @@ -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]]: diff --git a/uaclient/messages/__init__.py b/uaclient/messages/__init__.py index e163e010df..d396264452 100644 --- a/uaclient/messages/__init__.py +++ b/uaclient/messages/__init__.py @@ -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"),