Class: Network
Constant Summary
CloudstackCli::Helper::ASYNC_STATES
Instance Attribute Summary
#config
Instance Method Summary
collapse
exit_on_failure?
#ask_number, #bootstrap_server, #bootstrap_server_interactive, #create_port_rules, #create_server, #print_job_status, #print_options, #update_job_status, #watch_jobs
Instance Method Details
#default ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/cloudstack-cli/commands/network.rb', line 43
def default
network = client.get_default_network(options[:zone])
unless network
puts "No default network found."
else
table = [["Name", "Displaytext", "Domain", "Zone"]]
table[0] << "ID" if options[:showid]
table << [
network["name"],
network["displaytext"],
network["domain"],
network["zonename"]
]
table[-1] << network["id"] if options[:showid]
print_table table
end
end
|
#delete(name) ⇒ Object
97
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/cloudstack-cli/commands/network.rb', line 97
def delete(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? "Destroy network \"#{network['name']}\"?"
p client.delete_network(network['id'])
end
end
|
#list ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/cloudstack-cli/commands/network.rb', line 8
def list
project = find_project if options[:project]
networks = []
if project
networks = client.list_networks(project_id: project['id'])
elsif options[:account]
networks = client.list_networks(account: options[:account])
else
networks = client.list_networks(isdefault: options[:isdefault])
networks += client.list_networks(project_id: -1, isdefault: options[:isdefault])
end
if networks.size < 1
puts "No networks found."
else
table = [["Name", "Displaytext", "Account", "Project", "Domain", "State", "Type"]]
table[0] << "ID" if options[:showid]
networks.each do |network|
table << [
network["name"],
network["displaytext"],
network["account"],
network["project"],
network["domain"],
network["state"],
network["type"]
]
table[-1] << network["id"] if options[:showid]
end
print_table table
end
end
|
#restart(name) ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/cloudstack-cli/commands/network.rb', line 84
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
|
#show(name) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/cloudstack-cli/commands/network.rb', line 63
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
|