morpheus-cli 0.9.9 → 0.9.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/morpheus/api/api_client.rb +4 -0
- data/lib/morpheus/api/app_templates_interface.rb +74 -0
- data/lib/morpheus/api/instance_types_interface.rb +9 -0
- data/lib/morpheus/api/instances_interface.rb +16 -0
- data/lib/morpheus/api/roles_interface.rb +37 -1
- data/lib/morpheus/cli.rb +4 -1
- data/lib/morpheus/cli/accounts.rb +82 -58
- data/lib/morpheus/cli/app_templates.rb +908 -0
- data/lib/morpheus/cli/apps.rb +226 -187
- data/lib/morpheus/cli/cli_command.rb +57 -30
- data/lib/morpheus/cli/clouds.rb +50 -65
- data/lib/morpheus/cli/deployments.rb +18 -33
- data/lib/morpheus/cli/deploys.rb +1 -3
- data/lib/morpheus/cli/groups.rb +54 -38
- data/lib/morpheus/cli/hosts.rb +86 -80
- data/lib/morpheus/cli/instance_types.rb +42 -29
- data/lib/morpheus/cli/instances.rb +192 -69
- data/lib/morpheus/cli/key_pairs.rb +70 -87
- data/lib/morpheus/cli/license.rb +7 -9
- data/lib/morpheus/cli/load_balancers.rb +23 -53
- data/lib/morpheus/cli/mixins/accounts_helper.rb +7 -8
- data/lib/morpheus/cli/mixins/print_helper.rb +67 -0
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +461 -0
- data/lib/morpheus/cli/option_types.rb +71 -18
- data/lib/morpheus/cli/roles.rb +725 -34
- data/lib/morpheus/cli/security_group_rules.rb +50 -70
- data/lib/morpheus/cli/security_groups.rb +61 -48
- data/lib/morpheus/cli/shell.rb +123 -14
- data/lib/morpheus/cli/tasks.rb +24 -59
- data/lib/morpheus/cli/users.rb +86 -71
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli/virtual_images.rb +21 -51
- data/lib/morpheus/cli/workflows.rb +14 -29
- data/lib/morpheus/ext/nil_class.rb +5 -0
- data/lib/morpheus/formatters.rb +1 -0
- metadata +7 -3
- data/lib/morpheus/cli/error_handler.rb +0 -44
data/lib/morpheus/cli/deploys.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# require 'yaml'
|
2
2
|
require 'io/console'
|
3
3
|
require 'rest_client'
|
4
|
-
require 'term/ansicolor'
|
5
4
|
require 'optparse'
|
6
5
|
require 'filesize'
|
7
6
|
require 'table_print'
|
@@ -9,7 +8,6 @@ require 'morpheus/cli/cli_command'
|
|
9
8
|
|
10
9
|
class Morpheus::Cli::Deploys
|
11
10
|
include Morpheus::Cli::CliCommand
|
12
|
-
include Term::ANSIColor
|
13
11
|
|
14
12
|
cli_command_name :deploy
|
15
13
|
|
@@ -24,7 +22,7 @@ class Morpheus::Cli::Deploys
|
|
24
22
|
|
25
23
|
def handle(args)
|
26
24
|
if @access_token.empty?
|
27
|
-
|
25
|
+
print_red_alert "Invalid Credentials. Unable to acquire access token. Please verify your credentials and try again."
|
28
26
|
return 1
|
29
27
|
end
|
30
28
|
|
data/lib/morpheus/cli/groups.rb
CHANGED
@@ -1,14 +1,12 @@
|
|
1
|
-
|
1
|
+
require 'yaml'
|
2
2
|
require 'io/console'
|
3
3
|
require 'rest_client'
|
4
|
-
require 'term/ansicolor'
|
5
4
|
require 'optparse'
|
6
5
|
require 'table_print'
|
7
6
|
require 'morpheus/cli/cli_command'
|
8
7
|
|
9
8
|
class Morpheus::Cli::Groups
|
10
9
|
include Morpheus::Cli::CliCommand
|
11
|
-
include Term::ANSIColor
|
12
10
|
|
13
11
|
def initialize()
|
14
12
|
@appliance_name, @appliance_url = Morpheus::Cli::Remote.active_appliance
|
@@ -20,7 +18,7 @@ class Morpheus::Cli::Groups
|
|
20
18
|
|
21
19
|
def handle(args)
|
22
20
|
if @access_token.empty?
|
23
|
-
|
21
|
+
print_red_alert "Invalid Credentials. Unable to acquire access token. Please verify your credentials and try again."
|
24
22
|
return 1
|
25
23
|
end
|
26
24
|
if args.empty?
|
@@ -43,61 +41,72 @@ class Morpheus::Cli::Groups
|
|
43
41
|
end
|
44
42
|
|
45
43
|
def add(args)
|
46
|
-
|
47
|
-
puts "\nUsage: morpheus groups add [name] [--location]\n\n"
|
48
|
-
return
|
49
|
-
end
|
44
|
+
options = {}
|
50
45
|
params = {}
|
51
46
|
optparse = OptionParser.new do|opts|
|
47
|
+
opts.banner = "Usage: morpheus groups add [name] [--location]"
|
52
48
|
opts.on( '-l', '--location LOCATION', "Location" ) do |desc|
|
53
49
|
params[:location] = desc
|
54
50
|
end
|
51
|
+
build_common_options(opts, options, [])
|
55
52
|
end
|
56
53
|
optparse.parse(args)
|
57
|
-
|
54
|
+
if args.count < 1
|
55
|
+
puts "\n#{optparse.banner}\n\n"
|
56
|
+
exit 1
|
57
|
+
end
|
58
58
|
group = {name: args[0], location: params[:location]}
|
59
59
|
begin
|
60
60
|
@groups_interface.create(group)
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
else
|
66
|
-
puts "Error Communicating with the Appliance. Please try again later. #{e}"
|
67
|
-
end
|
68
|
-
return nil
|
61
|
+
list([])
|
62
|
+
rescue RestClient::Exception => e
|
63
|
+
print_rest_exception(e, options)
|
64
|
+
exit 1
|
69
65
|
end
|
70
|
-
list([])
|
71
66
|
end
|
72
67
|
|
73
68
|
def remove(args)
|
69
|
+
options = {}
|
70
|
+
optparse = OptionParser.new do|opts|
|
71
|
+
opts.banner = "Usage: morpheus groups remove [name]"
|
72
|
+
build_common_options(opts, options, [:auto_confirm])
|
73
|
+
end
|
74
|
+
optparse.parse(args)
|
74
75
|
if args.count < 1
|
75
|
-
puts "\
|
76
|
-
|
76
|
+
puts "\n#{optparse.banner}\n\n"
|
77
|
+
exit 1
|
77
78
|
end
|
78
79
|
|
79
80
|
begin
|
80
81
|
group_results = @groups_interface.get(args[0])
|
81
82
|
if group_results['groups'].empty?
|
82
|
-
|
83
|
-
|
83
|
+
print_red_alert "Group not found by name #{args[0]}"
|
84
|
+
exit 1
|
85
|
+
end
|
86
|
+
unless options[:yes] || Morpheus::Cli::OptionTypes.confirm("Are you sure you want to delete the group #{group_results['groups'][0]['name']}?")
|
87
|
+
exit
|
84
88
|
end
|
85
89
|
@groups_interface.destroy(group_results['groups'][0]['id'])
|
86
90
|
list([])
|
87
91
|
rescue RestClient::Exception => e
|
88
|
-
|
89
|
-
|
90
|
-
::Morpheus::Cli::ErrorHandler.new.print_errors(error)
|
91
|
-
else
|
92
|
-
puts "Error Communicating with the Appliance. Please try again later. #{e}"
|
93
|
-
end
|
94
|
-
return nil
|
92
|
+
print_rest_exception(e, options)
|
93
|
+
exit 1
|
95
94
|
end
|
96
95
|
end
|
97
96
|
|
98
97
|
def list(args)
|
98
|
+
options = {}
|
99
|
+
optparse = OptionParser.new do|opts|
|
100
|
+
opts.banner = "Usage: morpheus groups list"
|
101
|
+
build_common_options(opts, options, [:json])
|
102
|
+
end
|
103
|
+
optparse.parse(args)
|
99
104
|
begin
|
100
105
|
json_response = @groups_interface.get()
|
106
|
+
if options[:json]
|
107
|
+
print JSON.pretty_generate(json_response)
|
108
|
+
return
|
109
|
+
end
|
101
110
|
groups = json_response['groups']
|
102
111
|
print "\n" ,cyan, bold, "Morpheus Groups\n","==================", reset, "\n\n"
|
103
112
|
if groups.empty?
|
@@ -113,15 +122,22 @@ class Morpheus::Cli::Groups
|
|
113
122
|
end
|
114
123
|
print reset,"\n\n"
|
115
124
|
|
116
|
-
rescue => e
|
117
|
-
|
118
|
-
|
125
|
+
rescue RestClient::Exception => e
|
126
|
+
print_rest_exception(e, options)
|
127
|
+
exit 1
|
119
128
|
end
|
120
129
|
end
|
121
130
|
|
122
|
-
def use(args)
|
131
|
+
def use(args)
|
132
|
+
options = {}
|
133
|
+
optparse = OptionParser.new do|opts|
|
134
|
+
opts.banner = "Usage: morpheus groups use [name]"
|
135
|
+
build_common_options(opts, options, [])
|
136
|
+
end
|
137
|
+
optparse.parse(args)
|
123
138
|
if args.length < 1
|
124
|
-
puts "
|
139
|
+
puts "\n#{optparse.banner}\n\n"
|
140
|
+
exit 1
|
125
141
|
end
|
126
142
|
begin
|
127
143
|
json_response = @groups_interface.get(args[0])
|
@@ -131,11 +147,11 @@ class Morpheus::Cli::Groups
|
|
131
147
|
::Morpheus::Cli::Groups.save_groups(@active_groups)
|
132
148
|
list([])
|
133
149
|
else
|
134
|
-
|
150
|
+
print_red_alert "Group not found by name #{args[0]}"
|
135
151
|
end
|
136
|
-
rescue => e
|
137
|
-
|
138
|
-
|
152
|
+
rescue RestClient::Exception => e
|
153
|
+
print_rest_exception(e, options)
|
154
|
+
exit 1
|
139
155
|
end
|
140
156
|
end
|
141
157
|
|
data/lib/morpheus/cli/hosts.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
# require 'yaml'
|
2
2
|
require 'io/console'
|
3
3
|
require 'rest_client'
|
4
|
-
require 'term/ansicolor'
|
5
4
|
require 'optparse'
|
6
5
|
require 'morpheus/cli/cli_command'
|
7
6
|
require 'morpheus/cli/option_types'
|
8
7
|
require 'json'
|
9
8
|
|
10
9
|
class Morpheus::Cli::Hosts
|
11
|
-
|
12
|
-
include Morpheus::Cli::CliCommand
|
10
|
+
include Morpheus::Cli::CliCommand
|
13
11
|
|
14
12
|
def initialize()
|
15
13
|
@appliance_name, @appliance_url = Morpheus::Cli::Remote.active_appliance
|
@@ -33,15 +31,16 @@ class Morpheus::Cli::Hosts
|
|
33
31
|
@logs_interface = Morpheus::APIClient.new(@access_token,nil,nil, @appliance_url).logs
|
34
32
|
@cloud_types = @clouds_interface.cloud_types['zoneTypes']
|
35
33
|
if @access_token.empty?
|
36
|
-
|
34
|
+
print_red_alert "Invalid Credentials. Unable to acquire access token. Please verify your credentials and try again."
|
37
35
|
exit 1
|
38
36
|
end
|
39
37
|
end
|
40
38
|
|
41
39
|
def handle(args)
|
40
|
+
usage = "Usage: morpheus hosts [list,add,remove,logs,start,stop,run-workflow,make-managed,upgrade-agent,server-types] [name]"
|
42
41
|
if args.empty?
|
43
|
-
puts "\
|
44
|
-
exit
|
42
|
+
puts "\n#{usage}\n\n"
|
43
|
+
exit 127
|
45
44
|
end
|
46
45
|
|
47
46
|
case args[0]
|
@@ -64,7 +63,7 @@ class Morpheus::Cli::Hosts
|
|
64
63
|
when 'server-types'
|
65
64
|
server_types(args[1..-1])
|
66
65
|
else
|
67
|
-
puts "\
|
66
|
+
puts "\n#{usage}\n\n"
|
68
67
|
exit 127 #Command now foud exit code
|
69
68
|
end
|
70
69
|
end
|
@@ -73,11 +72,11 @@ class Morpheus::Cli::Hosts
|
|
73
72
|
options = {}
|
74
73
|
optparse = OptionParser.new do|opts|
|
75
74
|
opts.banner = "Usage: morpheus hosts logs [name]"
|
76
|
-
|
75
|
+
build_common_options(opts, options, [:list, :json, :remote])
|
77
76
|
end
|
78
77
|
if args.count < 1
|
79
78
|
puts "\n#{optparse.banner}\n\n"
|
80
|
-
|
79
|
+
exit 1
|
81
80
|
end
|
82
81
|
optparse.parse(args)
|
83
82
|
connect(options)
|
@@ -85,7 +84,7 @@ class Morpheus::Cli::Hosts
|
|
85
84
|
host = find_host_by_name(args[0])
|
86
85
|
logs = @logs_interface.server_logs([host['id']], { max: options[:max] || 100, offset: options[:offset] || 0, query: options[:phrase]})
|
87
86
|
if options[:json]
|
88
|
-
|
87
|
+
print JSON.pretty_generate(logs)
|
89
88
|
else
|
90
89
|
logs['data'].reverse.each do |log_entry|
|
91
90
|
log_level = ''
|
@@ -106,27 +105,22 @@ class Morpheus::Cli::Hosts
|
|
106
105
|
print reset,"\n"
|
107
106
|
end
|
108
107
|
rescue RestClient::Exception => e
|
109
|
-
|
108
|
+
print_rest_exception(e, options)
|
110
109
|
exit 1
|
111
110
|
end
|
112
111
|
end
|
113
112
|
|
114
113
|
def server_types(args)
|
115
|
-
if args.count < 1
|
116
|
-
puts "\nUsage: morpheus hosts server-types CLOUD\n\n"
|
117
|
-
exit 1
|
118
|
-
end
|
119
114
|
options = {zone: args[0]}
|
120
|
-
|
121
115
|
optparse = OptionParser.new do|opts|
|
122
|
-
opts.banner = "Usage: morpheus server
|
123
|
-
opts
|
124
|
-
options[:server_type] = server_type
|
125
|
-
end
|
126
|
-
Morpheus::Cli::CliCommand.genericOptions(opts,options)
|
116
|
+
opts.banner = "Usage: morpheus hosts server-types CLOUD"
|
117
|
+
build_common_options(opts, options, [:json, :remote])
|
127
118
|
end
|
128
|
-
|
129
119
|
optparse.parse(args)
|
120
|
+
if args.count < 1
|
121
|
+
puts "\n#{optparse.banner}\n\n"
|
122
|
+
exit 1
|
123
|
+
end
|
130
124
|
connect(options)
|
131
125
|
params = {}
|
132
126
|
|
@@ -138,23 +132,23 @@ class Morpheus::Cli::Hosts
|
|
138
132
|
end
|
139
133
|
|
140
134
|
if zone.nil?
|
141
|
-
|
135
|
+
print_red_alert "Cloud not found"
|
142
136
|
exit 1
|
143
137
|
else
|
144
138
|
zone_type = cloud_type_for_id(zone['zoneTypeId'])
|
145
139
|
end
|
146
|
-
|
140
|
+
cloud_server_types = zone_type['serverTypes'].select{|b| b['creatable'] == true}
|
147
141
|
if options[:json]
|
148
|
-
print JSON.pretty_generate(
|
142
|
+
print JSON.pretty_generate(cloud_server_types)
|
149
143
|
print "\n"
|
150
144
|
else
|
151
145
|
|
152
|
-
print "\n" ,
|
153
|
-
if
|
146
|
+
print "\n" ,cyan, bold, "Morpheus Server Types\n","==================", reset, "\n\n"
|
147
|
+
if cloud_server_types.nil? || cloud_server_types.empty?
|
154
148
|
puts yellow,"No server types found for the selected cloud.",reset
|
155
149
|
else
|
156
|
-
|
157
|
-
print
|
150
|
+
cloud_server_types.each do |server_type|
|
151
|
+
print cyan, "= #{server_type['code']} - #{server_type['name']}\n"
|
158
152
|
end
|
159
153
|
end
|
160
154
|
print reset,"\n\n"
|
@@ -167,11 +161,11 @@ class Morpheus::Cli::Hosts
|
|
167
161
|
name = args[1]
|
168
162
|
|
169
163
|
optparse = OptionParser.new do|opts|
|
170
|
-
opts.banner = "Usage: morpheus hosts add CLOUD NAME
|
171
|
-
opts.on( '-t', '--type TYPE', "
|
164
|
+
opts.banner = "Usage: morpheus hosts add CLOUD NAME [options]"
|
165
|
+
opts.on( '-t', '--type TYPE', "Server Type" ) do |server_type|
|
172
166
|
options[:server_type] = server_type
|
173
167
|
end
|
174
|
-
|
168
|
+
build_common_options(opts, options, [:options, :json, :remote])
|
175
169
|
end
|
176
170
|
if args.count < 2
|
177
171
|
puts "\n#{optparse}\n\n"
|
@@ -190,36 +184,51 @@ class Morpheus::Cli::Hosts
|
|
190
184
|
end
|
191
185
|
|
192
186
|
if zone.nil?
|
193
|
-
|
194
|
-
|
187
|
+
print_red_alert "Either the cloud was not specified or was not found. Please make sure a cloud is specified at the beginning of the argument."
|
188
|
+
exit 1
|
195
189
|
else
|
196
190
|
zone_type = cloud_type_for_id(zone['zoneTypeId'])
|
197
191
|
end
|
198
|
-
|
192
|
+
|
193
|
+
cloud_server_types = zone_type['serverTypes'].select{|b| b['creatable'] == true }
|
194
|
+
if options[:server_type]
|
195
|
+
server_type_code = options[:server_type]
|
196
|
+
else
|
197
|
+
server_type_options = cloud_server_types.collect {|it| {'name' => it['name'], 'value' => it['code']} }
|
198
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'type', 'type' => 'select', 'fieldLabel' => "Server Type", 'selectOptions' => server_type_options, 'required' => true, 'skipSingleOption' => true, 'description' => 'Choose a server type.'}], options[:options])
|
199
|
+
server_type_code = v_prompt['type']
|
200
|
+
end
|
201
|
+
|
202
|
+
server_type = cloud_server_types.find {|it| it['code'] == server_type_code }
|
203
|
+
|
204
|
+
if server_type.nil?
|
205
|
+
print_red_alert "Server Type #{server_type_code} not found cloud #{zone['name']}"
|
206
|
+
exit 1
|
207
|
+
end
|
208
|
+
|
199
209
|
params = Morpheus::Cli::OptionTypes.prompt(server_type['optionTypes'],options[:options],@api_client, options[:params])
|
200
210
|
begin
|
201
211
|
params['server'] = params['server'] || {}
|
202
212
|
server_payload = {server: {name: name, zone: {id: zone['id']}, computeServerType: [id: server_type['id']]}.merge(params['server']), config: params['config'], network: params['network']}
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
::Morpheus::Cli::ErrorHandler.new.print_errors(error)
|
213
|
+
json_response = @servers_interface.create(server_payload)
|
214
|
+
if options[:json]
|
215
|
+
print JSON.pretty_generate(json_response)
|
216
|
+
print "\n"
|
208
217
|
else
|
209
|
-
|
218
|
+
print_green_success "Provisioning Server..."
|
219
|
+
list([])
|
210
220
|
end
|
221
|
+
rescue RestClient::Exception => e
|
222
|
+
print_rest_exception(e, options)
|
211
223
|
exit 1
|
212
224
|
end
|
213
225
|
end
|
214
226
|
|
215
227
|
def remove(args)
|
216
|
-
if args.count < 1
|
217
|
-
puts "\nUsage: morpheus hosts remove [name] [-c CLOUD] [-f] [-S]\n\n"
|
218
|
-
return
|
219
|
-
end
|
220
228
|
options = {}
|
221
229
|
query_params = {removeResources: 'on', force: 'off'}
|
222
230
|
optparse = OptionParser.new do|opts|
|
231
|
+
opts.banner = "Usage: morpheus hosts remove [name] [-c CLOUD] [-f] [-S]"
|
223
232
|
opts.on( '-c', '--cloud CLOUD', "Cloud" ) do |cloud|
|
224
233
|
options[:zone] = cloud
|
225
234
|
end
|
@@ -230,9 +239,13 @@ class Morpheus::Cli::Hosts
|
|
230
239
|
query_params[:removeResources] = 'off'
|
231
240
|
end
|
232
241
|
|
233
|
-
|
242
|
+
build_common_options(opts, options, [:auto_confirm, :json, :remote])
|
234
243
|
end
|
235
244
|
optparse.parse(args)
|
245
|
+
if args.count < 1
|
246
|
+
puts "\n#{optparse.banner}\n\n"
|
247
|
+
exit 1
|
248
|
+
end
|
236
249
|
connect(options)
|
237
250
|
zone=nil
|
238
251
|
if !options[:zone].nil?
|
@@ -264,7 +277,7 @@ class Morpheus::Cli::Hosts
|
|
264
277
|
|
265
278
|
end
|
266
279
|
|
267
|
-
|
280
|
+
unless options[:yes] || ::Morpheus::Cli::OptionTypes::confirm("Are you sure you would like to remove this server?", options)
|
268
281
|
exit 1
|
269
282
|
end
|
270
283
|
|
@@ -273,15 +286,11 @@ class Morpheus::Cli::Hosts
|
|
273
286
|
print JSON.pretty_generate(json_response)
|
274
287
|
print "\n"
|
275
288
|
else
|
276
|
-
|
289
|
+
print_green_success "Removing Server..."
|
290
|
+
list([])
|
277
291
|
end
|
278
292
|
rescue RestClient::Exception => e
|
279
|
-
|
280
|
-
error = JSON.parse(e.response.to_s)
|
281
|
-
::Morpheus::Cli::ErrorHandler.new.print_errors(error)
|
282
|
-
else
|
283
|
-
puts "Error Communicating with the Appliance. Please try again later. #{e}"
|
284
|
-
end
|
293
|
+
print_rest_exception(e, options)
|
285
294
|
exit 1
|
286
295
|
end
|
287
296
|
end
|
@@ -290,11 +299,12 @@ class Morpheus::Cli::Hosts
|
|
290
299
|
options = {}
|
291
300
|
params = {}
|
292
301
|
optparse = OptionParser.new do|opts|
|
302
|
+
opts.banner = "Usage: morpheus hosts list"
|
293
303
|
opts.on( '-g', '--group GROUP', "Group Name" ) do |group|
|
294
304
|
options[:group] = group
|
295
305
|
end
|
296
306
|
|
297
|
-
|
307
|
+
build_common_options(opts, options, [:list, :json, :remote])
|
298
308
|
end
|
299
309
|
optparse.parse(args)
|
300
310
|
connect(options)
|
@@ -306,22 +316,18 @@ class Morpheus::Cli::Hosts
|
|
306
316
|
params['site'] = group['id']
|
307
317
|
end
|
308
318
|
end
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
if !options[:offset].nil?
|
313
|
-
params['offset'] = options[:offset]
|
314
|
-
end
|
315
|
-
if !options[:phrase].nil?
|
316
|
-
params['phrase'] = options[:phrase]
|
319
|
+
|
320
|
+
[:phrase, :offset, :max, :sort, :direction].each do |k|
|
321
|
+
params[k] = options[k] unless options[k].nil?
|
317
322
|
end
|
323
|
+
|
318
324
|
json_response = @servers_interface.get(params)
|
319
325
|
servers = json_response['servers']
|
320
326
|
if options[:json]
|
321
327
|
print JSON.pretty_generate(json_response)
|
322
328
|
print "\n"
|
323
329
|
else
|
324
|
-
print "\n" ,
|
330
|
+
print "\n" ,cyan, bold, "Morpheus Hosts\n","==================", reset, "\n\n"
|
325
331
|
if servers.empty?
|
326
332
|
puts yellow,"No hosts currently configured.",reset
|
327
333
|
else
|
@@ -330,23 +336,23 @@ class Morpheus::Cli::Hosts
|
|
330
336
|
server_table =servers.collect do |server|
|
331
337
|
power_state = nil
|
332
338
|
if server['powerState'] == 'on'
|
333
|
-
power_state = "#{green}ON#{
|
339
|
+
power_state = "#{green}ON#{cyan}"
|
334
340
|
elsif server['powerState'] == 'off'
|
335
|
-
power_state = "#{red}OFF#{
|
341
|
+
power_state = "#{red}OFF#{cyan}"
|
336
342
|
else
|
337
|
-
power_state = "#{white}#{server['powerState'].upcase}#{
|
343
|
+
power_state = "#{white}#{server['powerState'].upcase}#{cyan}"
|
338
344
|
end
|
339
345
|
{id: server['id'], name: server['name'], platform: server['serverOs'] ? server['serverOs']['name'].upcase : 'N/A', type: server['computeServerType'] ? server['computeServerType']['name'] : 'unmanaged', status: server['status'], power: power_state}
|
340
|
-
# print
|
346
|
+
# print cyan, "= [#{server['id']}] #{server['name']} - #{server['computeServerType'] ? server['computeServerType']['name'] : 'unmanaged'} (#{server['status']}) Power: ", power_state, "\n"
|
341
347
|
end
|
342
348
|
end
|
343
|
-
print
|
349
|
+
print cyan
|
344
350
|
tp server_table, :id, :name, :type, :platform, :status, :power
|
345
351
|
print reset,"\n\n"
|
346
352
|
end
|
347
|
-
rescue => e
|
348
|
-
|
349
|
-
|
353
|
+
rescue RestClient::Exception => e
|
354
|
+
print_rest_exception(e, options)
|
355
|
+
exit 1
|
350
356
|
end
|
351
357
|
end
|
352
358
|
|
@@ -355,7 +361,7 @@ class Morpheus::Cli::Hosts
|
|
355
361
|
options = {}
|
356
362
|
optparse = OptionParser.new do|opts|
|
357
363
|
opts.banner = "Usage: morpheus hosts start [name]"
|
358
|
-
|
364
|
+
build_common_options(opts, options, [:json, :remote])
|
359
365
|
end
|
360
366
|
if args.count < 1
|
361
367
|
puts "\n#{optparse.banner}\n\n"
|
@@ -374,7 +380,7 @@ class Morpheus::Cli::Hosts
|
|
374
380
|
end
|
375
381
|
return
|
376
382
|
rescue RestClient::Exception => e
|
377
|
-
|
383
|
+
print_rest_exception(e, options)
|
378
384
|
exit 1
|
379
385
|
end
|
380
386
|
end
|
@@ -383,7 +389,7 @@ class Morpheus::Cli::Hosts
|
|
383
389
|
options = {}
|
384
390
|
optparse = OptionParser.new do|opts|
|
385
391
|
opts.banner = "Usage: morpheus hosts stop [name]"
|
386
|
-
|
392
|
+
build_common_options(opts, options, [:json, :remote])
|
387
393
|
end
|
388
394
|
if args.count < 1
|
389
395
|
puts "\n#{optparse.banner}\n\n"
|
@@ -402,7 +408,7 @@ class Morpheus::Cli::Hosts
|
|
402
408
|
end
|
403
409
|
return
|
404
410
|
rescue RestClient::Exception => e
|
405
|
-
|
411
|
+
print_rest_exception(e, options)
|
406
412
|
exit 1
|
407
413
|
end
|
408
414
|
end
|
@@ -411,7 +417,7 @@ class Morpheus::Cli::Hosts
|
|
411
417
|
options = {}
|
412
418
|
optparse = OptionParser.new do|opts|
|
413
419
|
opts.banner = "Usage: morpheus hosts upgrade [name]"
|
414
|
-
|
420
|
+
build_common_options(opts, options, [:json, :remote])
|
415
421
|
end
|
416
422
|
if args.count < 1
|
417
423
|
puts "\n#{optparse.banner}\n\n"
|
@@ -430,7 +436,7 @@ class Morpheus::Cli::Hosts
|
|
430
436
|
end
|
431
437
|
return
|
432
438
|
rescue RestClient::Exception => e
|
433
|
-
|
439
|
+
print_rest_exception(e, options)
|
434
440
|
exit 1
|
435
441
|
end
|
436
442
|
end
|
@@ -440,7 +446,7 @@ class Morpheus::Cli::Hosts
|
|
440
446
|
|
441
447
|
optparse = OptionParser.new do|opts|
|
442
448
|
opts.banner = "Usage: morpheus hosts run-workflow [HOST] [name] [options]"
|
443
|
-
|
449
|
+
build_common_options(opts, options, [:json, :remote])
|
444
450
|
end
|
445
451
|
if args.count < 2
|
446
452
|
puts "\n#{optparse}\n\n"
|
@@ -484,7 +490,7 @@ class Morpheus::Cli::Hosts
|
|
484
490
|
puts "Running workflow..."
|
485
491
|
end
|
486
492
|
rescue RestClient::Exception => e
|
487
|
-
|
493
|
+
print_rest_exception(e, options)
|
488
494
|
exit 1
|
489
495
|
end
|
490
496
|
end
|