Class: Server
Instance Attribute Summary
#config
Instance Method Summary
collapse
exit_on_failure?
#ask_number, #bootstrap_server, #bootstrap_server_interactive, #get_async_job_status, #print_options, #watch_jobs
Instance Method Details
#bootstrap ⇒ Object
74
75
76
|
# File 'lib/cloudstack-cli/commands/server.rb', line 74
def bootstrap
bootstrap_server_interactive
end
|
#create(name) ⇒ Object
49
50
51
|
# File 'lib/cloudstack-cli/commands/server.rb', line 49
def create(name)
bootstrap_server(options.merge({name: name}))
end
|
#destroy(*names) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/cloudstack-cli/commands/server.rb', line 56
def destroy(*names)
projectid = find_project['id'] if options[:project]
names.each do |name|
server = client.get_server(name, projectid)
unless server
say "Server #{name} not found.", :red
else
ask = "Destroy #{name} (#{server['state']})?"
if options[:force] || yes?(ask, :yellow)
say "destroying #{name} "
client.destroy_server(server["id"])
puts
end
end
end
end
|
#list ⇒ Object
6
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
|
# File 'lib/cloudstack-cli/commands/server.rb', line 6
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
91
92
93
94
|
# File 'lib/cloudstack-cli/commands/server.rb', line 91
def restart(name)
client.reboot_server(name)
puts
end
|
#start(name) ⇒ Object
85
86
87
88
|
# File 'lib/cloudstack-cli/commands/server.rb', line 85
def start(name)
client.start_server(name)
puts
end
|
#stop(name) ⇒ Object
79
80
81
82
|
# File 'lib/cloudstack-cli/commands/server.rb', line 79
def stop(name)
client.stop_server(name)
puts
end
|