class Host

Public Instance Methods

list() click to toggle source
   # File lib/cloudstack-cli/commands/host.rb
 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
show(name) click to toggle source
   # File lib/cloudstack-cli/commands/host.rb
33 def show(name)
34   unless host = client.list_hosts(name: name).first
35     say "No host with name '#{name}' found."
36   else
37     table = host.map do |key, value|
38       [ set_color("#{key}:", :yellow), "#{value}" ]
39     end
40     print_table table
41   end
42 end