morpheus-cli 5.0.0 → 5.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile +1 -1
  3. data/lib/morpheus/api/api_client.rb +12 -0
  4. data/lib/morpheus/api/billing_interface.rb +1 -0
  5. data/lib/morpheus/api/deploy_interface.rb +1 -1
  6. data/lib/morpheus/api/deployments_interface.rb +20 -1
  7. data/lib/morpheus/api/forgot_password_interface.rb +17 -0
  8. data/lib/morpheus/api/instances_interface.rb +7 -0
  9. data/lib/morpheus/api/search_interface.rb +13 -0
  10. data/lib/morpheus/api/servers_interface.rb +7 -0
  11. data/lib/morpheus/api/usage_interface.rb +18 -0
  12. data/lib/morpheus/cli.rb +4 -1
  13. data/lib/morpheus/cli/cli_command.rb +26 -9
  14. data/lib/morpheus/cli/commands/standard/curl_command.rb +3 -5
  15. data/lib/morpheus/cli/commands/standard/history_command.rb +3 -1
  16. data/lib/morpheus/cli/commands/standard/man_command.rb +74 -40
  17. data/lib/morpheus/cli/deploy.rb +199 -90
  18. data/lib/morpheus/cli/deployments.rb +341 -28
  19. data/lib/morpheus/cli/deploys.rb +206 -41
  20. data/lib/morpheus/cli/error_handler.rb +7 -0
  21. data/lib/morpheus/cli/forgot_password.rb +133 -0
  22. data/lib/morpheus/cli/health_command.rb +2 -2
  23. data/lib/morpheus/cli/hosts.rb +169 -32
  24. data/lib/morpheus/cli/instances.rb +83 -32
  25. data/lib/morpheus/cli/invoices_command.rb +33 -16
  26. data/lib/morpheus/cli/logs_command.rb +9 -6
  27. data/lib/morpheus/cli/mixins/deployments_helper.rb +31 -2
  28. data/lib/morpheus/cli/mixins/print_helper.rb +0 -21
  29. data/lib/morpheus/cli/mixins/provisioning_helper.rb +24 -4
  30. data/lib/morpheus/cli/option_types.rb +266 -17
  31. data/lib/morpheus/cli/remote.rb +35 -10
  32. data/lib/morpheus/cli/reports_command.rb +99 -30
  33. data/lib/morpheus/cli/search_command.rb +182 -0
  34. data/lib/morpheus/cli/setup.rb +1 -1
  35. data/lib/morpheus/cli/shell.rb +33 -11
  36. data/lib/morpheus/cli/tasks.rb +20 -21
  37. data/lib/morpheus/cli/usage_command.rb +64 -11
  38. data/lib/morpheus/cli/version.rb +1 -1
  39. data/lib/morpheus/cli/virtual_images.rb +280 -199
  40. data/lib/morpheus/cli/whoami.rb +6 -6
  41. data/lib/morpheus/cli/workflows.rb +33 -40
  42. data/lib/morpheus/formatters.rb +22 -0
  43. data/lib/morpheus/terminal.rb +6 -2
  44. metadata +7 -2
@@ -160,15 +160,15 @@ EOT
160
160
  print cyan
161
161
  print_description_list({
162
162
  "ID" => 'id',
163
- "Tenant" => lambda {|it| (it['account'] ? it['account']['name'] : '') + (@is_master_account ? " (Master Tenant)" : '') },
164
- "First Name" => 'firstName',
165
- "Last Name" => 'lastName',
166
- # "Name" => 'displayName',
167
- #"Name" => lambda {|it| it['firstName'] ? it['displayName'] : '' },
168
163
  "Username" => 'username',
164
+ # "First Name" => 'firstName',
165
+ # "Last Name" => 'lastName',
166
+ # "Name" => 'displayName',
167
+ "Name" => lambda {|it| "#{it['firstName']} #{it['lastName']}".strip },
169
168
  "Email" => 'email',
169
+ "Tenant" => lambda {|it| (it['account'] ? it['account']['name'] : '') + (@is_master_account ? " (Master Tenant)" : '') },
170
170
  "Role" => lambda {|it| format_user_role_names(it) },
171
- #"Remote" => lambda {|it| display_appliance(@appliance_name, @appliance_url) },
171
+ "Remote" => lambda {|it| display_appliance(@appliance_name, @appliance_url) },
172
172
  }, @current_user)
173
173
  print cyan
174
174
 
@@ -32,7 +32,7 @@ class Morpheus::Cli::Workflows
32
32
  params = {}
33
33
  options = {}
34
34
  optparse = Morpheus::Cli::OptionParser.new do |opts|
35
- opts.banner = subcommand_usage()
35
+ opts.banner = subcommand_usage("[search]")
36
36
  opts.on("-t", "--type TYPE", "Type of workflow. i.e. provision or operation. Default is provision.") do |val|
37
37
  workflow_type = val.to_s.downcase
38
38
  if workflow_type.include?('provision')
@@ -42,50 +42,43 @@ class Morpheus::Cli::Workflows
42
42
  end
43
43
  params['type'] = workflow_type
44
44
  end
45
- build_common_options(opts, options, [:list, :query, :json, :yaml, :csv, :fields, :dry_run, :remote])
45
+ build_standard_list_options(opts, options)
46
+ opts.footer = "List workflows."
46
47
  end
47
48
  optparse.parse!(args)
48
49
  connect(options)
49
- begin
50
- params.merge!(parse_list_options(options))
51
- @task_sets_interface.setopts(options)
52
- if options[:dry_run]
53
- print_dry_run @task_sets_interface.dry.get(params)
54
- return
55
- end
56
- json_response = @task_sets_interface.get(params)
57
- task_sets = json_response['taskSets']
58
- # print result and return output
59
- if options[:json]
60
- puts as_json(json_response, options, "taskSets")
61
- return 0
62
- elsif options[:csv]
63
- puts records_as_csv(json_response['taskSets'], options)
64
- return 0
65
- elsif options[:yaml]
66
- puts as_yaml(json_response, options, "taskSets")
67
- return 0
50
+ if args.count > 0
51
+ options[:phrase] = args.join(" ")
52
+ end
53
+ params.merge!(parse_list_options(options))
54
+ @task_sets_interface.setopts(options)
55
+ if options[:dry_run]
56
+ print_dry_run @task_sets_interface.dry.get(params)
57
+ return
58
+ end
59
+ json_response = @task_sets_interface.get(params)
60
+ task_sets = json_response['taskSets']
61
+ render_response(json_response, options, 'taskSets') do
62
+ title = "Morpheus Workflows"
63
+ subtitles = []
64
+ subtitles += parse_list_subtitles(options)
65
+ if params['type']
66
+ subtitles << "Type: #{params['type']}"
67
+ end
68
+ print_h1 title, subtitles
69
+ if task_sets.empty?
70
+ print cyan,"No workflows found.",reset,"\n"
68
71
  else
69
- task_sets = json_response['taskSets']
70
- title = "Morpheus Workflows"
71
- subtitles = []
72
- subtitles += parse_list_subtitles(options)
73
- if params['type']
74
- subtitles << "Type: #{params['type']}"
75
- end
76
- print_h1 title, subtitles
77
- if task_sets.empty?
78
- print cyan,"No workflows found.",reset,"\n"
79
- else
80
- print cyan
81
- print_workflows_table(task_sets)
82
- print_results_pagination(json_response)
83
- end
84
- print reset,"\n"
72
+ print cyan
73
+ print_workflows_table(task_sets)
74
+ print_results_pagination(json_response)
85
75
  end
86
- rescue RestClient::Exception => e
87
- print_rest_exception(e, options)
88
- exit 1
76
+ print reset,"\n"
77
+ end
78
+ if task_sets.empty?
79
+ return 1, "no workflows found"
80
+ else
81
+ return 0, nil
89
82
  end
90
83
  end
91
84
 
@@ -399,6 +399,7 @@ def format_currency(amount, currency='usd', opts={})
399
399
  sigdig = opts[:sigdig] ? opts[:sigdig].to_i : 2 # max decimal digits
400
400
  min_sigdig = opts[:min_sigdig] ? opts[:min_sigdig].to_i : 2 # min decimal digits
401
401
  display_value = format_sig_dig(amount, sigdig, min_sigdig, opts[:pad_zeros])
402
+ display_value = format_number(display_value) # commas
402
403
  rtn = currency_sym(currency).to_s + display_value
403
404
  if amount.to_i < 0
404
405
  rtn = "(#{rtn})"
@@ -415,3 +416,24 @@ alias :format_money :format_currency
415
416
  # def format_money(amount, currency='usd', opts={})
416
417
  # format_currency(amount, currency, opts)
417
418
  # end
419
+
420
+ def format_list(items, conjunction="and", limit=nil)
421
+ items = items ? items.clone : []
422
+ if limit
423
+ items = items.first(limit)
424
+ end
425
+ last_item = items.pop
426
+ if items.empty?
427
+ return "#{last_item}"
428
+ else
429
+ return items.join(", ") + (conjunction.to_s.empty? ? ", " : " #{conjunction} ") + "#{last_item}" + ((limit && limit < (items.size+1)) ? " ..." : "")
430
+ end
431
+ end
432
+
433
+ def anded_list(items, limit=nil)
434
+ format_list(items, "and", limit)
435
+ end
436
+
437
+ def ored_list(items, limit=nil)
438
+ format_list(items, "or", limit)
439
+ end
@@ -277,8 +277,12 @@ module Morpheus
277
277
  end
278
278
  end
279
279
  out << "Commands:\n"
280
- Morpheus::Cli::CliRegistry.all.keys.sort.each {|cmd|
281
- out << "\t#{cmd.to_s}\n"
280
+ sorted_commands = Morpheus::Cli::CliRegistry.all.values.sort { |x,y| x.command_name.to_s <=> y.command_name.to_s }
281
+ sorted_commands.each {|cmd|
282
+ # JD: not ready to show description yet, gotta finish filling in every command first
283
+ # maybe change 'View and manage' to something more concise like 'Manage'
284
+ # out << "\t#{cmd.command_name.to_s.ljust(28, ' ')} #{cmd.command_description}\n"
285
+ out << "\t#{cmd.command_name.to_s}\n"
282
286
  }
283
287
  # out << "Options:\n"
284
288
  out << optparse.to_s
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: 5.0.0
4
+ version: 5.0.1
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-09-29 00:00:00.000000000 Z
14
+ date: 2020-10-21 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -207,6 +207,7 @@ files:
207
207
  - lib/morpheus/api/execute_schedules_interface.rb
208
208
  - lib/morpheus/api/execution_request_interface.rb
209
209
  - lib/morpheus/api/file_copy_request_interface.rb
210
+ - lib/morpheus/api/forgot_password_interface.rb
210
211
  - lib/morpheus/api/group_policies_interface.rb
211
212
  - lib/morpheus/api/groups_interface.rb
212
213
  - lib/morpheus/api/guidance_interface.rb
@@ -273,6 +274,7 @@ files:
273
274
  - lib/morpheus/api/reports_interface.rb
274
275
  - lib/morpheus/api/rest_interface.rb
275
276
  - lib/morpheus/api/roles_interface.rb
277
+ - lib/morpheus/api/search_interface.rb
276
278
  - lib/morpheus/api/security_group_rules_interface.rb
277
279
  - lib/morpheus/api/security_groups_interface.rb
278
280
  - lib/morpheus/api/server_types_interface.rb
@@ -284,6 +286,7 @@ files:
284
286
  - lib/morpheus/api/subnets_interface.rb
285
287
  - lib/morpheus/api/task_sets_interface.rb
286
288
  - lib/morpheus/api/tasks_interface.rb
289
+ - lib/morpheus/api/usage_interface.rb
287
290
  - lib/morpheus/api/user_groups_interface.rb
288
291
  - lib/morpheus/api/user_settings_interface.rb
289
292
  - lib/morpheus/api/user_sources_interface.rb
@@ -354,6 +357,7 @@ files:
354
357
  - lib/morpheus/cli/execution_request_command.rb
355
358
  - lib/morpheus/cli/expression_parser.rb
356
359
  - lib/morpheus/cli/file_copy_request_command.rb
360
+ - lib/morpheus/cli/forgot_password.rb
357
361
  - lib/morpheus/cli/groups.rb
358
362
  - lib/morpheus/cli/guidance_command.rb
359
363
  - lib/morpheus/cli/health_command.rb
@@ -428,6 +432,7 @@ files:
428
432
  - lib/morpheus/cli/remote.rb
429
433
  - lib/morpheus/cli/reports_command.rb
430
434
  - lib/morpheus/cli/roles.rb
435
+ - lib/morpheus/cli/search_command.rb
431
436
  - lib/morpheus/cli/security_group_rules.rb
432
437
  - lib/morpheus/cli/security_groups.rb
433
438
  - lib/morpheus/cli/service_plans_command.rb