morpheus-cli 4.2.6 → 4.2.7

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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile +1 -1
  3. data/lib/morpheus/api/api_client.rb +4 -0
  4. data/lib/morpheus/api/clouds_interface.rb +14 -0
  5. data/lib/morpheus/api/guidance_interface.rb +47 -0
  6. data/lib/morpheus/api/users_interface.rb +7 -0
  7. data/lib/morpheus/cli.rb +1 -0
  8. data/lib/morpheus/cli/account_groups_command.rb +1 -1
  9. data/lib/morpheus/cli/approvals_command.rb +2 -2
  10. data/lib/morpheus/cli/apps.rb +26 -30
  11. data/lib/morpheus/cli/blueprints_command.rb +1 -1
  12. data/lib/morpheus/cli/budgets_command.rb +2 -2
  13. data/lib/morpheus/cli/change_password_command.rb +0 -1
  14. data/lib/morpheus/cli/cli_command.rb +19 -9
  15. data/lib/morpheus/cli/clouds.rb +107 -10
  16. data/lib/morpheus/cli/clusters.rb +12 -12
  17. data/lib/morpheus/cli/commands/standard/curl_command.rb +7 -0
  18. data/lib/morpheus/cli/deployments.rb +2 -2
  19. data/lib/morpheus/cli/environments_command.rb +1 -1
  20. data/lib/morpheus/cli/execution_request_command.rb +1 -1
  21. data/lib/morpheus/cli/groups.rb +1 -1
  22. data/lib/morpheus/cli/guidance_command.rb +529 -0
  23. data/lib/morpheus/cli/hosts.rb +2 -10
  24. data/lib/morpheus/cli/instances.rb +31 -13
  25. data/lib/morpheus/cli/integrations_command.rb +1 -1
  26. data/lib/morpheus/cli/jobs_command.rb +2 -2
  27. data/lib/morpheus/cli/library_container_types_command.rb +4 -4
  28. data/lib/morpheus/cli/library_instance_types_command.rb +3 -3
  29. data/lib/morpheus/cli/library_spec_templates_command.rb +1 -1
  30. data/lib/morpheus/cli/load_balancers.rb +2 -2
  31. data/lib/morpheus/cli/mixins/print_helper.rb +43 -3
  32. data/lib/morpheus/cli/mixins/provisioning_helper.rb +251 -165
  33. data/lib/morpheus/cli/network_routers_command.rb +1 -1
  34. data/lib/morpheus/cli/price_sets_command.rb +2 -2
  35. data/lib/morpheus/cli/provisioning_licenses_command.rb +1 -1
  36. data/lib/morpheus/cli/remote.rb +6 -1
  37. data/lib/morpheus/cli/reports_command.rb +1 -1
  38. data/lib/morpheus/cli/security_group_rules.rb +1 -1
  39. data/lib/morpheus/cli/security_groups.rb +13 -5
  40. data/lib/morpheus/cli/service_plans_command.rb +2 -2
  41. data/lib/morpheus/cli/user_groups_command.rb +2 -6
  42. data/lib/morpheus/cli/user_settings_command.rb +31 -5
  43. data/lib/morpheus/cli/user_sources_command.rb +3 -3
  44. data/lib/morpheus/cli/users.rb +117 -90
  45. data/lib/morpheus/cli/version.rb +1 -1
  46. data/lib/morpheus/cli/virtual_images.rb +2 -2
  47. data/lib/morpheus/cli/whitelabel_settings_command.rb +95 -15
  48. data/lib/morpheus/cli/wiki_command.rb +2 -2
  49. data/lib/morpheus/cli/workflows.rb +2 -3
  50. data/lib/morpheus/formatters.rb +14 -5
  51. metadata +4 -2
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Morpheus
3
3
  module Cli
4
- VERSION = "4.2.6"
4
+ VERSION = "4.2.7"
5
5
  end
6
6
  end
