8 def list
9 resolve_zone if options[:zone]
10 hosts = client.list_hosts(options)
11 if hosts.size < 1
12 say "No hosts found."
13 else
14 case options[:format].to_sym
15 when :yaml
16 puts({hosts: hosts}.to_yaml)
17 when :json
18 puts JSON.pretty_generate(hosts: hosts)
19 else
20 table = [["Zone", "Type", "Cluster", "Name"]]
21 hosts.each do |host|
22 table << [
23 host['zonename'], host['type'], host['clustername'], host['name']
24 ]
25 end
26 print_table table
27 say "Total number of hosts: #{hosts.size}"
28 end
29 end
30 end