[Merge] ~mitchburton/ubuntu/+source/landscape-client:ubuntu/lunar-devel into ubuntu/+source/landscape-client:ubuntu/lunar-devel

Andreas Hasenack mp+437634 at code.launchpad.net
Thu Feb 23 22:20:16 UTC 2023



Diff comments:

> diff --git a/landscape/client/monitor/ubuntuproinfo.py b/landscape/client/monitor/ubuntuproinfo.py
> new file mode 100644
> index 0000000..4f78999
> --- /dev/null
> +++ b/landscape/client/monitor/ubuntuproinfo.py
> @@ -0,0 +1,47 @@
> +import json
> +import subprocess
> +
> +from landscape.client.monitor.plugin import DataWatcher
> +
> +
> +class UbuntuProInfo(DataWatcher):
> +    """
> +    Plugin that captures and reports Ubuntu Pro registration
> +    information.
> +
> +    We use the `ua` CLI with output formatted as JSON. This is sent
> +    as-is and parsed by Landscape Server because the JSON content is
> +    considered "Experimental" and we don't want to have to change in
> +    both Client and Server in the event that the format changes.
> +    """
> +
> +    run_interval = 900  # 15 minutes
> +    message_type = "ubuntu-pro-info"
> +    message_key = message_type
> +    persist_name = message_type
> +    scope = "ubuntu-pro"
> +    run_immediately = True
> +
> +    def get_data(self):
> +        ubuntu_pro_info = get_ubuntu_pro_info()
> +
> +        return json.dumps(ubuntu_pro_info, separators=(",", ":"))
> +
> +
> +def get_ubuntu_pro_info():
> +    try:
> +        completed_process = subprocess.run(
> +            ["ua", "status", "--format", "json"],
> +            encoding="utf8", stdout=subprocess.PIPE)
> +    except FileNotFoundError:
> +        return {
> +            "errors": [{
> +                "message": "ubuntu-advantage-tools not found.",
> +                "message_code": "tools-error",
> +                "service": None,
> +                "type": "system",
> +            }],
> +            "result": "failure",

yes, or make a new "upstream" release. But we don't need that now: since it will be a bugfix, we can do it after lunar's feature freeze.

> +        }
> +    else:
> +        return json.loads(completed_process.stdout)


-- 
https://code.launchpad.net/~mitchburton/ubuntu/+source/landscape-client/+git/landscape-client/+merge/437634
Your team Ubuntu Sponsors Team is requested to review the proposed merge of ~mitchburton/ubuntu/+source/landscape-client:ubuntu/lunar-devel into ubuntu/+source/landscape-client:ubuntu/lunar-devel.




More information about the Ubuntu-sponsors mailing list