Gandi / gandi.cli

⚠ ARCHIVED - Command line interface to Gandi.net products using the public API
http://cli.gandi.net/
GNU General Public License v3.0
347 stars 62 forks source link

add json format when listing vms #312

Open bib0x opened 3 years ago

bib0x commented 3 years ago

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.

coveralls commented 3 years ago

Coverage Status

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

aegiap commented 3 years ago

+1 LGTM