lib/cloudstack-cli/commands/network.rb in cloudstack-cli-0.3.7 vs lib/cloudstack-cli/commands/network.rb in cloudstack-cli-0.3.8

- old
+ new

@@ -18,10 +18,31 @@ table[-1] << network["id"] if options[:showid] print_table table end end + desc "show NAME", "show detailed infos about a network" + option :project + def show(name) + if options[:project] + if options[:project].downcase == "all" + options[:project_id] = -1 + else + project = find_project + options[:project_id] = project['id'] + end + end + unless server = client.get_network(name, options[:project_id]) + puts "No network found." + else + server.each do |key, value| + say "#{key}: ", :yellow + say "#{value}" + end + end + end + desc "list", "list networks" option :project option :account option :showid, type: :boolean option :isdefault, type: :boolean @@ -56,17 +77,32 @@ end print_table table end end + desc "restart NAME", "restart network" + option :cleanup, type: :boolean, default: true + def restart(name) + network = client.get_network(name) + network = client.get_network(name, -1) unless network + unless network + say "Network #{name} not found." + exit 1 + end + if yes? "Restart network \"#{network['name']}\" (cleanup=#{options[:cleanup]})?" + p client.restart_network(network['id'], options[:cleanup]) + end + end + desc "delete NAME", "delete network" def delete(name) - network = client.get_network(name, -1) + network = client.get_network(name) + network = client.get_network(name, -1) unless network unless network - say "Network #{name} not found." + say "Network \"#{name}\" not found." exit 1 end - if yes? "Destroy network #{network['name']} - #{network['name']}?" + if yes? "Destroy network \"#{network['name']}\"?" p client.delete_network(network['id']) end end end \ No newline at end of file