About the pro status check `pro api u.pro.status.is_attached.v1 | grep -q 
true`. The 
[output](https://documentation.ubuntu.com/pro-client/en/latest/references/api/#u-pro-status-enabled-services-v1)
 is like:

```
{"_schema_version": "v1", "data": {"attributes": {"contract_remaining_days": 0, 
"contract_status": null, "is_attached": false, 
"is_attached_and_contract_valid": false}, "meta": {"environment_vars": []}, 
"type": "IsAttached"}, "errors": [], "result": "success", "version": 
"36ubuntu0~25.04", "warnings": []}
```

The only two fields that is boolean is "is_attached" and 
"is_attached_and_contract_valid", so for now it's safe to say ANY "true" <=> 
IS_ATTACHED, otherwise there are several alternative approaches for discussion:

#1 use grep/awk regex to query json output
#2 use grep to query pro status's default tabular output
#3 install jq
#4 directly detach the vm no matter attached or not and ignore the return code 
which could be either not attached vm or detach process fail
-- 
https://code.launchpad.net/~wqian/ubuntu-qa-tools/+git/ubuntu-qa-tools/+merge/490758
Your team Ubuntu Bug Control is subscribed to branch ubuntu-qa-tools:master.


_______________________________________________
Mailing list: https://launchpad.net/~ubuntu-bugcontrol
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~ubuntu-bugcontrol
More help   : https://help.launchpad.net/ListHelp

Reply via email to