morpheus-cli 4.2.8 → 4.2.10
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/lib/morpheus/api.rb +1 -1
- data/lib/morpheus/api/activity_interface.rb +9 -0
- data/lib/morpheus/api/api_client.rb +83 -27
- data/lib/morpheus/api/apps_interface.rb +21 -0
- data/lib/morpheus/api/dashboard_interface.rb +5 -21
- data/lib/morpheus/api/instances_interface.rb +3 -10
- data/lib/morpheus/api/invoice_line_items_interface.rb +14 -0
- data/lib/morpheus/api/invoices_interface.rb +7 -12
- data/lib/morpheus/api/library_layouts_interface.rb +8 -0
- data/lib/morpheus/api/ping_interface.rb +20 -0
- data/lib/morpheus/api/projects_interface.rb +33 -0
- data/lib/morpheus/api/setup_interface.rb +19 -36
- data/lib/morpheus/api/user_settings_interface.rb +0 -6
- data/lib/morpheus/api/whoami_interface.rb +4 -8
- data/lib/morpheus/benchmarking.rb +16 -26
- data/lib/morpheus/cli.rb +10 -5
- data/lib/morpheus/cli/access_token_command.rb +5 -8
- data/lib/morpheus/cli/activity_command.rb +146 -0
- data/lib/morpheus/cli/apps.rb +312 -121
- data/lib/morpheus/cli/archives_command.rb +1 -1
- data/lib/morpheus/cli/auth_command.rb +4 -11
- data/lib/morpheus/cli/blueprints_command.rb +196 -137
- data/lib/morpheus/cli/change_password_command.rb +1 -1
- data/lib/morpheus/cli/cli_command.rb +225 -72
- data/lib/morpheus/cli/cli_registry.rb +2 -2
- data/lib/morpheus/cli/cloud_datastores_command.rb +1 -1
- data/lib/morpheus/cli/clouds.rb +5 -20
- data/lib/morpheus/cli/clusters.rb +4 -28
- data/lib/morpheus/cli/commands/standard/alias_command.rb +2 -9
- data/lib/morpheus/cli/commands/standard/benchmark_command.rb +2 -0
- data/lib/morpheus/cli/commands/standard/curl_command.rb +2 -3
- data/lib/morpheus/cli/commands/standard/history_command.rb +3 -6
- data/lib/morpheus/cli/commands/standard/man_command.rb +10 -7
- data/lib/morpheus/cli/commands/standard/ssl_verification_command.rb +10 -9
- data/lib/morpheus/cli/containers_command.rb +3 -3
- data/lib/morpheus/cli/credentials.rb +13 -16
- data/lib/morpheus/cli/error_handler.rb +18 -12
- data/lib/morpheus/cli/errors.rb +45 -0
- data/lib/morpheus/cli/execute_schedules_command.rb +1 -1
- data/lib/morpheus/cli/execution_request_command.rb +4 -4
- data/lib/morpheus/cli/groups.rb +84 -132
- data/lib/morpheus/cli/hosts.rb +6 -16
- data/lib/morpheus/cli/instances.rb +100 -183
- data/lib/morpheus/cli/invoices_command.rb +505 -71
- data/lib/morpheus/cli/library_layouts_command.rb +254 -166
- data/lib/morpheus/cli/library_option_lists_command.rb +0 -87
- data/lib/morpheus/cli/library_option_types_command.rb +0 -96
- data/lib/morpheus/cli/license.rb +3 -0
- data/lib/morpheus/cli/login.rb +17 -37
- data/lib/morpheus/cli/logout.rb +9 -5
- data/lib/morpheus/cli/mixins/accounts_helper.rb +83 -7
- data/lib/morpheus/cli/mixins/operations_helper.rb +41 -0
- data/lib/morpheus/cli/mixins/option_source_helper.rb +255 -0
- data/lib/morpheus/cli/mixins/print_helper.rb +18 -4
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +222 -13
- data/lib/morpheus/cli/mixins/remote_helper.rb +139 -0
- data/lib/morpheus/cli/monitoring_checks_command.rb +11 -3
- data/lib/morpheus/cli/network_groups_command.rb +8 -2
- data/lib/morpheus/cli/option_types.rb +1 -1
- data/lib/morpheus/cli/ping.rb +252 -0
- data/lib/morpheus/cli/price_sets_command.rb +16 -27
- data/lib/morpheus/cli/prices_command.rb +34 -27
- data/lib/morpheus/cli/processes_command.rb +81 -7
- data/lib/morpheus/cli/projects_command.rb +607 -0
- data/lib/morpheus/cli/recent_activity_command.rb +87 -65
- data/lib/morpheus/cli/remote.rb +965 -974
- data/lib/morpheus/cli/reports_command.rb +3 -15
- data/lib/morpheus/cli/roles.rb +8 -31
- data/lib/morpheus/cli/service_plans_command.rb +25 -31
- data/lib/morpheus/cli/setup.rb +392 -0
- data/lib/morpheus/cli/shell.rb +144 -56
- data/lib/morpheus/cli/subnets_command.rb +71 -11
- data/lib/morpheus/cli/tasks.rb +3 -3
- data/lib/morpheus/cli/user_sources_command.rb +4 -4
- data/lib/morpheus/cli/users.rb +135 -109
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli/whitelabel_settings_command.rb +7 -7
- data/lib/morpheus/cli/whoami.rb +90 -129
- data/lib/morpheus/cli/wiki_command.rb +2 -14
- data/lib/morpheus/ext/rest_client.rb +36 -0
- data/lib/morpheus/formatters.rb +42 -5
- data/lib/morpheus/rest_client.rb +0 -10
- data/lib/morpheus/terminal.rb +41 -1
- data/lib/morpheus/util.rb +24 -0
- metadata +16 -3
- data/lib/morpheus/cli/command_error.rb +0 -22
data/lib/morpheus/cli/users.rb
CHANGED
@@ -16,6 +16,9 @@ class Morpheus::Cli::Users
|
|
16
16
|
alias_subcommand :details, :get
|
17
17
|
set_default_subcommand :list
|
18
18
|
|
19
|
+
#todo: TOO_SIMPL_REGEX = //i
|
20
|
+
# TOO_SIMPLE_ERROR = "Password too simple. Password must contain at least one uppercase letter, one lowercase letter, a number, and a symbol."
|
21
|
+
|
19
22
|
def initialize()
|
20
23
|
# @appliance_name, @appliance_url = Morpheus::Cli::Remote.active_appliance
|
21
24
|
end
|
@@ -116,10 +119,15 @@ class Morpheus::Cli::Users
|
|
116
119
|
params = {}
|
117
120
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
118
121
|
opts.banner = subcommand_usage("[username]")
|
119
|
-
opts.on(
|
122
|
+
opts.on('-p','--permissions', "Display Permissions") do |val|
|
120
123
|
options[:include_features_access] = true
|
121
124
|
params['includeAccess'] = true
|
122
125
|
end
|
126
|
+
opts.on(nil,'--feature-access', "Display Permissions") do |val|
|
127
|
+
options[:include_features_access] = true
|
128
|
+
params['includeAccess'] = true
|
129
|
+
end
|
130
|
+
opts.add_hidden_option('--feature-access')
|
123
131
|
opts.on(nil,'--group-access', "Display Group Access") do
|
124
132
|
options[:include_sites_access] = true
|
125
133
|
params['includeAccess'] = true
|
@@ -211,12 +219,13 @@ class Morpheus::Cli::Users
|
|
211
219
|
description_cols = {
|
212
220
|
"ID" => 'id',
|
213
221
|
"Account" => lambda {|it| it['account'] ? it['account']['name'] : '' },
|
214
|
-
|
215
|
-
|
222
|
+
"First Name" => 'firstName',
|
223
|
+
"Last Name" => 'lastName',
|
216
224
|
# "Name" => 'displayName',
|
217
|
-
"Name" => lambda {|it| it['firstName'] ? it['displayName'] : '' },
|
225
|
+
#"Name" => lambda {|it| it['firstName'] ? it['displayName'] : '' },
|
218
226
|
"Username" => 'username',
|
219
227
|
"Email" => 'email',
|
228
|
+
"Notifications" => lambda {|it| it['receiveNotifications'].nil? ? '' : format_boolean(it['receiveNotifications']) },
|
220
229
|
"Role" => lambda {|it| format_user_role_names(it) },
|
221
230
|
"Created" => lambda {|it| format_local_dt(it['dateCreated']) },
|
222
231
|
"Updated" => lambda {|it| format_local_dt(it['lastUpdated']) }
|
@@ -233,12 +242,12 @@ class Morpheus::Cli::Users
|
|
233
242
|
print cyan
|
234
243
|
if user_feature_permissions.is_a?(Array)
|
235
244
|
rows = user_feature_permissions.collect do |it|
|
236
|
-
{name: it['name'], code: it['code'], access:
|
245
|
+
{name: it['name'], code: it['code'], access: format_access_string(it['access']) }
|
237
246
|
end
|
238
247
|
print as_pretty_table(rows, [:name, :code, :access], options)
|
239
248
|
else
|
240
249
|
rows = user_feature_permissions.collect do |code, access|
|
241
|
-
{code: code, access:
|
250
|
+
{code: code, access: format_access_string(access) }
|
242
251
|
end
|
243
252
|
print as_pretty_table(rows, [:code, :access], options)
|
244
253
|
end
|
@@ -252,11 +261,21 @@ class Morpheus::Cli::Users
|
|
252
261
|
access = user['access'][field.split('_').enum_for(:each_with_index).collect {|word, idx| idx == 0 ? word : word.capitalize}.join]
|
253
262
|
access = access.reject {|it| it['access'] == 'none'} if !options[:display_none_access]
|
254
263
|
|
255
|
-
|
264
|
+
if field == "features"
|
265
|
+
# print_h2 "Permissions", options
|
266
|
+
print_h2 "#{label} Access", options
|
267
|
+
else
|
268
|
+
print_h2 "#{label} Access", options
|
269
|
+
end
|
256
270
|
print cyan
|
257
271
|
|
272
|
+
# access levels vary, default is none,read,user,full
|
273
|
+
available_access_levels = ["none","read","user","full"]
|
274
|
+
if field == 'sites' || field == 'zones' || field == 'instance_types' || field == 'app_templates'
|
275
|
+
available_access_levels = ["none","read","full"]
|
276
|
+
end
|
258
277
|
if access.count > 0
|
259
|
-
access.each {|it| it['access'] =
|
278
|
+
access.each {|it| it['access'] = format_access_string(it['access'], available_access_levels)}
|
260
279
|
|
261
280
|
if ['features', 'instance_types'].include?(field)
|
262
281
|
print as_pretty_table(access, [:name, :code, :access], options)
|
@@ -289,11 +308,7 @@ class Morpheus::Cli::Users
|
|
289
308
|
"[username] is required. This is the username or id of a user."
|
290
309
|
end
|
291
310
|
optparse.parse!(args)
|
292
|
-
|
293
|
-
if args.count < 1
|
294
|
-
puts optparse
|
295
|
-
return 1
|
296
|
-
end
|
311
|
+
verify_args!(args:args, optparse:optparse, count:1)
|
297
312
|
|
298
313
|
connect(options)
|
299
314
|
begin
|
@@ -331,12 +346,12 @@ class Morpheus::Cli::Users
|
|
331
346
|
print cyan
|
332
347
|
if user_feature_permissions.is_a?(Array)
|
333
348
|
rows = user_feature_permissions.collect do |it|
|
334
|
-
{name: it['name'], code: it['code'], access:
|
349
|
+
{name: it['name'], code: it['code'], access: format_access_string(it['access']) }
|
335
350
|
end
|
336
351
|
print as_pretty_table(rows, [:name, :code, :access], options)
|
337
352
|
else
|
338
353
|
rows = user_feature_permissions.collect do |code, access|
|
339
|
-
{code: code, access:
|
354
|
+
{code: code, access: format_access_string(access) }
|
340
355
|
end
|
341
356
|
print as_pretty_table(rows, [:code, :access], options)
|
342
357
|
end
|
@@ -367,9 +382,12 @@ class Morpheus::Cli::Users
|
|
367
382
|
|
368
383
|
print_h2 "#{label} Access", options
|
369
384
|
print cyan
|
370
|
-
|
385
|
+
available_access_levels = ["full","user","read","none"]
|
386
|
+
if field == 'sites' || field == 'zones' || field == 'instance_types' || field == 'app_templates'
|
387
|
+
available_access_levels = ["full","custom","none"]
|
388
|
+
end
|
371
389
|
if access.count > 0
|
372
|
-
access.each {|it| it['access'] =
|
390
|
+
access.each {|it| it['access'] = format_access_string(it['access'], available_access_levels)}
|
373
391
|
|
374
392
|
if ['features', 'instance_types'].include?(field)
|
375
393
|
print as_pretty_table(access, [:name, :code, :access], options)
|
@@ -377,7 +395,7 @@ class Morpheus::Cli::Users
|
|
377
395
|
print as_pretty_table(access, [:name, :access], options)
|
378
396
|
end
|
379
397
|
else
|
380
|
-
println
|
398
|
+
println cyan,"No #{label} Access Found.",reset
|
381
399
|
end
|
382
400
|
end
|
383
401
|
end
|
@@ -394,24 +412,36 @@ class Morpheus::Cli::Users
|
|
394
412
|
options = {}
|
395
413
|
params = {}
|
396
414
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
397
|
-
opts.banner = subcommand_usage("[options]")
|
415
|
+
opts.banner = subcommand_usage("[username] [email] [first] [last] [options]")
|
398
416
|
build_option_type_options(opts, options, add_user_option_types)
|
399
417
|
build_common_options(opts, options, [:account, :options, :payload, :json, :dry_run])
|
418
|
+
opts.footer = <<-EOT
|
419
|
+
Create a new user.
|
420
|
+
[username] is required. Username of the new user
|
421
|
+
[email] is required. Email address
|
422
|
+
[first] is optional. First Name
|
423
|
+
[last] is optional. Last Name
|
424
|
+
EOT
|
400
425
|
end
|
401
426
|
optparse.parse!(args)
|
402
|
-
|
427
|
+
verify_args!(args:args, optparse:optparse, min:0, max:4)
|
428
|
+
options[:options]['username'] = args[0] if args[0]
|
429
|
+
options[:options]['email'] = args[1] if args[1]
|
430
|
+
options[:options]['firstName'] = args[2] if args[2]
|
431
|
+
options[:options]['lastName'] = args[3] if args[3]
|
403
432
|
connect(options)
|
404
433
|
begin
|
405
434
|
|
406
435
|
account = find_account_from_options(options)
|
407
436
|
account_id = account ? account['id'] : nil
|
408
437
|
|
409
|
-
payload =
|
438
|
+
payload = {}
|
410
439
|
if options[:payload]
|
411
440
|
payload = options[:payload]
|
441
|
+
payload.deep_merge!(parse_passed_options(options))
|
412
442
|
else
|
413
443
|
# merge -O options into normally parsed options
|
414
|
-
|
444
|
+
payload.deep_merge!(parse_passed_options(options))
|
415
445
|
# remove role option_type, it is just for help display, the role prompt is separate down below
|
416
446
|
prompt_option_types = add_user_option_types().reject {|it| 'role' == it['fieldName'] }
|
417
447
|
v_prompt = Morpheus::Cli::OptionTypes.prompt(prompt_option_types, options[:options], @api_client, options[:params])
|
@@ -452,7 +482,7 @@ class Morpheus::Cli::Users
|
|
452
482
|
if account
|
453
483
|
details_options.push "--account-id", account['id'].to_s
|
454
484
|
end
|
455
|
-
get(details_options)
|
485
|
+
get(details_options + (options[:remote] ? ["-r",options[:remote]] : []))
|
456
486
|
end
|
457
487
|
|
458
488
|
|
@@ -465,18 +495,14 @@ class Morpheus::Cli::Users
|
|
465
495
|
def update(args)
|
466
496
|
options = {}
|
467
497
|
params = {}
|
498
|
+
payload = {}
|
468
499
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
469
500
|
opts.banner = subcommand_usage("[username] [options]")
|
470
501
|
build_option_type_options(opts, options, update_user_option_types)
|
471
502
|
build_common_options(opts, options, [:account, :options, :payload, :json, :dry_run])
|
472
503
|
end
|
473
504
|
optparse.parse!(args)
|
474
|
-
|
475
|
-
if args.count < 1
|
476
|
-
puts optparse
|
477
|
-
return 1
|
478
|
-
end
|
479
|
-
|
505
|
+
verify_args!(args:args, optparse:optparse, count:1)
|
480
506
|
connect(options)
|
481
507
|
begin
|
482
508
|
|
@@ -486,36 +512,29 @@ class Morpheus::Cli::Users
|
|
486
512
|
user = find_user_by_username_or_id(account_id, args[0])
|
487
513
|
return 1 if user.nil?
|
488
514
|
|
489
|
-
|
515
|
+
# use --payload
|
490
516
|
if options[:payload]
|
491
517
|
payload = options[:payload]
|
518
|
+
payload.deep_merge!(parse_passed_options(options))
|
492
519
|
else
|
493
|
-
#
|
494
|
-
#
|
495
|
-
params.deep_merge!(options
|
496
|
-
#
|
497
|
-
# print_red_alert "Specify at least one option to update"
|
498
|
-
# puts optparse
|
499
|
-
# return 1
|
500
|
-
# end
|
501
|
-
# prompt_option_types = update_user_option_types().reject {|it| 'role' == it['fieldName'] }
|
502
|
-
# params = Morpheus::Cli::OptionTypes.prompt(prompt_option_types, params, @api_client)
|
520
|
+
# inject -O key=value options
|
521
|
+
# payload.deep_merge!(parse_passed_options(options))
|
522
|
+
params.deep_merge!(parse_passed_options(options))
|
523
|
+
# user_prompt_output = Morpheus::Cli::OptionTypes.prompt(prompt_option_types, payload['user'], @api_client)
|
503
524
|
selected_roles = []
|
504
525
|
selected_roles += params.delete('role').split(',').collect {|r| r.strip.empty? ? nil : r.strip}.uniq if params['role']
|
505
526
|
selected_roles += params.delete('roles').split(',').collect {|r| r.strip.empty? ? nil : r.strip}.uniq if params['roles']
|
506
527
|
roles = prompt_user_roles(account_id, user['id'], selected_roles, options.merge(no_prompt: true))
|
528
|
+
# should it allow [] (no roles) ?
|
507
529
|
if !roles.empty?
|
508
530
|
params['roles'] = roles.collect {|r| {id: r['id']} }
|
509
531
|
end
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
return 1
|
532
|
+
payload.deep_merge!({'user' => params})
|
533
|
+
if payload['user'].empty? # || options[:no_prompt]
|
534
|
+
raise_command_error "Specify at least one option to update.\n#{optparse}"
|
514
535
|
end
|
515
|
-
|
516
|
-
|
517
|
-
payload = {'user' => params}
|
518
536
|
end
|
537
|
+
|
519
538
|
@users_interface.setopts(options)
|
520
539
|
if options[:dry_run]
|
521
540
|
print_dry_run @users_interface.dry.update(account_id, user['id'], payload)
|
@@ -528,13 +547,15 @@ class Morpheus::Cli::Users
|
|
528
547
|
print "\n"
|
529
548
|
else
|
530
549
|
username = user['username'] # json_response['user']['username']
|
531
|
-
|
550
|
+
if payload['user'] && payload['user']['username']
|
551
|
+
username = payload['user']['username']
|
552
|
+
end
|
532
553
|
print_green_success "Updated user #{username}"
|
533
554
|
details_options = [username]
|
534
555
|
if account
|
535
556
|
details_options.push "--account-id", account['id'].to_s
|
536
557
|
end
|
537
|
-
get(details_options)
|
558
|
+
get(details_options + (options[:remote] ? ["-r",options[:remote]] : []))
|
538
559
|
end
|
539
560
|
|
540
561
|
rescue RestClient::Exception => e
|
@@ -547,75 +568,79 @@ class Morpheus::Cli::Users
|
|
547
568
|
options = {}
|
548
569
|
new_password = nil
|
549
570
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
550
|
-
opts.banner = subcommand_usage("[username] [options]")
|
551
|
-
opts.on('--password VALUE', String, "New password") do |val|
|
552
|
-
|
553
|
-
end
|
554
|
-
|
571
|
+
opts.banner = subcommand_usage("[username] [password] [options]")
|
572
|
+
# opts.on('--password VALUE', String, "New password") do |val|
|
573
|
+
# new_password = val
|
574
|
+
# end
|
575
|
+
build_standard_update_options(opts, options, [:account])
|
555
576
|
end
|
556
577
|
optparse.parse!(args)
|
557
|
-
|
558
|
-
if args.count < 1
|
559
|
-
# print_error Morpheus::Terminal.angry_prompt
|
560
|
-
# puts_error "wrong number of arguments, expected 1 and got #{args.count}\n#{optparse}"
|
561
|
-
puts optparse
|
562
|
-
return 1
|
563
|
-
end
|
564
|
-
|
578
|
+
verify_args!(args:args, optparse:optparse, min:1,max:2) # [username] [password]
|
565
579
|
connect(options)
|
566
|
-
|
580
|
+
exit_code, err = 0, nil
|
567
581
|
|
568
|
-
|
569
|
-
|
582
|
+
# user can be scoped to account (tenant)
|
583
|
+
account = find_account_from_options(options)
|
584
|
+
account_id = account ? account['id'] : nil
|
570
585
|
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
end
|
586
|
+
# fetch the user to update
|
587
|
+
user = find_user_by_username_or_id(account_id, args[0])
|
588
|
+
return 1 if user.nil?
|
589
|
+
|
590
|
+
new_password = args[1] if args[1]
|
577
591
|
|
578
|
-
|
579
|
-
|
592
|
+
# print a warning or important info
|
593
|
+
if !options[:quiet]
|
594
|
+
print cyan, "Changing password for #{user['username']}", reset, "\n"
|
595
|
+
end
|
596
|
+
# construct change_password payload
|
597
|
+
|
598
|
+
# use --payload
|
599
|
+
if options[:payload]
|
600
|
+
payload = options[:payload]
|
601
|
+
payload.deep_merge!(parse_passed_options(options))
|
602
|
+
else
|
603
|
+
# inject -O key=value options
|
604
|
+
payload.deep_merge!(parse_passed_options(options))
|
605
|
+
|
606
|
+
# prompt for password input
|
607
|
+
current_input_attempt = 1
|
608
|
+
still_prompting = new_password ? false : true
|
609
|
+
while still_prompting do
|
610
|
+
# New Password
|
580
611
|
password_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'password', 'fieldLabel' => 'New Password', 'type' => 'password', 'required' => true}], options[:options], @api_client)
|
581
612
|
new_password = password_prompt['password']
|
582
|
-
|
613
|
+
|
614
|
+
# could validate password is "strong"
|
615
|
+
# Confirm New Password
|
583
616
|
confirm_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'passwordConfirmation', 'fieldLabel' => 'Confirm Password', 'type' => 'password', 'required' => true}], options[:options], @api_client)
|
584
617
|
confirm_password = confirm_prompt['passwordConfirmation']
|
585
618
|
if confirm_password != new_password
|
586
619
|
print_red_alert "Confirm password did not match."
|
587
|
-
|
620
|
+
new_password = nil
|
621
|
+
unless ::Morpheus::Cli::OptionTypes::confirm("Would you like to try again?", options.merge({default: true}))
|
622
|
+
return 9, "aborted login"
|
623
|
+
end
|
588
624
|
end
|
625
|
+
still_prompting = !!new_password
|
589
626
|
end
|
590
|
-
|
591
|
-
if new_password.nil? || new_password.empty?
|
592
|
-
print_red_alert "A new password is required"
|
593
|
-
return 1
|
594
|
-
end
|
595
|
-
|
596
627
|
payload = {
|
597
628
|
'user' => {
|
598
629
|
'password' => new_password
|
599
630
|
}
|
600
631
|
}
|
601
|
-
@users_interface.setopts(options)
|
602
|
-
if options[:dry_run]
|
603
|
-
print_dry_run @users_interface.dry.update(account_id, user['id'], payload)
|
604
|
-
return
|
605
|
-
end
|
606
632
|
|
607
|
-
json_response = @users_interface.update(account_id, user['id'], payload)
|
608
|
-
|
609
|
-
if options[:json]
|
610
|
-
puts JSON.pretty_generate(json_response)
|
611
|
-
elsif !options[:quiet]
|
612
|
-
print_green_success "Updated password for user #{user['username']}"
|
613
|
-
end
|
614
|
-
return 0
|
615
|
-
rescue RestClient::Exception => e
|
616
|
-
print_rest_exception(e, options)
|
617
|
-
return 1
|
618
633
|
end
|
634
|
+
@users_interface.setopts(options)
|
635
|
+
if options[:dry_run]
|
636
|
+
print_dry_run @users_interface.dry.update(account_id, user['id'], payload)
|
637
|
+
return
|
638
|
+
end
|
639
|
+
json_response = @users_interface.update(account_id, user['id'], payload)
|
640
|
+
render_response(json_response, optparse, "user") do
|
641
|
+
print_green_success "Updated password for user #{user['username']}"
|
642
|
+
end
|
643
|
+
return exit_code, err
|
619
644
|
end
|
620
645
|
|
621
646
|
def remove(args)
|
@@ -670,22 +695,23 @@ class Morpheus::Cli::Users
|
|
670
695
|
{'fieldName' => 'lastName', 'fieldLabel' => 'Last Name', 'type' => 'text', 'required' => false, 'displayOrder' => 2},
|
671
696
|
{'fieldName' => 'username', 'fieldLabel' => 'Username', 'type' => 'text', 'required' => true, 'displayOrder' => 3},
|
672
697
|
{'fieldName' => 'email', 'fieldLabel' => 'Email', 'type' => 'text', 'required' => true, 'displayOrder' => 4},
|
673
|
-
{'fieldName' => 'password', 'fieldLabel' => 'Password', 'type' => 'password', 'required' => true, 'displayOrder' =>
|
674
|
-
{'fieldName' => 'passwordConfirmation', 'fieldLabel' => 'Confirm Password', 'type' => 'password', 'required' => true, 'displayOrder' =>
|
675
|
-
{'fieldName' => 'role', 'fieldLabel' => 'Role', 'type' => 'text', '
|
698
|
+
{'fieldName' => 'password', 'fieldLabel' => 'Password', 'type' => 'password', 'required' => true, 'displayOrder' => 5},
|
699
|
+
{'fieldName' => 'passwordConfirmation', 'fieldLabel' => 'Confirm Password', 'type' => 'password', 'required' => true, 'displayOrder' => 6},
|
700
|
+
{'fieldName' => 'role', 'fieldLabel' => 'Role', 'type' => 'text', 'description' => "Role names (comma separated)", 'displayOrder' => 7},
|
701
|
+
{'fieldName' => 'receiveNotifications', 'fieldLabel' => 'receiveNotifications', 'type' => 'checkbox', 'required' => false, 'defaultValue' => true, 'displayOrder' => 58},
|
702
|
+
{'fieldName' => 'linuxUsername', 'fieldLabel' => 'Linux Username', 'type' => 'text', 'required' => false, 'displayOrder' => 9},
|
703
|
+
# {'fieldName' => 'linuxPassword', 'fieldLabel' => 'Linux Password', 'type' => 'password', 'required' => false, 'displayOrder' => 10},
|
704
|
+
{'fieldName' => 'windowsUsername', 'fieldLabel' => 'Windows Username', 'type' => 'text', 'required' => false, 'displayOrder' => 11},
|
705
|
+
# {'fieldName' => 'windowsPassword', 'fieldLabel' => 'Windows Password', 'type' => 'text', 'required' => false, 'displayOrder' => 12},
|
706
|
+
# 'linuxUsername','windowsUsername','linuxKeyPairId'
|
676
707
|
]
|
677
708
|
end
|
678
709
|
|
679
710
|
def update_user_option_types
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
{'fieldName' => 'email', 'fieldLabel' => 'Email', 'type' => 'text', 'required' => false, 'displayOrder' => 4},
|
685
|
-
{'fieldName' => 'password', 'fieldLabel' => 'Password', 'type' => 'password', 'required' => false, 'displayOrder' => 6},
|
686
|
-
{'fieldName' => 'passwordConfirmation', 'fieldLabel' => 'Confirm Password', 'type' => 'password', 'required' => false, 'displayOrder' => 7},
|
687
|
-
{'fieldName' => 'role', 'fieldLabel' => 'Role', 'type' => 'text', 'displayOrder' => 11, 'description' => "Role names (comma separated)"},
|
688
|
-
]
|
711
|
+
add_user_option_types.collect {|it|
|
712
|
+
it['required'] = false
|
713
|
+
it
|
714
|
+
}
|
689
715
|
end
|
690
716
|
|
691
717
|
# prompt user to select roles for a new or existing user
|
data/lib/morpheus/cli/version.rb
CHANGED
@@ -29,7 +29,7 @@ class Morpheus::Cli::WhitelabelSettingsCommand
|
|
29
29
|
options = {}
|
30
30
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
31
31
|
opts.banner = subcommand_usage()
|
32
|
-
opts.on( '-a', '--
|
32
|
+
opts.on( '-a', '--tenant TENANT', "Tenant Name or ID" ) do |val|
|
33
33
|
options[:account] = val
|
34
34
|
end
|
35
35
|
opts.on('--details', "Show full (not truncated) contents of Terms of Use, Privacy Policy, Override CSS" ) do
|
@@ -80,7 +80,7 @@ class Morpheus::Cli::WhitelabelSettingsCommand
|
|
80
80
|
print_h1 "Whitelabel Settings"
|
81
81
|
print cyan
|
82
82
|
description_cols = {
|
83
|
-
"
|
83
|
+
"Tenant" => lambda {|it| it['account']['name'] rescue '' },
|
84
84
|
"Enabled" => lambda {|it| format_boolean(it['enabled']) },
|
85
85
|
"Appliance Name" => lambda {|it| it['applianceName'] },
|
86
86
|
"Disable Support Menu" => lambda {|it| format_boolean(it['disableSupportMenu'])},
|
@@ -148,7 +148,7 @@ class Morpheus::Cli::WhitelabelSettingsCommand
|
|
148
148
|
query_params = {}
|
149
149
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
150
150
|
opts.banner = opts.banner = subcommand_usage()
|
151
|
-
opts.on( '-a', '--account ACCOUNT', "
|
151
|
+
opts.on( '-a', '--account ACCOUNT', "Tenant Name or ID" ) do |val|
|
152
152
|
options[:account] = val
|
153
153
|
end
|
154
154
|
opts.on('--active [on|off]', String, "Can be used to enable / disable whitelabel feature") do |val|
|
@@ -314,7 +314,7 @@ class Morpheus::Cli::WhitelabelSettingsCommand
|
|
314
314
|
options = {}
|
315
315
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
316
316
|
opts.banner = opts.banner = subcommand_usage()
|
317
|
-
opts.on( '-a', '--account ACCOUNT', "
|
317
|
+
opts.on( '-a', '--account ACCOUNT', "Tenant Name or ID" ) do |val|
|
318
318
|
options[:account] = val
|
319
319
|
end
|
320
320
|
opts.on("--header-logo FILE", String, "Header logo image. Local path of a file to upload (png|jpg|svg)") do |val|
|
@@ -412,7 +412,7 @@ class Morpheus::Cli::WhitelabelSettingsCommand
|
|
412
412
|
options = {}
|
413
413
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
414
414
|
opts.banner = opts.banner = subcommand_usage("[image-type]")
|
415
|
-
opts.on( '-a', '--
|
415
|
+
opts.on( '-a', '--tenant TENANT', "Tenant Name or ID" ) do |val|
|
416
416
|
options[:account] = val
|
417
417
|
end
|
418
418
|
build_common_options(opts, options, [:json, :dry_run, :quiet, :remote])
|
@@ -468,7 +468,7 @@ class Morpheus::Cli::WhitelabelSettingsCommand
|
|
468
468
|
options = {}
|
469
469
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
470
470
|
opts.banner = opts.banner = subcommand_usage("[image-type]")
|
471
|
-
opts.on( '-a', '--
|
471
|
+
opts.on( '-a', '--tenant TENANT', "Tenant Name or ID" ) do |val|
|
472
472
|
options[:account] = val
|
473
473
|
end
|
474
474
|
build_common_options(opts, options, [:json, :dry_run, :quiet, :remote])
|
@@ -532,7 +532,7 @@ class Morpheus::Cli::WhitelabelSettingsCommand
|
|
532
532
|
options = {}
|
533
533
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
534
534
|
opts.banner = opts.banner = subcommand_usage("[image-type] [local-file]")
|
535
|
-
opts.on( '-a', '--
|
535
|
+
opts.on( '-a', '--tenant TENANT', "Tenant Name or ID" ) do |val|
|
536
536
|
options[:account] = val
|
537
537
|
end
|
538
538
|
opts.on( '-f', '--force', "Overwrite existing [local-file] if it exists." ) do
|