lib/cloudstack-cli/commands/volume.rb in cloudstack-cli-0.0.5 vs lib/cloudstack-cli/commands/volume.rb in cloudstack-cli-0.1.0
- old
+ new
@@ -1,20 +1,19 @@
-class Volume < Thor
- desc "volume list", "list networks"
+class Volume < CloudstackCli::Base
+
+ desc "list", "list networks"
option :project
def list
- cs_cli = CloudstackCli::Helper.new(options[:config])
- if options[:project]
- project = cs_cli.projects.select { |p| p['name'] == options[:project] }.first
- raise "Project '#{options[:project]}' not found" unless project
- end
-
- networks = cs_cli.networks(project ? project['id'] : nil)
+ project = find_project if options[:project]
+ networks = client.list_networks(project ? project['id'] : nil)
if networks.size < 1
puts "No networks found"
else
+ table = [["Name", "Displaytext", "Default?"]]
networks.each do |network|
- puts "#{network['name']} - #{network['displaytext']} #{' - Default' if network['isdefault']}"
+ table << [network['name'], network['displaytext'], network['isdefault']]
end
+ print_table(table)
end
end
+
end
\ No newline at end of file