Sha256: e22e1d5c3b4d316b96866c740ee72c18d5e0f2ed3636f242b276f71315a03a78

Contents?: true

Size: 1.11 KB

Versions: 25

Compression:

Stored size: 1.11 KB

Contents

class Host < CloudstackCli::Base

  desc 'list', 'list hosts'
  option :zone, desc: "lists hosts by zone"
  option :type, desc: "the host type"
  option :format, default: "table",
    enum: %w(table json yaml)
  def list
    resolve_zone if options[:zone]
    hosts = client.list_hosts(options)
    if hosts.size < 1
      say "No hosts found."
    else
      case options[:format].to_sym
      when :yaml
        puts({hosts: hosts}.to_yaml)
      when :json
        puts JSON.pretty_generate(hosts: hosts)
      else
        table = [["Zone", "Type", "Cluster", "Name"]]
        hosts.each do |host|
          table << [
          	host['zonename'], host['type'], host['clustername'], host['name']
          ]
        end
        print_table table
        say "Total number of hosts: #{hosts.size}"
      end
    end
  end

  desc 'show', 'show host details'
  def show(name)
    unless host = client.list_hosts(name: name).first
      say "No host with name '#{name}' found."
    else
      table = host.map do |key, value|
        [ set_color("#{key}:", :yellow), "#{value}" ]
      end
      print_table table
    end
  end

end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
cloudstack-cli-1.6.10 lib/cloudstack-cli/commands/host.rb
cloudstack-cli-1.6.9 lib/cloudstack-cli/commands/host.rb
cloudstack-cli-1.6.8 lib/cloudstack-cli/commands/host.rb
cloudstack-cli-1.6.7 lib/cloudstack-cli/commands/host.rb
cloudstack-cli-1.6.6 lib/cloudstack-cli/commands/host.rb
cloudstack-cli-1.6.5 lib/cloudstack-cli/commands/host.rb
cloudstack-cli-1.6.4 lib/cloudstack-cli/commands/host.rb
cloudstack-cli-1.6.3 lib/cloudstack-cli/commands/host.rb
cloudstack-cli-1.6.2 lib/cloudstack-cli/commands/host.rb
cloudstack-cli-1.6.1 lib/cloudstack-cli/commands/host.rb
cloudstack-cli-1.6.0 lib/cloudstack-cli/commands/host.rb
cloudstack-cli-1.5.13 lib/cloudstack-cli/commands/host.rb
cloudstack-cli-1.5.12 lib/cloudstack-cli/commands/host.rb
cloudstack-cli-1.5.10 lib/cloudstack-cli/commands/host.rb
cloudstack-cli-1.5.9 lib/cloudstack-cli/commands/host.rb
cloudstack-cli-1.5.8 lib/cloudstack-cli/commands/host.rb
cloudstack-cli-1.5.7 lib/cloudstack-cli/commands/host.rb
cloudstack-cli-1.5.6 lib/cloudstack-cli/commands/host.rb
cloudstack-cli-1.5.5 lib/cloudstack-cli/commands/host.rb
cloudstack-cli-1.5.4 lib/cloudstack-cli/commands/host.rb