gandi.cli icon indicating copy to clipboard operation
gandi.cli copied to clipboard

add json format when listing vms

Open bib0x opened this issue 3 years ago • 2 comments

This PR aims to add JSON output and some network information when listing VM.

So, you can customize the default text output using jq such as:

(gandi.cli) $ cat /tmp/vm_info.jq
{
    "hostname": .hostname,
    "ips": [
        .ifaces[].ips[].ip
    ]
}

(gandi.cli) $ gandi vm list --format json | jq -f /tmp/vm_info.jq
{
  "hostname": "test-sd5",
  "ips": [
    "46.xxx.xxx.xxx",
    "2001:4b98:xxx"
  ]
}
{
  "hostname": "test-sd6",
  "ips": [
    "46.xxx.xxx.xxx",
    "2001:4b98:xxx"
  ]
}

Pretty useful to avoid loop over gandi vm info <resource> output to just gather basic network information.

bib0x avatar May 03 '21 10:05 bib0x

Coverage Status

Coverage increased (+0.008%) to 90.751% when pulling 24e8b5960c2493a70637708fc35c79eda8ceb863 on bib0x:vm-list-json-output into bfe2e6f44135b7fbac50f9f44b5e58577583d07d on Gandi:master.

coveralls avatar May 03 '21 10:05 coveralls

+1 LGTM

aegiap avatar May 05 '21 08:05 aegiap