77
88from cmk .ccc .version import Edition
99from cmk .gui .legacy_plugins import get_failed_plugins as get_failed_plugins
10+ from cmk .licensing .community_handler import ( # astrein: disable=cmk-module-layer-violation
11+ CommunityLicensingHandler ,
12+ )
13+ from cmk .licensing .features import licensed_features # astrein: disable=cmk-module-layer-violation
1014
1115_registered_edition : Edition | None = None
1216
@@ -22,31 +26,51 @@ def register(edition: Edition) -> None:
2226 return
2327 _registered_edition = edition
2428
29+ # NOTE: CommunityLicensingHandler is used here because the edition-specific handler has not
30+ # been registered yet at this point in the call chain. This is safe because licensed_features()
31+ # currently ignores the handler entirely (see features.py) and derives bakery availability
32+ # solely from the edition. Once licensed_features() is simplified to reflect this, the
33+ # handler argument will be removed and this workaround will no longer be needed.
34+ agent_bakery_enabled = licensed_features (
35+ edition , CommunityLicensingHandler .make ()
36+ ).bakery .enabled
37+
2538 match edition :
2639 case Edition .PRO :
2740 import cmk .gui .nonfree .pro .registration # type: ignore[import-not-found, import-untyped, unused-ignore]
2841
29- cmk .gui .nonfree .pro .registration .register (edition )
42+ cmk .gui .nonfree .pro .registration .register (
43+ edition ,
44+ agent_bakery_enabled = agent_bakery_enabled ,
45+ )
3046
3147 case Edition .ULTIMATEMT :
3248 import cmk .gui .nonfree .ultimatemt .registration # type: ignore[import-not-found, import-untyped, unused-ignore]
3349
34- cmk .gui .nonfree .ultimatemt .registration .register (edition )
50+ cmk .gui .nonfree .ultimatemt .registration .register (
51+ edition , agent_bakery_enabled = agent_bakery_enabled
52+ )
3553
3654 case Edition .ULTIMATE :
3755 import cmk .gui .nonfree .ultimate .registration # type: ignore[import-not-found, import-untyped, unused-ignore]
3856
39- cmk .gui .nonfree .ultimate .registration .register (edition )
57+ cmk .gui .nonfree .ultimate .registration .register (
58+ edition , agent_bakery_enabled = agent_bakery_enabled
59+ )
4060
4161 case Edition .CLOUD :
4262 import cmk .gui .nonfree .cloud .registration # type: ignore[import-not-found, import-untyped, unused-ignore]
4363
44- cmk .gui .nonfree .cloud .registration .register (edition )
64+ cmk .gui .nonfree .cloud .registration .register (
65+ edition , agent_bakery_enabled = agent_bakery_enabled
66+ )
4567
4668 case Edition .COMMUNITY :
4769 import cmk .gui .community_registration
4870
49- cmk .gui .community_registration .register (edition )
71+ cmk .gui .community_registration .register (
72+ edition , agent_bakery_enabled = agent_bakery_enabled
73+ )
5074
5175 case _ as unreachable :
5276 assert_never (unreachable )
0 commit comments