lib/cloudstack-cli/commands/system_vm.rb in cloudstack-cli-1.4.1 vs lib/cloudstack-cli/commands/system_vm.rb in cloudstack-cli-1.4.2

- old
+ new

@@ -3,23 +3,32 @@ desc 'list', 'list system VMs' option :zone, desc: "the name of the availability zone" option :state, desc: "state of the system VM" option :type, desc: "the system VM type.", enum: %w(consoleproxy secondarystoragevm) + option :format, default: "table", + enum: %w(table json yaml) def list resolve_zone vms = client.list_system_vms(options) if vms.size < 1 say "No system VM's found." else - table = [%w(Name Zone State Type)] - vms.each do |vm| - table << [ - vm['name'], vm['zonename'], vm['state'], vm['systemvmtype'] - ] + case options[:format].to_sym + when :yaml + puts({system_vms: vms}.to_yaml) + when :json + puts JSON.pretty_generate(system_vms: vms) + else + table = [%w(Name Zone State Type)] + vms.each do |vm| + table << [ + vm['name'], vm['zonename'], vm['state'], vm['systemvmtype'] + ] + end + print_table table + say "Total number of system VM's: #{vms.size}" end - print_table table - say "Total number of system VM's: #{vms.size}" end end desc 'show NAME', 'show system VM' def show(name)