From d67c71e0bab9c0307a6f0513210b5162c354e17e Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Mon, 13 Jun 2022 15:45:28 +0200 Subject: [PATCH] ubuntu-pro: add auto_enabled property for services The JSON returned by uaclient for a status request contains the auto_enabled property for each service. This property tells whether a given service is enabled automatically when `ua attach` is done. We will need this information going forward so we now include it in the success response to /ubuntu_pro/check_token: { "status": "VALID_TOKEN", "services": [ { "name": "esm-infra", "description": "UA Infra: Extended Security Maintenance (ESM)", "auto_enabled": true }, { "name": "fips", "description": "NIST-certified core packages", "auto_enabled": false } ] } Signed-off-by: Olivier Gayot --- subiquity/common/types.py | 1 + subiquity/server/tests/test_ubuntu_advantage.py | 4 ++++ subiquity/server/ubuntu_advantage.py | 1 + 3 files changed, 6 insertions(+) diff --git a/subiquity/common/types.py b/subiquity/common/types.py index 70f53170..dacab493 100644 --- a/subiquity/common/types.py +++ b/subiquity/common/types.py @@ -460,6 +460,7 @@ class UbuntuProCheckTokenStatus(enum.Enum): class UbuntuProService: name: str description: str + auto_enabled: bool @attr.s(auto_attribs=True) diff --git a/subiquity/server/tests/test_ubuntu_advantage.py b/subiquity/server/tests/test_ubuntu_advantage.py index 308f8337..e6d9a217 100644 --- a/subiquity/server/tests/test_ubuntu_advantage.py +++ b/subiquity/server/tests/test_ubuntu_advantage.py @@ -191,18 +191,22 @@ class TestUAInterface(unittest.TestCase): self.assertIn(UbuntuProService( name="esm-infra", description="UA Infra: Extended Security Maintenance (ESM)", + auto_enabled=True, ), services) self.assertIn(UbuntuProService( name="fips", description="NIST-certified core packages", + auto_enabled=False, ), services) self.assertNotIn(UbuntuProService( name="esm-apps", description="UA Apps: Extended Security Maintenance (ESM)", + auto_enabled=True, ), services) self.assertNotIn(UbuntuProService( name="cis", description="Center for Internet Security Audit Tools", + auto_enabled=False, ), services) # Test with "Z" suffix for the expiration date. diff --git a/subiquity/server/ubuntu_advantage.py b/subiquity/server/ubuntu_advantage.py index eb973315..65e11d8d 100644 --- a/subiquity/server/ubuntu_advantage.py +++ b/subiquity/server/ubuntu_advantage.py @@ -174,6 +174,7 @@ class UAInterface: return UbuntuProService( name=service["name"], description=service["description"], + auto_enabled=service["auto_enabled"] == "yes", ) activable_services: List[UbuntuProService] = []