morpheus-cli 0.9.9 → 0.9.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
@@ -1,7 +1,5 @@
|
|
1
|
-
# require 'yaml'
|
2
1
|
require 'io/console'
|
3
2
|
require 'rest_client'
|
4
|
-
require 'term/ansicolor'
|
5
3
|
require 'optparse'
|
6
4
|
require 'morpheus/cli/cli_command'
|
7
5
|
require 'morpheus/cli/option_types'
|
@@ -9,7 +7,6 @@ require 'morpheus/cli/mixins/accounts_helper'
|
|
9
7
|
require 'json'
|
10
8
|
|
11
9
|
class Morpheus::Cli::KeyPairs
|
12
|
-
include Term::ANSIColor
|
13
10
|
include Morpheus::Cli::CliCommand
|
14
11
|
include Morpheus::Cli::AccountsHelper
|
15
12
|
|
@@ -20,7 +17,7 @@ class Morpheus::Cli::KeyPairs
|
|
20
17
|
def connect(opts)
|
21
18
|
@access_token = Morpheus::Cli::Credentials.new(@appliance_name,@appliance_url).request_credentials()
|
22
19
|
if @access_token.empty?
|
23
|
-
|
20
|
+
print_red_alert "Invalid Credentials. Unable to acquire access token. Please verify your credentials and try again."
|
24
21
|
exit 1
|
25
22
|
end
|
26
23
|
@api_client = Morpheus::APIClient.new(@access_token,nil,nil, @appliance_url)
|
@@ -53,12 +50,12 @@ class Morpheus::Cli::KeyPairs
|
|
53
50
|
end
|
54
51
|
|
55
52
|
def list(args)
|
53
|
+
usage = "Usage: morpheus key-pairs list [options]"
|
56
54
|
options = {}
|
57
55
|
params = {}
|
58
|
-
account = nil
|
59
56
|
optparse = OptionParser.new do|opts|
|
60
|
-
|
61
|
-
|
57
|
+
opts.banner = usage
|
58
|
+
build_common_options(opts, options, [:account, :list, :json])
|
62
59
|
end
|
63
60
|
optparse.parse(args)
|
64
61
|
connect(options)
|
@@ -86,27 +83,27 @@ class Morpheus::Cli::KeyPairs
|
|
86
83
|
print reset,"\n\n"
|
87
84
|
end
|
88
85
|
rescue RestClient::Exception => e
|
89
|
-
|
86
|
+
print_rest_exception(e, options)
|
90
87
|
exit 1
|
91
88
|
end
|
92
89
|
end
|
93
90
|
|
94
91
|
def details(args)
|
95
92
|
usage = "Usage: morpheus key-pairs details [name] [options]"
|
96
|
-
if args.count < 1
|
97
|
-
puts "\n#{usage}\n\n"
|
98
|
-
exit 1
|
99
|
-
end
|
100
|
-
account = nil
|
101
|
-
name = args[0]
|
102
93
|
options = {}
|
103
94
|
params = {}
|
104
95
|
optparse = OptionParser.new do|opts|
|
105
96
|
opts.banner = usage
|
106
|
-
|
107
|
-
Morpheus::Cli::CliCommand.genericOptions(opts,options)
|
97
|
+
build_common_options(opts, options, [:account, :json])
|
108
98
|
end
|
109
99
|
optparse.parse(args)
|
100
|
+
|
101
|
+
if args.count < 1
|
102
|
+
puts "\n#{usage}\n\n"
|
103
|
+
exit 1
|
104
|
+
end
|
105
|
+
name = args[0]
|
106
|
+
|
110
107
|
connect(options)
|
111
108
|
begin
|
112
109
|
|
@@ -121,7 +118,7 @@ class Morpheus::Cli::KeyPairs
|
|
121
118
|
exit 1 if key_pair.nil?
|
122
119
|
|
123
120
|
if options[:json]
|
124
|
-
print JSON.pretty_generate(key_pair)
|
121
|
+
print JSON.pretty_generate({keyPair: key_pair})
|
125
122
|
print "\n"
|
126
123
|
else
|
127
124
|
print "\n" ,cyan, bold, "Key Pair Details\n","==================", reset, "\n\n"
|
@@ -137,27 +134,17 @@ class Morpheus::Cli::KeyPairs
|
|
137
134
|
|
138
135
|
end
|
139
136
|
rescue RestClient::Exception => e
|
140
|
-
|
137
|
+
print_rest_exception(e, options)
|
141
138
|
exit 1
|
142
139
|
end
|
143
140
|
end
|
144
141
|
|
145
142
|
def add(args)
|
146
|
-
# if args.count > 0
|
147
|
-
# puts "\nUsage: morpheus hosts add [options]\n\n"
|
148
|
-
# exit 1
|
149
|
-
# end
|
150
|
-
account_name = nil
|
151
|
-
keypair_name = args[0]
|
152
143
|
options = {}
|
153
144
|
optparse = OptionParser.new do|opts|
|
154
145
|
opts.banner = "Usage: morpheus key-pairs add [name] [options]"
|
155
|
-
|
156
|
-
opts.on( '-a', '--account ACCOUNT', "Account Name" ) do |val|
|
157
|
-
account_name = val
|
158
|
-
end
|
159
146
|
|
160
|
-
opts.on(
|
147
|
+
opts.on('', '--public-key-file FILENAME', "Public Key File" ) do |filename|
|
161
148
|
if File.exists?(File.expand_path(filename))
|
162
149
|
options['publicKey'] = File.read(File.expand_path(filename))
|
163
150
|
options[:options] ||= {}
|
@@ -168,13 +155,13 @@ class Morpheus::Cli::KeyPairs
|
|
168
155
|
end
|
169
156
|
end
|
170
157
|
|
171
|
-
opts.on(
|
158
|
+
opts.on('', '--public-key TEXT', "Public Key Text" ) do |val|
|
172
159
|
options['publicKey'] = val
|
173
160
|
options[:options] ||= {}
|
174
161
|
options[:options]['publicKey'] = options['publicKey']
|
175
162
|
end
|
176
163
|
|
177
|
-
opts.on(
|
164
|
+
opts.on('', '--private-key-file FILENAME', "Private Key File" ) do |filename|
|
178
165
|
if File.exists?(File.expand_path(filename))
|
179
166
|
options['privateKey'] = File.read(File.expand_path(filename))
|
180
167
|
options[:options] ||= {}
|
@@ -185,14 +172,15 @@ class Morpheus::Cli::KeyPairs
|
|
185
172
|
end
|
186
173
|
end
|
187
174
|
|
188
|
-
opts.on(
|
175
|
+
opts.on('', '--private-key TEXT', "Private Key Text" ) do |val|
|
189
176
|
options['privateKey'] = val
|
190
177
|
options[:options] ||= {}
|
191
178
|
options[:options]['privateKey'] = options['privateKey']
|
192
179
|
end
|
193
180
|
|
194
|
-
|
181
|
+
build_common_options(opts, options, [:account, :options, :json])
|
195
182
|
end
|
183
|
+
|
196
184
|
if args.count < 1
|
197
185
|
puts "\n#{optparse}\n\n"
|
198
186
|
exit 1
|
@@ -203,15 +191,10 @@ class Morpheus::Cli::KeyPairs
|
|
203
191
|
|
204
192
|
begin
|
205
193
|
|
206
|
-
|
207
|
-
account = nil
|
208
|
-
if !account_name.nil?
|
209
|
-
account = find_account_by_name(account_name)
|
210
|
-
exit 1 if account.nil?
|
211
|
-
end
|
194
|
+
account = find_account_from_options(options)
|
212
195
|
account_id = account ? account['id'] : nil
|
213
196
|
|
214
|
-
params = Morpheus::Cli::OptionTypes.prompt(add_key_pair_option_types, options[:options], @api_client, options[:params])
|
197
|
+
params = Morpheus::Cli::OptionTypes.prompt(add_key_pair_option_types, options[:options], @api_client, options[:params])
|
215
198
|
|
216
199
|
if !params['publicKey']
|
217
200
|
print_red_alert "publicKey is required"
|
@@ -225,49 +208,45 @@ class Morpheus::Cli::KeyPairs
|
|
225
208
|
key_pair_payload = params.select {|k,v| ['name','publicKey', 'privateKey'].include?(k) }
|
226
209
|
|
227
210
|
request_payload = {keyPair: key_pair_payload}
|
228
|
-
|
229
|
-
|
211
|
+
json_response = @key_pairs_interface.create(account_id, request_payload)
|
212
|
+
if options[:json]
|
213
|
+
print JSON.pretty_generate(json_response)
|
214
|
+
print "\n"
|
215
|
+
else
|
216
|
+
print_green_success "Key Pair #{key_pair_payload['name']} added"
|
217
|
+
end
|
230
218
|
rescue RestClient::Exception => e
|
231
|
-
|
219
|
+
print_rest_exception(e, options)
|
232
220
|
exit 1
|
233
221
|
end
|
234
222
|
end
|
235
223
|
|
236
224
|
def update(args)
|
237
|
-
usage = "Usage: morpheus
|
238
|
-
if args.count < 1
|
239
|
-
puts "\n#{usage}\n\n"
|
240
|
-
exit 1
|
241
|
-
end
|
242
|
-
account_name = nil
|
243
|
-
name = args[0]
|
225
|
+
usage = "Usage: morpheus key-pairs update [name] [options]"
|
244
226
|
options = {}
|
245
227
|
optparse = OptionParser.new do|opts|
|
246
228
|
opts.banner = usage
|
247
|
-
|
248
|
-
opts.on( '-a', '--account ACCOUNT', "Account Name" ) do |val|
|
249
|
-
account_name = val
|
250
|
-
end
|
251
|
-
|
252
|
-
Morpheus::Cli::CliCommand.genericOptions(opts,options)
|
229
|
+
build_common_options(opts, options, [:account, :options, :json])
|
253
230
|
end
|
254
231
|
optparse.parse(args)
|
255
232
|
|
233
|
+
if args.count < 1
|
234
|
+
puts "\n#{usage}\n\n"
|
235
|
+
exit 1
|
236
|
+
end
|
237
|
+
name = args[0]
|
238
|
+
|
256
239
|
connect(options)
|
257
240
|
|
258
241
|
begin
|
259
242
|
|
260
|
-
|
261
|
-
|
262
|
-
account = find_account_by_name(account_name)
|
263
|
-
exit 1 if account.nil?
|
264
|
-
account_id = account['id']
|
265
|
-
end
|
243
|
+
account = find_account_from_options(options)
|
244
|
+
account_id = account ? account['id'] : nil
|
266
245
|
|
267
246
|
key_pair = ((name.to_s =~ /\A\d{1,}\Z/) ? find_key_pair_by_id(account_id, name) : find_key_pair_by_name(account_id, name) )
|
268
247
|
exit 1 if key_pair.nil?
|
269
248
|
|
270
|
-
#params = Morpheus::Cli::OptionTypes.prompt(update_key_pair_option_types, options[:options], @api_client, options[:params])
|
249
|
+
#params = Morpheus::Cli::OptionTypes.prompt(update_key_pair_option_types, options[:options], @api_client, options[:params])
|
271
250
|
params = options[:options] || {}
|
272
251
|
|
273
252
|
if params.empty?
|
@@ -279,51 +258,55 @@ class Morpheus::Cli::KeyPairs
|
|
279
258
|
|
280
259
|
key_pair_payload = params.select {|k,v| ['name'].include?(k) }
|
281
260
|
request_payload = {keyPair: key_pair_payload}
|
282
|
-
|
283
|
-
|
261
|
+
json_response = @key_pairs_interface.update(account_id, key_pair['id'], request_payload)
|
262
|
+
if options[:json]
|
263
|
+
print JSON.pretty_generate(json_response)
|
264
|
+
print "\n"
|
265
|
+
else
|
266
|
+
print_green_success "Key Pair #{key_pair_payload['name'] || key_pair['name']} updated"
|
267
|
+
end
|
284
268
|
rescue RestClient::Exception => e
|
285
|
-
|
269
|
+
print_rest_exception(e, options)
|
286
270
|
exit 1
|
287
271
|
end
|
288
272
|
end
|
289
273
|
|
290
274
|
def remove(args)
|
291
275
|
usage = "Usage: morpheus key-pairs remove [name]"
|
276
|
+
options = {}
|
277
|
+
optparse = OptionParser.new do|opts|
|
278
|
+
opts.banner = usage
|
279
|
+
build_common_options(opts, options, [:account, :auto_confirm, :json])
|
280
|
+
end
|
281
|
+
optparse.parse(args)
|
282
|
+
|
292
283
|
if args.count < 1
|
293
284
|
puts "\n#{usage}\n\n"
|
294
285
|
exit 1
|
295
286
|
end
|
296
|
-
account_name = nil
|
297
287
|
name = args[0]
|
298
|
-
options = {}
|
299
|
-
optparse = OptionParser.new do|opts|
|
300
|
-
opts.banner = usage
|
301
288
|
|
302
|
-
opts.on( '-a', '--account ACCOUNT', "Account Name or ID" ) do |val|
|
303
|
-
account_name = val
|
304
|
-
end
|
305
|
-
|
306
|
-
Morpheus::Cli::CliCommand.genericOptions(opts,options)
|
307
|
-
end
|
308
|
-
optparse.parse(args)
|
309
289
|
connect(options)
|
310
290
|
begin
|
311
291
|
# current user account by default
|
312
|
-
account =
|
313
|
-
if !account_name.nil?
|
314
|
-
account = find_account_by_name(account_name)
|
315
|
-
exit 1 if account.nil?
|
316
|
-
end
|
292
|
+
account = find_account_from_options(options)
|
317
293
|
account_id = account ? account['id'] : nil
|
318
294
|
# allow finding by ID since name is not unique!
|
319
295
|
key_pair = ((name.to_s =~ /\A\d{1,}\Z/) ? find_key_pair_by_id(account_id, name) : find_key_pair_by_name(account_id, name) )
|
320
296
|
exit 1 if key_pair.nil?
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
297
|
+
unless options[:yes] || Morpheus::Cli::OptionTypes.confirm("Are you sure you want to delete the key pair #{key_pair['name']}?")
|
298
|
+
exit
|
299
|
+
end
|
300
|
+
json_response = @key_pairs_interface.destroy(account_id, key_pair['id'])
|
301
|
+
if options[:json]
|
302
|
+
print JSON.pretty_generate(json_response)
|
303
|
+
print "\n"
|
304
|
+
else
|
305
|
+
print_green_success "Key Pair #{key_pair['name']} removed"
|
306
|
+
# list([])
|
307
|
+
end
|
325
308
|
rescue RestClient::Exception => e
|
326
|
-
|
309
|
+
print_rest_exception(e, options)
|
327
310
|
exit 1
|
328
311
|
end
|
329
312
|
end
|
data/lib/morpheus/cli/license.rb
CHANGED
@@ -1,14 +1,12 @@
|
|
1
|
-
# require 'yaml'
|
2
1
|
require 'io/console'
|
3
2
|
require 'rest_client'
|
4
|
-
require 'term/ansicolor'
|
5
3
|
require 'optparse'
|
6
4
|
require 'table_print'
|
7
5
|
require 'morpheus/cli/cli_command'
|
8
6
|
|
9
7
|
class Morpheus::Cli::License
|
10
8
|
include Morpheus::Cli::CliCommand
|
11
|
-
|
9
|
+
|
12
10
|
def initialize()
|
13
11
|
@appliance_name, @appliance_url = Morpheus::Cli::Remote.active_appliance
|
14
12
|
end
|
@@ -25,7 +23,7 @@ class Morpheus::Cli::License
|
|
25
23
|
@license_interface = Morpheus::APIClient.new(@access_token,nil,nil, @appliance_url).license
|
26
24
|
|
27
25
|
if @access_token.empty?
|
28
|
-
|
26
|
+
print_red_alert "Invalid Credentials. Unable to acquire access token. Please verify your credentials and try again."
|
29
27
|
exit 1
|
30
28
|
end
|
31
29
|
end
|
@@ -53,7 +51,7 @@ class Morpheus::Cli::License
|
|
53
51
|
options = {}
|
54
52
|
optparse = OptionParser.new do|opts|
|
55
53
|
opts.banner = "Usage: morpheus license details"
|
56
|
-
|
54
|
+
build_common_options(opts, options, [:json, :remote])
|
57
55
|
end
|
58
56
|
optparse.parse(args)
|
59
57
|
connect(options)
|
@@ -80,7 +78,7 @@ class Morpheus::Cli::License
|
|
80
78
|
print reset,"\n\n"
|
81
79
|
end
|
82
80
|
rescue RestClient::Exception => e
|
83
|
-
|
81
|
+
print_rest_exception(e, options)
|
84
82
|
exit 1
|
85
83
|
end
|
86
84
|
end
|
@@ -91,7 +89,7 @@ class Morpheus::Cli::License
|
|
91
89
|
account_name = nil
|
92
90
|
optparse = OptionParser.new do|opts|
|
93
91
|
opts.banner = "Usage: morpheus license apply [key]"
|
94
|
-
|
92
|
+
build_common_options(opts, options, [:json, :remote])
|
95
93
|
end
|
96
94
|
if args.count < 1
|
97
95
|
puts "\n#{optparse.banner}\n\n"
|
@@ -110,9 +108,9 @@ class Morpheus::Cli::License
|
|
110
108
|
puts "License applied successfully!"
|
111
109
|
end
|
112
110
|
rescue RestClient::Exception => e
|
113
|
-
|
111
|
+
print_rest_exception(e, options)
|
114
112
|
exit 1
|
115
113
|
end
|
116
114
|
end
|
117
115
|
|
118
|
-
end
|
116
|
+
end
|
@@ -1,14 +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 'table_print'
|
7
6
|
require 'morpheus/cli/cli_command'
|
8
7
|
|
9
8
|
class Morpheus::Cli::LoadBalancers
|
10
9
|
include Morpheus::Cli::CliCommand
|
11
|
-
|
10
|
+
|
12
11
|
def initialize()
|
13
12
|
@appliance_name, @appliance_url = Morpheus::Cli::Remote.active_appliance
|
14
13
|
end
|
@@ -25,7 +24,7 @@ class Morpheus::Cli::LoadBalancers
|
|
25
24
|
@load_balancers_interface = Morpheus::APIClient.new(@access_token,nil,nil, @appliance_url).load_balancers
|
26
25
|
|
27
26
|
if @access_token.empty?
|
28
|
-
|
27
|
+
print_red_alert "Invalid Credentials. Unable to acquire access token. Please verify your credentials and try again."
|
29
28
|
exit 1
|
30
29
|
end
|
31
30
|
end
|
@@ -60,20 +59,14 @@ class Morpheus::Cli::LoadBalancers
|
|
60
59
|
options = {}
|
61
60
|
optparse = OptionParser.new do|opts|
|
62
61
|
opts.banner = "Usage: morpheus load-balancers list [-s] [-o] [-m]"
|
63
|
-
|
62
|
+
build_common_options(opts, options, [:list, :json, :remote])
|
64
63
|
end
|
65
64
|
optparse.parse(args)
|
66
65
|
connect(options)
|
67
66
|
begin
|
68
67
|
params = {}
|
69
|
-
|
70
|
-
params[
|
71
|
-
end
|
72
|
-
if options[:max]
|
73
|
-
params[:max] = options[:max]
|
74
|
-
end
|
75
|
-
if options[:phrase]
|
76
|
-
params[:phrase] = options[:phrase]
|
68
|
+
[:phrase, :offset, :max, :sort, :direction].each do |k|
|
69
|
+
params[k] = options[k] unless options[k].nil?
|
77
70
|
end
|
78
71
|
json_response = @load_balancers_interface.get(params)
|
79
72
|
if options[:json]
|
@@ -95,12 +88,7 @@ class Morpheus::Cli::LoadBalancers
|
|
95
88
|
|
96
89
|
|
97
90
|
rescue RestClient::Exception => e
|
98
|
-
|
99
|
-
error = JSON.parse(e.response.to_s)
|
100
|
-
::Morpheus::Cli::ErrorHandler.new.print_errors(error,options)
|
101
|
-
else
|
102
|
-
puts "Error Communicating with the Appliance. Please try again later. #{e}"
|
103
|
-
end
|
91
|
+
print_rest_exception(e, options)
|
104
92
|
exit 1
|
105
93
|
end
|
106
94
|
end
|
@@ -110,7 +98,7 @@ class Morpheus::Cli::LoadBalancers
|
|
110
98
|
options = {}
|
111
99
|
optparse = OptionParser.new do|opts|
|
112
100
|
opts.banner = "Usage: morpheus load-balancers details [name]"
|
113
|
-
|
101
|
+
build_common_options(opts, options, [:json, :remote])
|
114
102
|
end
|
115
103
|
if args.count < 1
|
116
104
|
puts "\n#{optparse.banner}\n\n"
|
@@ -133,12 +121,7 @@ class Morpheus::Cli::LoadBalancers
|
|
133
121
|
print reset,"\n\n"
|
134
122
|
end
|
135
123
|
rescue RestClient::Exception => e
|
136
|
-
|
137
|
-
error = JSON.parse(e.response.to_s)
|
138
|
-
::Morpheus::Cli::ErrorHandler.new.print_errors(error,options)
|
139
|
-
else
|
140
|
-
puts "Error Communicating with the Appliance. Please try again later. #{e}"
|
141
|
-
end
|
124
|
+
print_rest_exception(e, options)
|
142
125
|
exit 1
|
143
126
|
end
|
144
127
|
end
|
@@ -149,7 +132,7 @@ class Morpheus::Cli::LoadBalancers
|
|
149
132
|
account_name = nil
|
150
133
|
optparse = OptionParser.new do|opts|
|
151
134
|
opts.banner = "Usage: morpheus tasks update [task] [options]"
|
152
|
-
|
135
|
+
build_common_options(opts, options, [:options, :json, :remote])
|
153
136
|
end
|
154
137
|
if args.count < 1
|
155
138
|
puts "\n#{optparse.banner}\n\n"
|
@@ -199,12 +182,7 @@ class Morpheus::Cli::LoadBalancers
|
|
199
182
|
print "\n", cyan, "Task #{response['task']['name']} updated", reset, "\n\n"
|
200
183
|
end
|
201
184
|
rescue RestClient::Exception => e
|
202
|
-
|
203
|
-
error = JSON.parse(e.response.to_s)
|
204
|
-
::Morpheus::Cli::ErrorHandler.new.print_errors(error)
|
205
|
-
else
|
206
|
-
puts "Error Communicating with the Appliance. Please try again later. #{e}"
|
207
|
-
end
|
185
|
+
print_rest_exception(e, options)
|
208
186
|
exit 1
|
209
187
|
end
|
210
188
|
end
|
@@ -214,7 +192,7 @@ class Morpheus::Cli::LoadBalancers
|
|
214
192
|
options = {}
|
215
193
|
optparse = OptionParser.new do|opts|
|
216
194
|
opts.banner = "Usage: morpheus load-balancers lb-types"
|
217
|
-
|
195
|
+
build_common_options(opts, options, [:json, :remote])
|
218
196
|
end
|
219
197
|
optparse.parse(args)
|
220
198
|
connect(options)
|
@@ -239,13 +217,8 @@ class Morpheus::Cli::LoadBalancers
|
|
239
217
|
end
|
240
218
|
|
241
219
|
|
242
|
-
rescue => e
|
243
|
-
|
244
|
-
error = JSON.parse(e.response.to_s)
|
245
|
-
::Morpheus::Cli::ErrorHandler.new.print_errors(error,options)
|
246
|
-
else
|
247
|
-
puts "Error Communicating with the Appliance. Please try again later. #{e}"
|
248
|
-
end
|
220
|
+
rescue RestClient::Exception => e
|
221
|
+
print_rest_exception(e, options)
|
249
222
|
exit 1
|
250
223
|
end
|
251
224
|
end
|
@@ -259,7 +232,7 @@ class Morpheus::Cli::LoadBalancers
|
|
259
232
|
opts.on( '-t', '--type LB_TYPE', "Lb Type" ) do |val|
|
260
233
|
lb_type_name = val
|
261
234
|
end
|
262
|
-
|
235
|
+
build_common_options(opts, options, [:options, :json, :remote])
|
263
236
|
end
|
264
237
|
if args.count < 1
|
265
238
|
puts "\n#{optparse.banner}\n\n"
|
@@ -288,7 +261,7 @@ class Morpheus::Cli::LoadBalancers
|
|
288
261
|
print "\n", cyan, "LB #{json_response['loadBalancer']['name']} created successfully", reset, "\n\n"
|
289
262
|
end
|
290
263
|
rescue RestClient::Exception => e
|
291
|
-
|
264
|
+
print_rest_exception(e, options)
|
292
265
|
exit 1
|
293
266
|
end
|
294
267
|
end
|
@@ -298,7 +271,7 @@ class Morpheus::Cli::LoadBalancers
|
|
298
271
|
options = {}
|
299
272
|
optparse = OptionParser.new do|opts|
|
300
273
|
opts.banner = "Usage: morpheus load-balancers remove [name]"
|
301
|
-
|
274
|
+
build_common_options(opts, options, [:auto_confirm, :json, :remote])
|
302
275
|
end
|
303
276
|
if args.count < 1
|
304
277
|
puts "\n#{optparse.banner}\n\n"
|
@@ -309,7 +282,9 @@ class Morpheus::Cli::LoadBalancers
|
|
309
282
|
begin
|
310
283
|
lb = find_lb_by_name(lb_name)
|
311
284
|
exit 1 if lb.nil?
|
312
|
-
|
285
|
+
unless options[:yes] || Morpheus::Cli::OptionTypes.confirm("Are you sure you want to delete the load balancer #{lb['name']}?")
|
286
|
+
exit
|
287
|
+
end
|
313
288
|
json_response = @load_balancers_interface.destroy(lb['id'])
|
314
289
|
if options[:json]
|
315
290
|
print JSON.pretty_generate(json_response)
|
@@ -317,12 +292,7 @@ class Morpheus::Cli::LoadBalancers
|
|
317
292
|
print "\n", cyan, "Load Balancer #{lb['name']} removed", reset, "\n\n"
|
318
293
|
end
|
319
294
|
rescue RestClient::Exception => e
|
320
|
-
|
321
|
-
error = JSON.parse(e.response.to_s)
|
322
|
-
::Morpheus::Cli::ErrorHandler.new.print_errors(error,options)
|
323
|
-
else
|
324
|
-
puts "Error Communicating with the Appliance. Please try again later. #{e}"
|
325
|
-
end
|
295
|
+
print_rest_exception(e, options)
|
326
296
|
exit 1
|
327
297
|
end
|
328
298
|
end
|
@@ -340,7 +310,7 @@ private
|
|
340
310
|
result = results['loadBalancer']
|
341
311
|
end
|
342
312
|
if result.nil?
|
343
|
-
|
313
|
+
print_red_alert "LB not found by '#{val}'"
|
344
314
|
return nil
|
345
315
|
end
|
346
316
|
return result
|
@@ -357,10 +327,10 @@ private
|
|
357
327
|
result = results['loadBalancerType']
|
358
328
|
end
|
359
329
|
if result.nil?
|
360
|
-
|
330
|
+
print_red_alert "LB Type not found by '#{val}'"
|
361
331
|
return nil
|
362
332
|
end
|
363
333
|
return result
|
364
334
|
end
|
365
335
|
|
366
|
-
end
|
336
|
+
end
|