Class: Template

Inherits:
Thor
  • Object
show all
Defined in:
lib/cloudstack-cli/commands/template.rb

Instance Method Summary collapse

Instance Method Details

#list(type = 'featured') ⇒ Object



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

def list(type='featured')
  cs_cli = CloudstackCli::Helper.new(options[:config])
  
  if options[:project]
    project = cs_cli.projects.select { |p| p['name'] == options[:project] }.first
    exit_now! "Project '#{options[:project]}' not found" unless project
  end
  
  exit_now! "unsupported template type '#{type}'" unless
    %w(featured self self-executable executable community).include? type
  templates = cs_cli.templates(type, project ? project['id'] : nil)
  if templates.size < 1
    puts "No templates found"
  else
    templates.each do |template|
      puts template['name']
    end
  end
end