Class: Chef::Knife::ProxmoxTemplateList
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- Chef::Knife::ProxmoxTemplateList
- Includes:
- ProxmoxBase
- Defined in:
- lib/chef/knife/proxmox_template_list.rb
Instance Method Summary collapse
Methods included from ProxmoxBase
#action_response, #check_config_parameter, #check_global_parameter, #connection, #destroy_item, included, #locate_config_value, #new_vmid, #server_create, #server_destroy, #server_get_data, #server_name_to_vmid, #server_start, #server_stop, #template_number_to_name, #vmid_to_node, #waitfor
Instance Method Details
#run ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/chef/knife/proxmox_template_list.rb', line 11 def run # Needed to initialize @connection and @auth_params connection template_list = [ ui.color('Id' , :bold), ui.color('Name', :bold), ui.color('Size', :bold) ] @connection["nodes/#{Chef::Config[:knife][:pve_node_name]}/storage/local/content"].get @auth_params do |response, request, result, &block| template_index = 0 JSON.parse(response.body)['data'].each { |entry| if entry['content'] == 'vztmpl' then template_list << template_index.to_s template_list << entry['volid'] template_list << (entry['size'].to_i/1048576).to_s + " MB" template_index+=1 end } end puts ui.list(template_list, :uneven_columns_across, 3) end |