class Network
Public Instance Methods
Source
# File lib/cloudstack-cli/commands/network.rb 81 def delete(name) 82 resolve_project 83 unless network = client.list_networks(options).find {|n| n['name'] == name} 84 say "Error: Network with name '#{name}' not found.", :red 85 exit 1 86 end 87 if yes? "Delete network \"#{network['name']}\"?" 88 client.delete_network(id: network['id']) 89 end 90 end
Source
# File lib/cloudstack-cli/commands/network.rb 13 def list 14 resolve_zone if options[:zone] 15 resolve_project 16 add_filters_to_options("listNetworks") if options[:filter] 17 networks = client.list_networks(options) 18 networks = filter_objects(networks) if options[:filter] 19 if networks.size < 1 20 puts "No networks found." 21 else 22 case options[:format].to_sym 23 when :yaml 24 puts({networks: networks}.to_yaml) 25 when :json 26 puts JSON.pretty_generate(networks: networks) 27 else 28 table = [%w(Name Displaytext Account/Project Zone Domain State Type Offering)] 29 table[0] << "ID" if options[:showid] 30 table[0] << "VLAN" if options[:showvlan] 31 networks.each do |network| 32 table << [ 33 network["name"], 34 network["displaytext"], 35 network["account"] || network["project"], 36 network["zonename"], 37 network["domain"], 38 network["state"], 39 network["type"], 40 network["networkofferingname"] 41 ] 42 table[-1] << network["id"] if options[:showid] 43 table[-1] << network["vlan"] if options[:showvlan] 44 end 45 print_table table 46 say "Total number of networks: #{networks.count}" 47 end 48 end 49 end
Source
# File lib/cloudstack-cli/commands/network.rb 68 def restart(name) 69 resolve_project 70 unless network = client.list_networks(options).find {|n| n['name'] == name} 71 say "Network with name '#{name}' not found." 72 exit 1 73 end 74 if yes? "Restart network \"#{network['name']}\" (cleanup=#{options[:cleanup]})?" 75 client.restart_network(id: network['id'], cleanup: options[:cleanup]) 76 end 77 end
Source
# File lib/cloudstack-cli/commands/network.rb 53 def show(name) 54 resolve_project 55 unless network = client.list_networks(options).find {|n| n['name'] == name} 56 say "Error: No network with name '#{name}' found.", :red 57 exit 58 end 59 table = network.map do |key, value| 60 [ set_color("#{key}:", :yellow), "#{value}" ] 61 end 62 print_table table 63 end