class Template

Public Instance Methods

list(type='featured') click to toggle source
   # File lib/cloudstack-cli/commands/template.rb
11 def list(type='featured')
12   resolve_project
13   resolve_zone
14   options[:template_filter] = options[:type]
15   templates = client.list_templates(options)
16   if templates.size < 1
17     puts "No templates found."
18   else
19     case options[:format].to_sym
20     when :yaml
21       puts({templates: templates}.to_yaml)
22     when :json
23       puts JSON.pretty_generate(templates: templates)
24     else
25       table = [%w(Name Created Zone Featured Public Format)]
26       templates.each do |template|
27         table << [
28           template['name'],
29           (Time.parse(template['created']).strftime("%F") rescue "-"),
30           template['zonename'],
31           template['isfeatured'],
32           template['ispublic'],
33           template['format']
34         ]
35       end
36       print_table(table)
37       say "Total number of templates: #{templates.size}"
38     end
39   end
40 end