@@ -89,7 +89,7 @@ class Morpheus::Cli::VirtualImages
89
89
  end
90
90
  print_h1 title, subtitles
91
91
  if images.empty?
92
- print yellow,"No virtual images found.",reset,"\n"
92
+ print cyan,"No virtual images found.",reset,"\n"
93
93
  else
94
94
  rows = images.collect do |image|
95
95
  image_type = virtual_image_type_for_name_or_code(image['imageType'])
@@ -307,7 +307,7 @@ class Morpheus::Cli::VirtualImages
307
307
  image_types = json_response['virtualImageTypes']
308
308
  print_h1 "Morpheus Virtual Image Types"
309
309
  if image_types.nil? || image_types.empty?
310
- print yellow,"No image types currently exist on this appliance. This could be a seed issue.",reset,"\n"
310
+ print cyan,"No image types found.",reset,"\n"
311
311
  else
312
312
  rows = image_types.collect do |lb_type|
313
313
  {name: lb_type['name'], code: lb_type['code']}
@@ -1,8 +1,9 @@
1
1
  require 'morpheus/cli/cli_command'
2
+ require 'morpheus/cli/mixins/accounts_helper'
2
3
 
3
4
  class Morpheus::Cli::WhitelabelSettingsCommand
4
5
  include Morpheus::Cli::CliCommand
5
- # include Morpheus::Cli::AccountsHelper
6
+ include Morpheus::Cli::AccountsHelper
6
7
 
7
8
  set_command_name :'whitelabel-settings'
8
9
 
@@ -17,6 +18,7 @@ class Morpheus::Cli::WhitelabelSettingsCommand
17
18
  def connect(opts)
18
19
  @api_client = establish_remote_appliance_connection(opts)
19
20
  @whitelabel_settings_interface = @api_client.whitelabel_settings
21
+ @accounts_interface = @api_client.accounts
20
22
  end
21
23
 
22
24
  def handle(args)
@@ -27,6 +29,9 @@ class Morpheus::Cli::WhitelabelSettingsCommand
27
29
  options = {}
28
30
  optparse = Morpheus::Cli::OptionParser.new do |opts|
29
31
  opts.banner = subcommand_usage()
32
+ opts.on( '-a', '--account ACCOUNT', "Account Name or ID" ) do |val|
33
+ options[:account] = val
34
+ end
30
35
  opts.on('--details', "Show full (not truncated) contents of Terms of Use, Privacy Policy, Override CSS" ) do
31
36
  options[:details] = true
32
37
  end
@@ -44,12 +49,21 @@ class Morpheus::Cli::WhitelabelSettingsCommand
44
49
 
45
50
  begin
46
51
  params = parse_list_options(options)
52
+ account = nil
53
+ if options[:account]
54
+ account = find_account_by_name_or_id(options[:account])
55
+ if account.nil?
56
+ return 1
57
+ else
58
+ params['accountId'] = account['id']
59
+ end
60
+ end
47
61
  @whitelabel_settings_interface.setopts(options)
48
62
  if options[:dry_run]
49
- print_dry_run @whitelabel_settings_interface.dry.get()
63
+ print_dry_run @whitelabel_settings_interface.dry.get(params)
50
64
  return
51
65
  end
52
- json_response = @whitelabel_settings_interface.get()
66
+ json_response = @whitelabel_settings_interface.get(params)
53
67
  if options[:json]
54
68
  puts as_json(json_response, options, "whitelabelSettings")
55
69
  return 0
@@ -66,6 +80,7 @@ class Morpheus::Cli::WhitelabelSettingsCommand
66
80
  print_h1 "Whitelabel Settings"
67
81
  print cyan
