Skip to content

Commit

Permalink
feat(cloud-init): support ubuntu_pro user-data (SC-1555)
Browse files Browse the repository at this point in the history
In #cloud-config user-data, cloud-init will be deprecating the
ubuntu_advantage key in favor of ubuntu_pro to align with the
current product naming and branding.

To avoid tightly coupling ubuntu-pro-client with cloud-init
releases, add support for the new 'ubuntu_pro' config key and
retain support for the deprecated keys:
 - ubuntu-advantage
 - ubuntu_advantage

Since cloud-init doesn't target Ubuntu Xenial for stable release
updates (SRUs), the ubuntu-advantage/ubuntu_advantage keys must be
supported by cloud-init and ubuntu-pro-client in Xenial unless a
backport of latest cloud-init cc_ubuntu_advantage.py module is
published to Xenial.
  • Loading branch information
blackboxsw committed Feb 5, 2024
1 parent 0a6a410 commit 82e742e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/auto_attach.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@

LOG = logging.getLogger("ubuntupro.lib.auto_attach")

# All known cloud-config keys which provide ubuntu pro configuration directives
CLOUD_INIT_UA_KEYS = set(
["ubuntu-advantage", "ubuntu_advantage", "ubuntu_pro"]
)

try:
import cloudinit.stages as ci_stages # type: ignore
except ImportError:
Expand All @@ -54,10 +59,7 @@ def check_cloudinit_userdata_for_ua_info():
if init is None:
return False

if init.cfg and (
"ubuntu_advantage" in init.cfg.keys()
or "ubuntu-advantage" in init.cfg.keys()
):
if init.cfg and CLOUD_INIT_UA_KEYS.intersection(init.cfg):
return True

return False
Expand Down
14 changes: 14 additions & 0 deletions uaclient/tests/test_lib_auto_attach.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ def test_check_cloudinit_data_returns_false_if_no_cloudinit(
"cloud_config_modules": ["ubuntu-advantage", "test"],
},
),
(
True,
{
"ubuntu_pro": {"token": "TOKEN"},
"cloud_config_modules": ["ubuntu-advantage", "test"],
},
),
(
True,
{
"ubuntu-advantage": {"token": "TOKEN"},
"cloud_config_modules": ["ubuntu-advantage", "test"],
},
),
),
)
@mock.patch("lib.auto_attach.get_cloudinit_init_stage")
Expand Down

0 comments on commit 82e742e

Please sign in to comment.