morpheus-cli 4.2.16 → 4.2.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Dockerfile +1 -1
- data/README.md +8 -6
- data/lib/morpheus/api/api_client.rb +32 -14
- data/lib/morpheus/api/auth_interface.rb +4 -2
- data/lib/morpheus/api/backup_jobs_interface.rb +9 -0
- data/lib/morpheus/api/backups_interface.rb +16 -0
- data/lib/morpheus/api/deploy_interface.rb +25 -56
- data/lib/morpheus/api/deployments_interface.rb +43 -54
- data/lib/morpheus/api/doc_interface.rb +57 -0
- data/lib/morpheus/api/instances_interface.rb +5 -0
- data/lib/morpheus/api/rest_interface.rb +40 -0
- data/lib/morpheus/api/user_sources_interface.rb +0 -15
- data/lib/morpheus/api/users_interface.rb +2 -3
- data/lib/morpheus/benchmarking.rb +2 -2
- data/lib/morpheus/cli.rb +3 -1
- data/lib/morpheus/cli/access_token_command.rb +27 -10
- data/lib/morpheus/cli/apps.rb +21 -15
- data/lib/morpheus/cli/backup_jobs_command.rb +276 -0
- data/lib/morpheus/cli/backups_command.rb +271 -0
- data/lib/morpheus/cli/boot_scripts_command.rb +1 -1
- data/lib/morpheus/cli/cli_command.rb +92 -41
- data/lib/morpheus/cli/clusters.rb +0 -18
- data/lib/morpheus/cli/commands/standard/benchmark_command.rb +7 -7
- data/lib/morpheus/cli/commands/standard/man_command.rb +1 -1
- data/lib/morpheus/cli/credentials.rb +13 -9
- data/lib/morpheus/cli/deploy.rb +374 -0
- data/lib/morpheus/cli/deployments.rb +521 -197
- data/lib/morpheus/cli/deploys.rb +271 -126
- data/lib/morpheus/cli/doc.rb +182 -0
- data/lib/morpheus/cli/error_handler.rb +23 -8
- data/lib/morpheus/cli/errors.rb +3 -2
- data/lib/morpheus/cli/image_builder_command.rb +2 -2
- data/lib/morpheus/cli/instances.rb +136 -17
- data/lib/morpheus/cli/invoices_command.rb +51 -38
- data/lib/morpheus/cli/library_layouts_command.rb +1 -1
- data/lib/morpheus/cli/login.rb +9 -3
- data/lib/morpheus/cli/mixins/accounts_helper.rb +158 -100
- data/lib/morpheus/cli/mixins/backups_helper.rb +115 -0
- data/lib/morpheus/cli/mixins/deployments_helper.rb +135 -0
- data/lib/morpheus/cli/mixins/option_source_helper.rb +1 -1
- data/lib/morpheus/cli/mixins/print_helper.rb +110 -74
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +2 -2
- data/lib/morpheus/cli/mixins/whoami_helper.rb +19 -6
- data/lib/morpheus/cli/network_routers_command.rb +1 -1
- data/lib/morpheus/cli/option_parser.rb +48 -5
- data/lib/morpheus/cli/option_types.rb +1 -1
- data/lib/morpheus/cli/remote.rb +3 -2
- data/lib/morpheus/cli/roles.rb +49 -92
- data/lib/morpheus/cli/security_groups.rb +7 -1
- data/lib/morpheus/cli/service_plans_command.rb +10 -10
- data/lib/morpheus/cli/setup.rb +1 -1
- data/lib/morpheus/cli/shell.rb +7 -6
- data/lib/morpheus/cli/subnets_command.rb +1 -1
- data/lib/morpheus/cli/tenants_command.rb +133 -163
- data/lib/morpheus/cli/user_groups_command.rb +20 -65
- data/lib/morpheus/cli/user_settings_command.rb +115 -13
- data/lib/morpheus/cli/user_sources_command.rb +57 -24
- data/lib/morpheus/cli/users.rb +210 -186
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli/whitelabel_settings_command.rb +29 -5
- data/lib/morpheus/cli/whoami.rb +113 -6
- data/lib/morpheus/cli/workflows.rb +1 -1
- data/lib/morpheus/ext/hash.rb +21 -0
- data/lib/morpheus/terminal.rb +1 -0
- metadata +12 -3
- data/lib/morpheus/cli/auth_command.rb +0 -105
@@ -2,6 +2,7 @@ require 'morpheus/cli/cli_command'
|
|
2
2
|
|
3
3
|
class Morpheus::Cli::UserSettingsCommand
|
4
4
|
include Morpheus::Cli::CliCommand
|
5
|
+
include Morpheus::Cli::AccountsHelper
|
5
6
|
|
6
7
|
set_command_name :'user-settings'
|
7
8
|
|
@@ -16,6 +17,7 @@ class Morpheus::Cli::UserSettingsCommand
|
|
16
17
|
def connect(opts)
|
17
18
|
@api_client = establish_remote_appliance_connection(opts)
|
18
19
|
@user_settings_interface = @api_client.user_settings
|
20
|
+
@users_interface = @api_client.users
|
19
21
|
end
|
20
22
|
|
21
23
|
def handle(args)
|
@@ -28,11 +30,18 @@ class Morpheus::Cli::UserSettingsCommand
|
|
28
30
|
params = {}
|
29
31
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
30
32
|
opts.banner = subcommand_usage()
|
33
|
+
opts.on("-u", "--user USER", "User username or ID") do |val|
|
34
|
+
options[:user] = val.to_s
|
35
|
+
end
|
31
36
|
opts.on("--user-id ID", String, "User ID") do |val|
|
32
37
|
params['userId'] = val.to_s
|
33
38
|
end
|
39
|
+
#opts.add_hidden_option('--user-id')
|
34
40
|
build_common_options(opts, options, [:query, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
35
|
-
opts.footer =
|
41
|
+
opts.footer = <<-EOT
|
42
|
+
Get user settings.
|
43
|
+
Done for the current user by default, unless a user is specified with the --user option.
|
44
|
+
EOT
|
36
45
|
end
|
37
46
|
optparse.parse!(args)
|
38
47
|
connect(options)
|
@@ -43,6 +52,11 @@ class Morpheus::Cli::UserSettingsCommand
|
|
43
52
|
end
|
44
53
|
|
45
54
|
begin
|
55
|
+
if options[:user]
|
56
|
+
user = find_user_by_username_or_id(nil, options[:user], {global:true})
|
57
|
+
return 1 if user.nil?
|
58
|
+
params['userId'] = user['id']
|
59
|
+
end
|
46
60
|
params.merge!(parse_list_options(options))
|
47
61
|
@user_settings_interface.setopts(options)
|
48
62
|
if options[:dry_run]
|
@@ -89,11 +103,16 @@ class Morpheus::Cli::UserSettingsCommand
|
|
89
103
|
#"ID" => lambda {|it| it['id'] },
|
90
104
|
"CLIENT ID" => lambda {|it| it['clientId'] },
|
91
105
|
"USERNAME" => lambda {|it| it['username'] },
|
106
|
+
"ACCESS TOKEN" => lambda {|it| it['maskedAccessToken'] },
|
107
|
+
"REFRESH TOKEN" => lambda {|it| it['maskedRefreshToken'] },
|
92
108
|
"EXPIRATION" => lambda {|it| format_local_dt(it['expiration']) },
|
93
109
|
"TTL" => lambda {|it| it['expiration'] ? (format_duration(it['expiration']) rescue '') : '' }
|
94
110
|
}
|
95
111
|
print cyan
|
96
112
|
puts as_pretty_table(access_tokens, cols)
|
113
|
+
else
|
114
|
+
#print "\n"
|
115
|
+
print cyan, "\n", "No API access tokens found", "\n\n"
|
97
116
|
end
|
98
117
|
|
99
118
|
print reset #, "\n"
|
@@ -111,11 +130,18 @@ class Morpheus::Cli::UserSettingsCommand
|
|
111
130
|
params = {}
|
112
131
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
113
132
|
opts.banner = subcommand_usage("[options]")
|
133
|
+
opts.on("-u", "--user USER", "User username or ID") do |val|
|
134
|
+
options[:user] = val.to_s
|
135
|
+
end
|
114
136
|
opts.on("--user-id ID", String, "User ID") do |val|
|
115
137
|
params['userId'] = val.to_s
|
116
138
|
end
|
139
|
+
#opts.add_hidden_option('--user-id')
|
117
140
|
build_common_options(opts, options, [:payload, :options, :json, :dry_run, :quiet, :remote])
|
118
|
-
opts.footer =
|
141
|
+
opts.footer = <<-EOT
|
142
|
+
Update user settings.
|
143
|
+
Done for the current user by default, unless a user is specified with the --user option.
|
144
|
+
EOT
|
119
145
|
end
|
120
146
|
optparse.parse!(args)
|
121
147
|
connect(options)
|
@@ -126,6 +152,11 @@ class Morpheus::Cli::UserSettingsCommand
|
|
126
152
|
end
|
127
153
|
|
128
154
|
begin
|
155
|
+
if options[:user]
|
156
|
+
user = find_user_by_username_or_id(nil, options[:user], {global:true})
|
157
|
+
return 1 if user.nil?
|
158
|
+
params['userId'] = user['id']
|
159
|
+
end
|
129
160
|
payload = {}
|
130
161
|
if options[:payload]
|
131
162
|
payload = options[:payload]
|
@@ -165,12 +196,19 @@ class Morpheus::Cli::UserSettingsCommand
|
|
165
196
|
params = {}
|
166
197
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
167
198
|
opts.banner = subcommand_usage("[file]")
|
199
|
+
opts.on("-u", "--user USER", "User username or ID") do |val|
|
200
|
+
options[:user] = val.to_s
|
201
|
+
end
|
168
202
|
opts.on("--user-id ID", String, "User ID") do |val|
|
169
203
|
params['userId'] = val.to_s
|
170
204
|
end
|
205
|
+
#opts.add_hidden_option('--user-id')
|
171
206
|
build_common_options(opts, options, [:json, :dry_run, :quiet, :remote])
|
172
|
-
opts.footer =
|
173
|
-
|
207
|
+
opts.footer = <<-EOT
|
208
|
+
Update avatar profile image.
|
209
|
+
[file] is required. This is the local path of a file to upload [png|jpg|svg].
|
210
|
+
Done for the current user by default, unless a user is specified with the --user option.
|
211
|
+
EOT
|
174
212
|
end
|
175
213
|
optparse.parse!(args)
|
176
214
|
connect(options)
|
@@ -191,6 +229,11 @@ class Morpheus::Cli::UserSettingsCommand
|
|
191
229
|
end
|
192
230
|
|
193
231
|
begin
|
232
|
+
if options[:user]
|
233
|
+
user = find_user_by_username_or_id(nil, options[:user], {global:true})
|
234
|
+
return 1 if user.nil?
|
235
|
+
params['userId'] = user['id']
|
236
|
+
end
|
194
237
|
@user_settings_interface.setopts(options)
|
195
238
|
if options[:dry_run]
|
196
239
|
print_dry_run @user_settings_interface.dry.update_avatar(image_file, params)
|
@@ -219,11 +262,19 @@ class Morpheus::Cli::UserSettingsCommand
|
|
219
262
|
params = {}
|
220
263
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
221
264
|
opts.banner = subcommand_usage()
|
265
|
+
opts.on("-u", "--user USER", "User username or ID") do |val|
|
266
|
+
options[:user] = val.to_s
|
267
|
+
end
|
222
268
|
opts.on("--user-id ID", String, "User ID") do |val|
|
223
269
|
params['userId'] = val.to_s
|
224
270
|
end
|
271
|
+
#opts.add_hidden_option('--user-id')
|
225
272
|
build_common_options(opts, options, [:json, :dry_run, :quiet, :remote])
|
226
|
-
opts.footer =
|
273
|
+
opts.footer = <<-EOT
|
274
|
+
Remove avatar profile image.
|
275
|
+
[file] is required. This is the local path of a file to upload [png|jpg|svg].
|
276
|
+
Done for the current user by default, unless a user is specified with the --user option.
|
277
|
+
EOT
|
227
278
|
end
|
228
279
|
optparse.parse!(args)
|
229
280
|
connect(options)
|
@@ -234,6 +285,11 @@ class Morpheus::Cli::UserSettingsCommand
|
|
234
285
|
end
|
235
286
|
|
236
287
|
begin
|
288
|
+
if options[:user]
|
289
|
+
user = find_user_by_username_or_id(nil, options[:user], {global:true})
|
290
|
+
return 1 if user.nil?
|
291
|
+
params['userId'] = user['id']
|
292
|
+
end
|
237
293
|
@user_settings_interface.setopts(options)
|
238
294
|
if options[:dry_run]
|
239
295
|
print_dry_run @user_settings_interface.dry.remove_avatar(params)
|
@@ -263,12 +319,19 @@ class Morpheus::Cli::UserSettingsCommand
|
|
263
319
|
params = {}
|
264
320
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
265
321
|
opts.banner = subcommand_usage()
|
322
|
+
opts.on("-u", "--user USER", "User username or ID") do |val|
|
323
|
+
options[:user] = val.to_s
|
324
|
+
end
|
266
325
|
opts.on("--user-id ID", String, "User ID") do |val|
|
267
326
|
params['userId'] = val.to_s
|
268
327
|
end
|
328
|
+
#opts.add_hidden_option('--user-id')
|
269
329
|
build_common_options(opts, options, [:remote])
|
270
|
-
opts.footer =
|
271
|
-
|
330
|
+
opts.footer = <<-EOT
|
331
|
+
View avatar profile image.
|
332
|
+
This opens the avatar image url with a web browser.
|
333
|
+
Done for the current user by default, unless a user is specified with the --user option.
|
334
|
+
EOT
|
272
335
|
end
|
273
336
|
optparse.parse!(args)
|
274
337
|
connect(options)
|
@@ -279,7 +342,11 @@ class Morpheus::Cli::UserSettingsCommand
|
|
279
342
|
end
|
280
343
|
|
281
344
|
begin
|
282
|
-
|
345
|
+
if options[:user]
|
346
|
+
user = find_user_by_username_or_id(nil, options[:user], {global:true})
|
347
|
+
return 1 if user.nil?
|
348
|
+
params['userId'] = user['id']
|
349
|
+
end
|
283
350
|
json_response = @user_settings_interface.get(params)
|
284
351
|
user_settings = json_response['user'] || json_response['userSettings']
|
285
352
|
|
@@ -310,12 +377,19 @@ class Morpheus::Cli::UserSettingsCommand
|
|
310
377
|
params = {}
|
311
378
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
312
379
|
opts.banner = subcommand_usage("[client-id]")
|
380
|
+
opts.on("-u", "--user USER", "User username or ID") do |val|
|
381
|
+
options[:user] = val.to_s
|
382
|
+
end
|
313
383
|
opts.on("--user-id ID", String, "User ID") do |val|
|
314
384
|
params['userId'] = val.to_s
|
315
385
|
end
|
386
|
+
#opts.add_hidden_option('--user-id')
|
316
387
|
build_common_options(opts, options, [:payload, :options, :json, :dry_run, :quiet, :remote])
|
317
|
-
opts.footer =
|
318
|
-
|
388
|
+
opts.footer = <<-EOT
|
389
|
+
Regenerate API access token for a specific client.
|
390
|
+
[client-id] is required. This is the id of an api client.
|
391
|
+
Done for the current user by default, unless a user is specified with the --user option.
|
392
|
+
EOT
|
319
393
|
end
|
320
394
|
optparse.parse!(args)
|
321
395
|
connect(options)
|
@@ -326,6 +400,11 @@ class Morpheus::Cli::UserSettingsCommand
|
|
326
400
|
end
|
327
401
|
params['clientId'] = args[0]
|
328
402
|
begin
|
403
|
+
if options[:user]
|
404
|
+
user = find_user_by_username_or_id(nil, options[:user], {global:true})
|
405
|
+
return 1 if user.nil?
|
406
|
+
params['userId'] = user['id']
|
407
|
+
end
|
329
408
|
payload = {}
|
330
409
|
@user_settings_interface.setopts(options)
|
331
410
|
if options[:dry_run]
|
@@ -374,12 +453,19 @@ class Morpheus::Cli::UserSettingsCommand
|
|
374
453
|
# opts.on("--client-id", "Client ID. eg. morph-api, morph-cli") do |val|
|
375
454
|
# params['clientId'] = val.to_s
|
376
455
|
# end
|
456
|
+
opts.on("-u", "--user USER", "User username or ID") do |val|
|
457
|
+
options[:user] = val.to_s
|
458
|
+
end
|
377
459
|
opts.on("--user-id ID", String, "User ID") do |val|
|
378
460
|
params['userId'] = val.to_s
|
379
461
|
end
|
462
|
+
#opts.add_hidden_option('--user-id')
|
380
463
|
build_common_options(opts, options, [:payload, :options, :json, :dry_run, :quiet, :remote])
|
381
|
-
opts.footer =
|
382
|
-
|
464
|
+
opts.footer = <<-EOT
|
465
|
+
Clear API access token for a specific client.
|
466
|
+
[client-id] or --all is required. This is the id of an api client.
|
467
|
+
Done for the current user by default, unless a user is specified with the --user option.
|
468
|
+
EOT
|
383
469
|
end
|
384
470
|
optparse.parse!(args)
|
385
471
|
connect(options)
|
@@ -397,6 +483,11 @@ class Morpheus::Cli::UserSettingsCommand
|
|
397
483
|
# clears all when clientId is omitted, no api parameter needed.
|
398
484
|
end
|
399
485
|
begin
|
486
|
+
if options[:user]
|
487
|
+
user = find_user_by_username_or_id(nil, options[:user], {global:true})
|
488
|
+
return 1 if user.nil?
|
489
|
+
params['userId'] = user['id']
|
490
|
+
end
|
400
491
|
payload = {}
|
401
492
|
@user_settings_interface.setopts(options)
|
402
493
|
if options[:dry_run]
|
@@ -445,11 +536,17 @@ class Morpheus::Cli::UserSettingsCommand
|
|
445
536
|
params = {}
|
446
537
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
447
538
|
opts.banner = subcommand_usage()
|
539
|
+
# opts.on("-u", "--user USER", "User username or ID") do |val|
|
540
|
+
# options[:user] = val.to_s
|
541
|
+
# end
|
448
542
|
# opts.on("--user-id ID", String, "User ID") do |val|
|
449
543
|
# params['userId'] = val.to_s
|
450
544
|
# end
|
545
|
+
# #opts.add_hidden_option('--user-id')
|
451
546
|
build_common_options(opts, options, [:query, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
452
|
-
opts.footer =
|
547
|
+
opts.footer = <<-EOT
|
548
|
+
List available api clients.
|
549
|
+
EOT
|
453
550
|
end
|
454
551
|
optparse.parse!(args)
|
455
552
|
connect(options)
|
@@ -460,6 +557,11 @@ class Morpheus::Cli::UserSettingsCommand
|
|
460
557
|
end
|
461
558
|
|
462
559
|
begin
|
560
|
+
# if options[:user]
|
561
|
+
# user = find_user_by_username_or_id(nil, options[:user], {global:true})
|
562
|
+
# return 1 if user.nil?
|
563
|
+
# params['userId'] = user['id']
|
564
|
+
# end
|
463
565
|
params.merge!(parse_list_options(options))
|
464
566
|
@user_settings_interface.setopts(options)
|
465
567
|
if options[:dry_run]
|
@@ -36,9 +36,13 @@ class Morpheus::Cli::UserSourcesCommand
|
|
36
36
|
account_id = nil
|
37
37
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
38
38
|
opts.banner = subcommand_usage()
|
39
|
-
opts.on('--
|
39
|
+
opts.on( '--tenant TENANT', String, "Filter by Tenant" ) do |val|
|
40
40
|
account_id = val
|
41
41
|
end
|
42
|
+
opts.on( '-a', '--account ACCOUNT', "Filter by Tenant" ) do |val|
|
43
|
+
account_id = val
|
44
|
+
end
|
45
|
+
opts.add_hidden_option('-a, --account') if opts.is_a?(Morpheus::Cli::OptionParser)
|
42
46
|
# opts.on('--technology VALUE', String, "Filter by technology") do |val|
|
43
47
|
# params['provisionType'] = val
|
44
48
|
# end
|
@@ -175,13 +179,15 @@ class Morpheus::Cli::UserSourcesCommand
|
|
175
179
|
#"Subdomain" => lambda {|it| it['subdomain'] },
|
176
180
|
"Login URL" => lambda {|it| it['loginURL'] },
|
177
181
|
"Default Role" => lambda {|it| it['defaultAccountRole'] ? it['defaultAccountRole']['authority'] : '' },
|
182
|
+
"External Login" => lambda {|it| format_boolean it['externalLogin'] },
|
183
|
+
"Allow Custom Mappings" => lambda {|it| format_boolean it['allowCustomMappings'] },
|
178
184
|
"Active" => lambda {|it| format_boolean it['active'] },
|
179
185
|
}
|
180
186
|
print_description_list(description_cols, user_source)
|
181
187
|
|
182
188
|
# show config settings...
|
183
189
|
user_source_config = user_source['config']
|
184
|
-
print_h2 "#{user_source['type']}
|
190
|
+
print_h2 "User Source Config (#{user_source['type']})"
|
185
191
|
if user_source_config
|
186
192
|
columns = user_source_config.keys #.sort
|
187
193
|
print_description_list(columns, user_source_config)
|
@@ -223,9 +229,13 @@ class Morpheus::Cli::UserSourcesCommand
|
|
223
229
|
default_role_id = nil
|
224
230
|
optparse = Morpheus::Cli::OptionParser.new do|opts|
|
225
231
|
opts.banner = subcommand_usage("[account] [name]")
|
226
|
-
opts.on('--
|
232
|
+
opts.on( '--tenant TENANT', String, "Tenant Name or ID the user source will belong to, default is your own." ) do |val|
|
227
233
|
account_id = val
|
228
234
|
end
|
235
|
+
opts.on( '-a', '--account ACCOUNT', "Tenant Name or ID the user source will belong to, default is your own." ) do |val|
|
236
|
+
account_id = val
|
237
|
+
end
|
238
|
+
opts.add_hidden_option('-a, --account') if opts.is_a?(Morpheus::Cli::OptionParser)
|
229
239
|
opts.on('--type CODE', String, "User Source Type") do |val|
|
230
240
|
type_code = val
|
231
241
|
end
|
@@ -235,6 +245,13 @@ class Morpheus::Cli::UserSourcesCommand
|
|
235
245
|
opts.on('--description VALUE', String, "Description") do |val|
|
236
246
|
params['description'] = val
|
237
247
|
end
|
248
|
+
opts.on("--allow-custom-mappings [on|off]", ['on','off'], "Allow Custom Mappings, Enable Role Mapping Permissions") do |val|
|
249
|
+
params['allowCustomMappings'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == '1' || val.to_s == ''
|
250
|
+
end
|
251
|
+
opts.on("--allowCustomMappings [on|off]", ['on','off'], "Allow Custom Mappings, Enable Role Mapping Permissions") do |val|
|
252
|
+
params['allowCustomMappings'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == '1' || val.to_s == ''
|
253
|
+
end
|
254
|
+
opts.add_hidden_option('--allowCustomMappings')
|
238
255
|
opts.on('--role-mappings MAPPINGS', String, "Role Mappings FQN in the format id1:FQN1,id2:FQN2") do |val|
|
239
256
|
role_mappings = {}
|
240
257
|
val.split(',').collect {|it| it.strip.split(':') }.each do |pair|
|
@@ -258,7 +275,7 @@ class Morpheus::Cli::UserSourcesCommand
|
|
258
275
|
default_role_id = val
|
259
276
|
end
|
260
277
|
#build_option_type_options(opts, options, add_user_source_option_types())
|
261
|
-
|
278
|
+
build_standard_add_options(opts, options)
|
262
279
|
opts.footer = "Create a new user source." + "\n" +
|
263
280
|
"[account] is required. This is the name or id of an account."
|
264
281
|
end
|
@@ -275,7 +292,9 @@ class Morpheus::Cli::UserSourcesCommand
|
|
275
292
|
if args[1]
|
276
293
|
params['name'] = args[1]
|
277
294
|
end
|
278
|
-
|
295
|
+
|
296
|
+
|
297
|
+
|
279
298
|
# find the account first, or just prompt for that too please.
|
280
299
|
if !account_id
|
281
300
|
print_error Morpheus::Terminal.angry_prompt
|
@@ -287,11 +306,12 @@ class Morpheus::Cli::UserSourcesCommand
|
|
287
306
|
account_id = account['id']
|
288
307
|
|
289
308
|
# construct payload
|
290
|
-
payload =
|
309
|
+
payload = {}
|
291
310
|
if options[:payload]
|
292
311
|
payload = options[:payload]
|
312
|
+
payload.deep_merge!({'userSource' => parse_passed_options(options)})
|
293
313
|
else
|
294
|
-
payload
|
314
|
+
payload.deep_merge!({'userSource' => parse_passed_options(options)})
|
295
315
|
|
296
316
|
# User Source Type
|
297
317
|
user_source_types = @user_sources_interface.list_types({userSelectable: true})['userSourceTypes']
|
@@ -339,6 +359,13 @@ class Morpheus::Cli::UserSourcesCommand
|
|
339
359
|
payload['userSource']['defaultAccountRole'] = {'id' => default_role_id }
|
340
360
|
end
|
341
361
|
|
362
|
+
# Allow Custom Mappings
|
363
|
+
if !params['allowCustomMappings'].nil?
|
364
|
+
payload['userSource']['allowCustomMappings'] = ["on","true"].include?(params['allowCustomMappings'].to_s)
|
365
|
+
else
|
366
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'allowCustomMappings', 'type' => 'checkbox', 'fieldLabel' => 'Allow Custom Mappings', 'defaultValue' => false}], options[:options])
|
367
|
+
payload['userSource']['allowCustomMappings'] = ["on","true"].include?(v_prompt['allowCustomMappings'].to_s)
|
368
|
+
end
|
342
369
|
|
343
370
|
if role_mappings
|
344
371
|
payload['roleMappings'] = role_mappings
|
@@ -367,12 +394,8 @@ class Morpheus::Cli::UserSourcesCommand
|
|
367
394
|
end
|
368
395
|
user_source = json_response['userSource']
|
369
396
|
print_green_success "Added User Source #{user_source['name']}"
|
370
|
-
get([user_source['id']])
|
397
|
+
get([user_source['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
|
371
398
|
return 0
|
372
|
-
rescue RestClient::Exception => e
|
373
|
-
print_rest_exception(e, options)
|
374
|
-
exit 1
|
375
|
-
end
|
376
399
|
end
|
377
400
|
|
378
401
|
def update(args)
|
@@ -389,6 +412,13 @@ class Morpheus::Cli::UserSourcesCommand
|
|
389
412
|
opts.on('--description VALUE', String, "Description") do |val|
|
390
413
|
params['description'] = val
|
391
414
|
end
|
415
|
+
opts.on("--allow-custom-mappings [on|off]", ['on','off'], "Allow Custom Mappings, Enable Role Mapping Permissions") do |val|
|
416
|
+
params['allowCustomMappings'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == '1' || val.to_s == ''
|
417
|
+
end
|
418
|
+
opts.on("--allowCustomMappings [on|off]", ['on','off'], "Allow Custom Mappings, Enable Role Mapping Permissions") do |val|
|
419
|
+
params['allowCustomMappings'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == '1' || val.to_s == ''
|
420
|
+
end
|
421
|
+
opts.add_hidden_option('--allowCustomMappings')
|
392
422
|
opts.on('--role-mappings MAPPINGS', String, "Role Mappings in the format id1:FQN,id2:FQN2") do |val|
|
393
423
|
role_mappings = {}
|
394
424
|
val.split(',').collect {|it| it.strip.split(':') }.each do |pair|
|
@@ -407,7 +437,7 @@ class Morpheus::Cli::UserSourcesCommand
|
|
407
437
|
end
|
408
438
|
end
|
409
439
|
end
|
410
|
-
|
440
|
+
build_standard_update_options(opts, options)
|
411
441
|
opts.footer = "Update a user source." + "\n" +
|
412
442
|
"[name] is required. This is the name or id of a user source."
|
413
443
|
end
|
@@ -420,11 +450,12 @@ class Morpheus::Cli::UserSourcesCommand
|
|
420
450
|
begin
|
421
451
|
user_source = find_user_source_by_name_or_id(nil, args[0])
|
422
452
|
exit 1 if user_source.nil?
|
423
|
-
payload =
|
453
|
+
payload = {}
|
424
454
|
if options[:payload]
|
425
455
|
payload = options[:payload]
|
456
|
+
payload.deep_merge!({'userSource' => parse_passed_options(options)})
|
426
457
|
else
|
427
|
-
payload
|
458
|
+
payload.deep_merge!({'userSource' => parse_passed_options(options)})
|
428
459
|
|
429
460
|
# Name
|
430
461
|
if params['name']
|
@@ -436,6 +467,11 @@ class Morpheus::Cli::UserSourcesCommand
|
|
436
467
|
payload['userSource']['description'] = params['description']
|
437
468
|
end
|
438
469
|
|
470
|
+
# Allow Custom Mappings
|
471
|
+
if !params['allowCustomMappings'].nil?
|
472
|
+
payload['userSource']['allowCustomMappings'] = params['allowCustomMappings']
|
473
|
+
end
|
474
|
+
|
439
475
|
if role_mappings
|
440
476
|
payload['roleMappings'] = role_mappings
|
441
477
|
end
|
@@ -444,9 +480,6 @@ class Morpheus::Cli::UserSourcesCommand
|
|
444
480
|
payload['roleMappingNames'] = role_mapping_names
|
445
481
|
end
|
446
482
|
|
447
|
-
# support old -O options
|
448
|
-
payload['userSource'].deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
449
|
-
|
450
483
|
end
|
451
484
|
@user_sources_interface.setopts(options)
|
452
485
|
if options[:dry_run]
|
@@ -462,7 +495,7 @@ class Morpheus::Cli::UserSourcesCommand
|
|
462
495
|
end
|
463
496
|
|
464
497
|
print_green_success "Updated User Source #{params['name'] || user_source['name']}"
|
465
|
-
get([user_source['id']])
|
498
|
+
get([user_source['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
|
466
499
|
rescue RestClient::Exception => e
|
467
500
|
print_rest_exception(e, options)
|
468
501
|
exit 1
|
@@ -512,7 +545,7 @@ class Morpheus::Cli::UserSourcesCommand
|
|
512
545
|
end
|
513
546
|
|
514
547
|
print_green_success "Activated User Source #{user_source['name']}"
|
515
|
-
get([user_source['id']])
|
548
|
+
get([user_source['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
|
516
549
|
rescue RestClient::Exception => e
|
517
550
|
print_rest_exception(e, options)
|
518
551
|
exit 1
|
@@ -562,7 +595,7 @@ class Morpheus::Cli::UserSourcesCommand
|
|
562
595
|
end
|
563
596
|
|
564
597
|
print_green_success "Activated User Source #{user_source['name']}"
|
565
|
-
get([user_source['id']])
|
598
|
+
get([user_source['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
|
566
599
|
rescue RestClient::Exception => e
|
567
600
|
print_rest_exception(e, options)
|
568
601
|
exit 1
|
@@ -612,9 +645,9 @@ class Morpheus::Cli::UserSourcesCommand
|
|
612
645
|
puts JSON.pretty_generate(json_response)
|
613
646
|
return
|
614
647
|
end
|
615
|
-
|
616
|
-
print_green_success "
|
617
|
-
get([user_source['id']])
|
648
|
+
# JD: uhh this updates the account too, it cannot be set per user source ...yet
|
649
|
+
print_green_success "Updated User Source #{user_source['name']} subdomain to '#{payload['subdomain']}'"
|
650
|
+
get([user_source['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
|
618
651
|
rescue RestClient::Exception => e
|
619
652
|
print_rest_exception(e, options)
|
620
653
|
exit 1
|