Class: Chef::Knife::RightscaleServertemplateList

Inherits:
Chef::Knife
  • Object
show all
Includes:
RightscaleBase
Defined in:
lib/chef/knife/rightscale_servertemplate_list.rb

Instance Method Summary collapse

Methods included from RightscaleBase

#connection, included, #locate_config_value, #msg_pair, #right_api_client, #set_log_level

Instance Method Details

#runObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/chef/knife/rightscale_servertemplate_list.rb', line 39

def run
  $stdout.sync = true

  validate!
  
  @servertemplates = connection.list_servertemplates(:by_name, config[:server_template_name])

  servertemplate_list = [
    ui.color('Name', :bold),
    ui.color('Revision', :bold),
    ui.color('ID', :bold)
  ].flatten.compact
  
  output_column_count = servertemplate_list.length
  
  @servertemplates.each do |servertemplate|
    revision = servertemplate.revision.to_s 
    servertemplate_list << servertemplate.name
    servertemplate_list << ((revision == "0") ? "HEAD" : revision)
    servertemplate_list << servertemplate.href.to_s.delete("/api/server_templates/")
  end
  
  puts ui.list(servertemplate_list, :uneven_columns_across, output_column_count)

end