lib/cloudstack-cli/commands/volume.rb in cloudstack-cli-0.5.4 vs lib/cloudstack-cli/commands/volume.rb in cloudstack-cli-0.5.5

- old
+ new

@@ -1,20 +1,30 @@ class Volume < CloudstackCli::Base desc "list", "list volumes" - option :project + option :project, desc: 'list resources by project' + option :account, desc: 'list resources by account' + option :keyword, desc: 'list by keyword' + option :name, desc: 'name of the disk volume' + option :type, desc: 'type of disk volume (ROOT or DATADISK)' def list - projectid = find_project['id'] if options[:project] - volumes = client.list_volumes(projectid) + if options[:project] + projectid = find_project['id'] + options[:project_id] = projectid if projectid + end + volumes = client.list_volumes(options) if volumes.size < 1 - puts "No volumes found." + say "No volumes found." else - table = [["Name", "Type", "Size", "VM", "Storage", "Offeringname"]] + table = [%w(Name Type Size VM Storage Offeringname)] volumes.each do |volume| - table << [volume['name'], volume['type'], + table << [ + volume['name'], volume['type'], (volume['size'] / 1024**3).to_s + 'GB', volume['vmname'], - volume['storage'], volume['diskofferingname']] + volume['storage'], + volume['diskofferingname'] + ] end print_table(table) end end \ No newline at end of file