68
82
  description_cols = {
83
+ "Account" => lambda {|it| it['account']['name'] rescue '' },
69
84
  "Enabled" => lambda {|it| format_boolean(it['enabled']) },
70
85
  "Appliance Name" => lambda {|it| it['applianceName'] },
71
86
  "Disable Support Menu" => lambda {|it| format_boolean(it['disableSupportMenu'])},
@@ -130,8 +145,12 @@ class Morpheus::Cli::WhitelabelSettingsCommand
130
145
  def update(args)
131
146
  options = {}
132
147
  params = {}
148
+ query_params = {}
133
149
  optparse = Morpheus::Cli::OptionParser.new do |opts|
134
150
  opts.banner = opts.banner = subcommand_usage()
151
+ opts.on( '-a', '--account ACCOUNT', "Account Name or ID" ) do |val|
152
+ options[:account] = val
153
+ end
135
154
  opts.on('--active [on|off]', String, "Can be used to enable / disable whitelabel feature") do |val|
136
155
  params['enabled'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == '1' || val.to_s == ''
137
156
  end
@@ -237,6 +256,15 @@ class Morpheus::Cli::WhitelabelSettingsCommand
237
256
  end
238
257
 
239
258
  begin
259
+ account = nil
260
+ if options[:account]
261
+ account = find_account_by_name_or_id(options[:account])
262
+ if account.nil?
263
+ return 1
264
+ else
265
+ query_params['accountId'] = account['id']
266
+ end
267
+ end
240
268
  payload = parse_payload(options)
241
269
  image_files = {}
242
270
 
@@ -258,17 +286,17 @@ class Morpheus::Cli::WhitelabelSettingsCommand
258
286
 
259
287
  @whitelabel_settings_interface.setopts(options)
260
288
  if options[:dry_run]
261
- print_dry_run @whitelabel_settings_interface.dry.update(payload, image_files)
289
+ print_dry_run @whitelabel_settings_interface.dry.update(payload, query_params)
262
290
  return
263
291
  end
264
- json_response = @whitelabel_settings_interface.update(payload, image_files)
292
+ json_response = @whitelabel_settings_interface.update(payload, query_params)
265
293
 
266
294
  if options[:json]
267
295
  puts as_json(json_response, options)
268
296
  elsif !options[:quiet]
269
297
  if json_response['success']
270
298
  print_green_success "Updated whitelabel settings"
271
- get([] + (options[:remote] ? ["-r",options[:remote]] : []))
299
+ get([] + (options[:account] ? ["-a",options[:account]] : []) + (options[:remote] ? ["-r",options[:remote]] : []))
272
300
  else
273
301
  print_red_alert "Error updating whitelabel settings: #{json_response['msg'] || json_response['errors']}"
274
302
  end
@@ -281,10 +309,14 @@ class Morpheus::Cli::WhitelabelSettingsCommand
281
309
  end
282
310
 
283
311
  def update_images(args)
284
- options = {}
285
312
  params = {}
313
+ query_params = {}
314
+ options = {}
286
315
  optparse = Morpheus::Cli::OptionParser.new do |opts|
287
316
  opts.banner = opts.banner = subcommand_usage()
317
+ opts.on( '-a', '--account ACCOUNT', "Account Name or ID" ) do |val|
318
+ options[:account] = val
319
+ end
288
320
  opts.on("--header-logo FILE", String, "Header logo image. Local path of a file to upload (png|jpg|svg)") do |val|
289
321
  options[:headerLogo] = val
290
322
  end
@@ -322,6 +354,15 @@ class Morpheus::Cli::WhitelabelSettingsCommand
322
354
  end
323
355
 
324
356
  begin
357
+ account = nil
358
+ if options[:account]
359
+ account = find_account_by_name_or_id(options[:account])
360
+ if account.nil?
361
+ return 1
362
+ else
363
+ query_params['accountId'] = account['id']
364
+ end
365
+ end
325
366
  payload = parse_payload(options)
326
367
 
327
368
  if !payload
@@ -348,11 +389,11 @@ class Morpheus::Cli::WhitelabelSettingsCommand
348
389
 
349
390
  @whitelabel_settings_interface.setopts(options)
350
391
  if options[:dry_run]
351
- print_dry_run @whitelabel_settings_interface.dry.update_images(payload)
392
+ print_dry_run @whitelabel_settings_interface.dry.update_images(payload, query_params)
352
393
  return
353
394
  end
354
395
 
355
- json_response = @whitelabel_settings_interface.update_images(payload)
396
+ json_response = @whitelabel_settings_interface.update_images(payload, query_params)
356
397
 
357
398
  if options[:json]
358
399
  puts as_json(json_response, options)
@@ -367,9 +408,13 @@ class Morpheus::Cli::WhitelabelSettingsCommand
367
408
  end
368
409
 
369
410
  def reset_image(args)
411
+ query_params = {}
370
412
  options = {}
371
413
  optparse = Morpheus::Cli::OptionParser.new do |opts|
372
414
  opts.banner = opts.banner = subcommand_usage("[image-type]")
415
+ opts.on( '-a', '--account ACCOUNT', "Account Name or ID" ) do |val|
416
+ options[:account] = val
417
+ end
373
418
  build_common_options(opts, options, [:json, :dry_run, :quiet, :remote])
374
419
  opts.footer = "Reset your whitelabel image.\n" +
375
420
  "[image-type] is required. This is the whitelabel image type (#{@image_types.collect {|k,v| k}.join('|')})"
@@ -388,14 +433,23 @@ class Morpheus::Cli::WhitelabelSettingsCommand
388
433
  end
389
434
 
390
435
  begin
436
+ account = nil
437
+ if options[:account]
438
+ account = find_account_by_name_or_id(options[:account])
439
+ if account.nil?
440
+ return 1
441
+ else
442
+ query_params['accountId'] = account['id']
443
+ end
444
+ end
391
445
  image_type = @image_types[args[0]]
392
446
  @whitelabel_settings_interface.setopts(options)
393
447
  if options[:dry_run]
394
- print_dry_run @whitelabel_settings_interface.dry.reset_image(image_type)
448
+ print_dry_run @whitelabel_settings_interface.dry.reset_image(image_type, query_params)
395
449
  return
396
450
  end
397
451
 
398
- json_response = @whitelabel_settings_interface.reset_image(image_type)
452
+ json_response = @whitelabel_settings_interface.reset_image(image_type, query_params)
399
453
 
400
454
  if options[:json]
401
455
  puts as_json(json_response, options)
@@ -410,9 +464,13 @@ class Morpheus::Cli::WhitelabelSettingsCommand
410
464
  end
411
465
 
412
466
  def view_image(args)
467
+ params = {}
413
468
  options = {}
414
469
  optparse = Morpheus::Cli::OptionParser.new do |opts|
415
470
  opts.banner = opts.banner = subcommand_usage("[image-type]")
471
+ opts.on( '-a', '--account ACCOUNT', "Account Name or ID" ) do |val|
472
+ options[:account] = val
473
+ end
416
474
  build_common_options(opts, options, [:json, :dry_run, :quiet, :remote])
417
475
  opts.footer = "View your image of specified [image-type].\n" +
418
476
  "[image-type] is required. This is the whitelabel image type (#{@image_types.collect {|k,v| k}.join('|')})\n" +
@@ -432,14 +490,23 @@ class Morpheus::Cli::WhitelabelSettingsCommand
432
490
  end
433
491
 
434
492
  begin
493
+ account = nil
494
+ if options[:account]
495
+ account = find_account_by_name_or_id(options[:account])
496
+ if account.nil?
497
+ return 1
498
+ else
499
+ params['accountId'] = account['id']
500
+ end
501
+ end
435
502
  image_type = @image_types[args[0]]
436
503
  @whitelabel_settings_interface.setopts(options)
437
504
  if options[:dry_run]
438
- print_dry_run @whitelabel_settings_interface.dry.get()
505
+ print_dry_run @whitelabel_settings_interface.dry.get(params)
439
506
  return
440
507
  end
441
508
 
442
- whitelabel_settings = @whitelabel_settings_interface.get()['whitelabelSettings']
509
+ whitelabel_settings = @whitelabel_settings_interface.get(params)['whitelabelSettings']
443
510
 
444
511
  if link = whitelabel_settings[image_type]
445
512
  if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
@@ -461,9 +528,13 @@ class Morpheus::Cli::WhitelabelSettingsCommand
461
528
  end
462
529
 
463
530
  def download_image(args)
531
+ params = {}
464
532
  options = {}
465
533
  optparse = Morpheus::Cli::OptionParser.new do |opts|
466
534
  opts.banner = opts.banner = subcommand_usage("[image-type] [local-file]")
535
+ opts.on( '-a', '--account ACCOUNT', "Account Name or ID" ) do |val|
536
+ options[:account] = val
537
+ end
467
538
  opts.on( '-f', '--force', "Overwrite existing [local-file] if it exists." ) do
468
539
  options[:overwrite] = true
469
540
  end
@@ -489,6 +560,15 @@ class Morpheus::Cli::WhitelabelSettingsCommand
489
560
  end
490
561
 
491
562
  begin
563
+ account = nil
564
+ if options[:account]
565
+ account = find_account_by_name_or_id(options[:account])
566
+ if account.nil?
567
+ return 1
568
+ else
569
+ params['accountId'] = account['id']
570
+ end
571
+ end
492
572
  image_type = @image_types[args[0]]
493
573
  outfile = File.expand_path(args[1])
494
574
  outdir = File.dirname(outfile)
@@ -513,7 +593,7 @@ class Morpheus::Cli::WhitelabelSettingsCommand
513
593
 
514
594
  @whitelabel_settings_interface.setopts(options)
515
595
  if options[:dry_run]
516
- print_dry_run @whitelabel_settings_interface.dry.download_image(image_type, outfile)
596
+ print_dry_run @whitelabel_settings_interface.dry.download_image(image_type, outfile, params)
517
597
  return
518
598
  end
519
599
 
@@ -521,7 +601,7 @@ class Morpheus::Cli::WhitelabelSettingsCommand
521
601
  print cyan + "Downloading #{args[0]} to #{outfile} ... "
522
602
  end
523
603
 
524
- http_response = @whitelabel_settings_interface.download_image(image_type, outfile)
604
+ http_response = @whitelabel_settings_interface.download_image(image_type, outfile, params)
525
605
 
526
606
  success = http_response.code.to_i == 200
527
607
  if success
@@ -58,7 +58,7 @@ class Morpheus::Cli::WikiCommand
58
58
  subtitles += parse_list_subtitles(options)
59
59
  print_h1 title, subtitles
60
60
  if pages.empty?
61
- print yellow,"No wiki pages found.",reset,"\n"
61
+ print cyan,"No wiki pages found.",reset,"\n"
62
62
  else
63
63
  columns = [
64
64
  {"ID" => lambda {|page| page['id'] } },
@@ -386,7 +386,7 @@ class Morpheus::Cli::WikiCommand
386
386
  subtitles += parse_list_subtitles(options)
387
387
  print_h1 title, subtitles
388
388
  if categories.empty?
389
- print yellow,"No wiki categories found.",reset,"\n"
389
+ print cyan,"No wiki categories found.",reset,"\n"
390
390
  else
391
391
  columns = [
392
392
  {"CATEGORY" => lambda {|page| page['name'] } },
@@ -351,15 +351,14 @@ class Morpheus::Cli::Workflows
351
351
  #task_names = tasks.collect {|it| it['name'] }
352
352
  print_h2 "Workflow Tasks"
353
353
  if tasks.empty?
354
- print yellow,"No tasks in this workflow.",reset,"\n"
354
+ print cyan,"No tasks in this workflow.",reset,"\n"
355
355
  else
356
356
  print cyan
357
357
  # tasks.each_with_index do |taskSetTask, index|
358
358
  # puts "#{(index+1).to_s.rjust(3, ' ')}. #{taskSetTask['task']['name']}"
359
359
  # end
360
360
  task_set_task_columns = [
361
- # this is the ID needed for the config options, by name would be nicer
362
- {"ID" => lambda {|it| it['id'] } },
361
+ #{"ID" => lambda {|it| it['id'] } },
363
362
  {"TASK ID" => lambda {|it| it['task']['id'] } },
364
363
  {"NAME" => lambda {|it| it['task']['name'] } },
365
364
  {"TYPE" => lambda {|it| it['task']['taskType'] ? it['task']['taskType']['name'] : '' } },
@@ -284,16 +284,17 @@ def filter_data(data, include_fields=nil, exclude_fields=nil)
284
284
  end
285
285
  end
286
286
 
287
- def format_bytes(bytes, units="B")
287
+ def format_bytes(bytes, units="B", round=nil)
288
288
  out = ""
289
289
  if bytes
290
290
  if bytes < 1024 && units == "B"
291
291
  out = "#{bytes.to_i} B"
292
292
  else
293
- out = Filesize.from("#{bytes} #{units}").pretty.strip
293
+ out = Filesize.from("#{bytes}#{units == 'auto' ? '' : " #{units}"}").pretty.strip
294
+ out = out.split(' ')[0].to_f.round(round).to_s + ' ' + out.split(' ')[1] if round
294
295
  end
295
296
  end
296
- return out
297
+ out
297
298
  end
298
299
 
299
300
  # returns bytes in an abbreviated format
@@ -343,7 +344,7 @@ end
343
344
 
344
345
  # returns currency amount formatted like "$4,5123.00". 0.00 is formatted as "$0"
345
346
  # this is not ideal
346
- def format_money(amount, currency='usd')
347
+ def format_money(amount, currency='usd', opts={})
347
348
  if amount.to_f == 0
348
349
  return currency_sym(currency).to_s + "0"
349
350
  # elsif amount.to_f < 0.01
@@ -357,6 +358,14 @@ def format_money(amount, currency='usd')
357
358
  rtn = rtn + (['0'] * (2 - rtn.split('.')[1].length) * '')
358
359
  end
359
360
  dollars,cents = rtn.split(".")
360
- currency_sym(currency).to_s + format_number(dollars.to_i) + "." + cents
361
+ rtn = currency_sym(currency).to_s + format_number(dollars.to_i.abs) + "." + cents
362
+
363
+ if dollars.to_i < 0
364
+ rtn = "(#{rtn})"
365
+ if opts[:minus_color]
366
+ rtn = "#{opts[:minus_color]}#{rtn}#{opts[:return_color] || cyan}"
367
+ end
368
+ end
369
+ rtn
361
370
  end
362
371
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: morpheus-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.6
4
+ version: 4.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Estes
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2020-03-18 00:00:00.000000000 Z
14
+ date: 2020-04-09 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -203,6 +203,7 @@ files:
203
203
  - lib/morpheus/api/file_copy_request_interface.rb
204
204
  - lib/morpheus/api/group_policies_interface.rb
205
205
  - lib/morpheus/api/groups_interface.rb
206
+ - lib/morpheus/api/guidance_interface.rb
206
207
  - lib/morpheus/api/health_interface.rb
207
208
  - lib/morpheus/api/image_builder_boot_scripts_interface.rb
208
209
  - lib/morpheus/api/image_builder_image_builds_interface.rb
@@ -338,6 +339,7 @@ files:
338
339
  - lib/morpheus/cli/expression_parser.rb
339
340
  - lib/morpheus/cli/file_copy_request_command.rb
340
341
  - lib/morpheus/cli/groups.rb
342
+ - lib/morpheus/cli/guidance_command.rb
341
343
  - lib/morpheus/cli/health_command.rb
342
344
  - lib/morpheus/cli/hosts.rb
343
345
  - lib/morpheus/cli/image_builder_command.rb