Class: Server
Instance Attribute Summary
#config
Instance Method Summary
collapse
#ask_number, #bootstrap_server, #bootstrap_server_interactive, #print_options
exit_on_failure?
Instance Method Details
#bootstrap ⇒ Object
76
77
78
|
# File 'lib/cloudstack-cli/commands/server.rb', line 76
def bootstrap
bootstrap_server_interactive
end
|
#create(name) ⇒ Object
50
51
52
|
# File 'lib/cloudstack-cli/commands/server.rb', line 50
def create(name)
bootstrap_server(options.merge({name: name}))
end
|
#destroy(*name) ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/cloudstack-cli/commands/server.rb', line 57
def destroy(*name)
projectid = find_project['id'] if options[:project]
name.each do |server_name|
server = client.get_server(server_name, projectid)
unless server
say "Server #{server_name} not found.", :red
else
ask = "Destroy #{server_name} (#{server['state']})?"
if options[:force] == true || yes?(ask, :yellow)
say "destroying #{server_name} "
client.destroy_server(server["id"])
puts
end
end
end
end
|
#list ⇒ Object
7
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
|
# File 'lib/cloudstack-cli/commands/server.rb', line 7
def list
if options[:project]
if options[:project].downcase == "all"
options[:project_id] = -1
else
project = find_project
options[:project_id] = project['id']
end
end
servers = client.list_servers(options)
if servers.size < 1
puts "No servers found."
else
table = [["Name", "State", "Offering", "Zone", options[:project] ? "Project" : "Account", "IP's"]]
servers.each do |server|
table << [
server['name'],
server['state'],
server['serviceofferingname'],
server['zonename'],
options[:project] ? server['project'] : server['account'],
server['nic'].map { |nic| nic['ipaddress']}.join(' ')
]
end
print_table table
end
end
|
#restart(name) ⇒ Object
93
94
95
96
|
# File 'lib/cloudstack-cli/commands/server.rb', line 93
def restart(name)
client.reboot_server(name)
puts
end
|
#start(name) ⇒ Object
87
88
89
90
|
# File 'lib/cloudstack-cli/commands/server.rb', line 87
def start(name)
client.start_server(name)
puts
end
|
#stop(name) ⇒ Object
81
82
83
84
|
# File 'lib/cloudstack-cli/commands/server.rb', line 81
def stop(name)
client.stop_server(name)
puts
end
|