Method: Region#list

Defined in:
lib/cloudstack-cli/commands/region.rb

#listObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cloudstack-cli/commands/region.rb', line 6

def list
  regions = client.list_regions
  if regions.size < 1
    say "No regions found."
  else
    case options[:format].to_sym
    when :yaml
      puts({regions: regions}.to_yaml)
    when :json
      puts JSON.pretty_generate(regions: regions)
    else
      table = [%w(Name, Endpoint)]
      regions.each do |region|
        table << [
        	region['name'], region['endpoint']
        ]
      end
      print_table table
      say "Total number of regions: #{regions.size}"
    end
  end
end