Corrected patch to drop unused livepatch_is_enabled.
Ran it through python3 -m flake8 and pyflakes and tested on focal machines which were attached, unattached both with and without the cache file /var/lib/ubuntu-advantage/status.json cache file (which forces a subprocess call to "ua status --format=json"
Below is my manual test run output:
root@dev-f:~# # install hello package which is provided as well from ESM repos
root@dev-f:~# apt install hello=2.10-2ubuntu2
Reading package lists... Done
Building dependency tree
Reading state information... Done
hello is already the newest version (2.10-2ubuntu2).
0 upgraded, 0 newly installed, 0 to remove and 15 not upgraded.
root@dev-f:~# apt policy hello
hello:
Installed: 2.10-2ubuntu2
Candidate: 2.10-2ubuntu2
Version table:
*** 2.10-2ubuntu2 500
500 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages
100 /var/lib/dpkg/status
root@dev-f:~# # unattached machine, no status.json cache
root@dev-f:~# [ -f /var/lib/ubuntu-advantage/status.json ] && echo JSON CACHE PRESENT || echo JSON CACHE ABSENT
JSON CACHE ABSENT
root@dev-f:~# /ubuntu-security-status
589 packages installed, of which:
586 receive package updates with LTS until 4/2025
3 could receive security updates with ESM Apps until 4/2030
Enable Extended Security Maintenance (ESM Apps) to get 1 security
update (so far) and enable coverage of 3 packages.
This machine is not attached to an Ubuntu Advantage subscription.
See https://ubuntu.com/advantage
root@dev-f:~# # JSON CACHE IS PRESENT NOW
root@dev-f:~# [ -f /var/lib/ubuntu-advantage/status.json ] && echo JSON CACHE PRESENT || echo JSON CACHE ABSENT
JSON CACHE PRESENT
root@dev-f:~# /ubuntu-security-status
589 packages installed, of which:
586 receive package updates with LTS until 4/2025
3 could receive security updates with ESM Apps until 4/2030
Enable Extended Security Maintenance (ESM Apps) to get 1 security
update (so far) and enable coverage of 3 packages.
This machine is not attached to an Ubuntu Advantage subscription.
See https://ubuntu.com/advantage
root@dev-f:~# # Now attach the machine to a UA contract
root@dev-f:~# ua attach <REDACTED_TOKEN>
Enabling default service esm-apps
Updating package lists
UA Apps: ESM enabled
Enabling default service esm-infra
Updating package lists
UA Infra: ESM enabled
This machine is now attached to 'UA Infrastructure & Applications - Essential (Virtual)'
SERVICE ENTITLED STATUS DESCRIPTION
cis yes disabled Center for Internet Security Audit Tools
esm-apps yes enabled UA Apps: Extended Security Maintenance (ESM)
esm-infra yes enabled UA Infra: Extended Security Maintenance (ESM)
fips yes disabled NIST-certified core packages
fips-updates yes disabled NIST-certified core packages with priority security updates
livepatch yes n/a Canonical Livepatch service
NOTICES
Operation in progress: ua attach
Enable services with: ua enable <service>
Account: <email address hidden> Subscription: UA Infrastructure & Applications - Essential (Virtual)
Valid until: 2022-02-23 18:11:01+00:00
Technical support level: essential
root@dev-f:~# [ -f /var/lib/ubuntu-advantage/status.json ] && echo JSON CACHE PRESENT || echo JSON CACHE ABSENT
JSON CACHE PRESENT
root@dev-f:~# /ubuntu-security-status
589 packages installed, of which:
586 receive package updates with LTS until 4/2025
3 are receiving security updates with ESM Apps until 4/2030
root@dev-f:~# # remove cached status.json to be sure attached status correct
root@dev-f:~# rm /var/lib/ubuntu-advantage/status.json
root@dev-f:~# [ -f /var/lib/ubuntu-advantage/status.json ] && echo JSON CACHE PRESENT || echo JSON CACHE ABSENT
JSON CACHE ABSENT
root@dev-f:~# /ubuntu-security-status
589 packages installed, of which:
586 receive package updates with LTS until 4/2025
3 are receiving security updates with ESM Apps until 4/2030
Corrected patch to drop unused livepatch_ is_enabled. ubuntu- advantage/ status. json cache file (which forces a subprocess call to "ua status --format=json"
Ran it through python3 -m flake8 and pyflakes and tested on focal machines which were attached, unattached both with and without the cache file /var/lib/
Below is my manual test run output: archive. ubuntu. com/ubuntu focal/main amd64 Packages dpkg/status ubuntu- advantage/ status. json ] && echo JSON CACHE PRESENT || echo JSON CACHE ABSENT security- status
root@dev-f:~# # install hello package which is provided as well from ESM repos
root@dev-f:~# apt install hello=2.10-2ubuntu2
Reading package lists... Done
Building dependency tree
Reading state information... Done
hello is already the newest version (2.10-2ubuntu2).
0 upgraded, 0 newly installed, 0 to remove and 15 not upgraded.
root@dev-f:~# apt policy hello
hello:
Installed: 2.10-2ubuntu2
Candidate: 2.10-2ubuntu2
Version table:
*** 2.10-2ubuntu2 500
500 http://
100 /var/lib/
root@dev-f:~# # unattached machine, no status.json cache
root@dev-f:~# [ -f /var/lib/
JSON CACHE ABSENT
root@dev-f:~# /ubuntu-
589 packages installed, of which:
586 receive package updates with LTS until 4/2025
3 could receive security updates with ESM Apps until 4/2030
Enable Extended Security Maintenance (ESM Apps) to get 1 security
update (so far) and enable coverage of 3 packages.
This machine is not attached to an Ubuntu Advantage subscription. /ubuntu. com/advantage ubuntu- advantage/ status. json ] && echo JSON CACHE PRESENT || echo JSON CACHE ABSENT security- status
See https:/
root@dev-f:~# # JSON CACHE IS PRESENT NOW
root@dev-f:~# [ -f /var/lib/
JSON CACHE PRESENT
root@dev-f:~# /ubuntu-
589 packages installed, of which:
586 receive package updates with LTS until 4/2025
3 could receive security updates with ESM Apps until 4/2030
Enable Extended Security Maintenance (ESM Apps) to get 1 security
update (so far) and enable coverage of 3 packages.
This machine is not attached to an Ubuntu Advantage subscription. /ubuntu. com/advantage
See https:/
root@dev-f:~# # Now attach the machine to a UA contract
root@dev-f:~# ua attach <REDACTED_TOKEN>
Enabling default service esm-apps
Updating package lists
UA Apps: ESM enabled
Enabling default service esm-infra
Updating package lists
UA Infra: ESM enabled
This machine is now attached to 'UA Infrastructure & Applications - Essential (Virtual)'
SERVICE ENTITLED STATUS DESCRIPTION
cis yes disabled Center for Internet Security Audit Tools
esm-apps yes enabled UA Apps: Extended Security Maintenance (ESM)
esm-infra yes enabled UA Infra: Extended Security Maintenance (ESM)
fips yes disabled NIST-certified core packages
fips-updates yes disabled NIST-certified core packages with priority security updates
livepatch yes n/a Canonical Livepatch service
NOTICES
Operation in progress: ua attach
Enable services with: ua enable <service>
Valid until: 2022-02-23 18:11:01+00:00
Technical support level: essential
root@dev-f:~# [ -f /var/lib/
JSON CACHE PRESENT
root@dev-f:~# /ubuntu-
589 packages installed, of which:
586 receive package updates with LTS until 4/2025
3 are receiving security updates with ESM Apps until 4/2030
root@dev-f:~# # remove cached status.json to be sure attached status correct
root@dev-f:~# rm /var/lib/
root@dev-f:~# [ -f /var/lib/
JSON CACHE ABSENT
root@dev-f:~# /ubuntu-
589 packages installed, of which:
586 receive package updates with LTS until 4/2025
3 are receiving security updates with ESM Apps until 4/2030