64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/chef/knife/cs_template_list.rb', line 64
def run
connection = CloudstackClient::Connection.new(
locate_config_value(:cloudstack_url),
locate_config_value(:cloudstack_api_key),
locate_config_value(:cloudstack_secret_key)
)
template_list = [
ui.color('ID', :bold),
ui.color('Name', :bold),
ui.color('Size', :bold),
ui.color('Zone', :bold),
ui.color('Public', :bold),
ui.color('Created', :bold),
]
filter = config[:filter]
templates = connection.list_templates(filter)
templates.each do |t|
template_list << t['id']
template_list << t['name']
template_list << (human_file_size(t['size']) || 'Unknown')
template_list << t['zonename']
template_list << t['ispublic'].to_s
template_list << t['created']
end
if config[:output_type].eql? "table"
puts ui.list(template_list, :columns_across, 6)
else
puts templates.to_json
end
end
|