mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-26 05:28:40 -05:00
Add --json option for floaty get
This option will return structured output from `floaty get`, which is
easier to parse in some cases.
Example output:
```json
{
"centos-7-x86_64": [
"hpfhhf5aqxowfd8.delivery.puppetlabs.net",
"k65euywltpz9fz0.delivery.puppetlabs.net"
],
"centos-6-x86_64": [
"oahunrurl7xis05.delivery.puppetlabs.net"
]
}
```
This commit is contained in:
parent
837fa94af5
commit
50eeb8f265
3 changed files with 53 additions and 28 deletions
|
|
@ -35,6 +35,7 @@ class Vmfloaty
|
|||
c.option '--token STRING', String, 'Token for pooler service'
|
||||
c.option '--notoken', 'Makes a request without a token'
|
||||
c.option '--force', 'Forces vmfloaty to get requested vms'
|
||||
c.option '--json', 'Prints retrieved vms in JSON format'
|
||||
c.action do |args, options|
|
||||
verbose = options.verbose || config['verbose']
|
||||
service = Service.new(options, config)
|
||||
|
|
@ -62,7 +63,12 @@ class Vmfloaty
|
|||
end
|
||||
|
||||
response = service.retrieve(verbose, os_types, use_token)
|
||||
puts Utils.format_hosts(response)
|
||||
hosts = Utils.standardize_hostnames(response)
|
||||
if options.json
|
||||
puts JSON.pretty_generate(hosts)
|
||||
else
|
||||
puts Utils.format_host_output(hosts)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue