morpheus-cli 6.3.3 → 7.0.0

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 (32) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile +1 -1
  3. data/lib/morpheus/api/api_client.rb +8 -0
  4. data/lib/morpheus/api/backup_restores_interface.rb +4 -0
  5. data/lib/morpheus/api/backup_types_interface.rb +9 -0
  6. data/lib/morpheus/api/catalog_item_types_interface.rb +1 -2
  7. data/lib/morpheus/api/hub_interface.rb +25 -0
  8. data/lib/morpheus/cli/cli_command.rb +3 -0
  9. data/lib/morpheus/cli/commands/backup_types_command.rb +53 -0
  10. data/lib/morpheus/cli/commands/backups_command.rb +100 -21
  11. data/lib/morpheus/cli/commands/catalog_item_types_command.rb +3 -31
  12. data/lib/morpheus/cli/commands/clouds.rb +22 -4
  13. data/lib/morpheus/cli/commands/curl_command.rb +1 -1
  14. data/lib/morpheus/cli/commands/groups.rb +50 -7
  15. data/lib/morpheus/cli/commands/hub.rb +215 -0
  16. data/lib/morpheus/cli/commands/jobs_command.rb +10 -6
  17. data/lib/morpheus/cli/commands/library_forms_command.rb +1 -1
  18. data/lib/morpheus/cli/commands/library_option_lists_command.rb +1 -1
  19. data/lib/morpheus/cli/commands/library_option_types_command.rb +1 -1
  20. data/lib/morpheus/cli/commands/license.rb +151 -86
  21. data/lib/morpheus/cli/commands/networks_command.rb +1 -1
  22. data/lib/morpheus/cli/commands/security_packages.rb +1 -1
  23. data/lib/morpheus/cli/commands/setup.rb +1 -1
  24. data/lib/morpheus/cli/commands/tasks.rb +2 -2
  25. data/lib/morpheus/cli/commands/user_settings_command.rb +10 -1
  26. data/lib/morpheus/cli/mixins/backups_helper.rb +4 -3
  27. data/lib/morpheus/cli/mixins/jobs_helper.rb +3 -0
  28. data/lib/morpheus/cli/mixins/print_helper.rb +80 -2
  29. data/lib/morpheus/cli/option_types.rb +9 -2
  30. data/lib/morpheus/cli/version.rb +1 -1
  31. data/lib/morpheus/routes.rb +2 -1
  32. metadata +6 -2
@@ -119,10 +119,10 @@ module Morpheus::Cli::BackupsHelper
119
119
  "Backup" => lambda {|it| it['backup']['name'] rescue '' },
120
120
  "Status" => lambda {|it| format_backup_result_status(it) },
121
121
  #"Duration" => lambda {|it| format_duration(it['startDate'], it['endDate']) },
122
- "Duration" => lambda {|it| format_duration_milliseconds(it['durationMillis']) },
122
+ "Duration" => lambda {|it| format_duration_milliseconds(it['durationMillis']) if it['durationMillis'].to_i > 0 },
123
123
  "Start Date" => lambda {|it| format_local_dt(it['startDate']) },
124
124
  "End Date" => lambda {|it| format_local_dt(it['endDate']) },
125
- "Size" => lambda {|it| format_bytes(it['sizeInMb'], 'MB') },
125
+ "Size" => lambda {|it| it['sizeInMb'].to_i != 0 ? format_bytes(it['sizeInMb'], 'MB') : '' },
126
126
  }
127
127
  end
128
128
 
@@ -155,7 +155,7 @@ module Morpheus::Cli::BackupsHelper
155
155
  "Target" => lambda {|it| it['instance']['name'] rescue '' },
156
156
  "Status" => lambda {|it| format_backup_result_status(it) },
157
157
  #"Duration" => lambda {|it| format_duration(it['startDate'], it['endDate']) },
158
- "Duration" => lambda {|it| format_duration_milliseconds(it['durationMillis']) },
158
+ "Duration" => lambda {|it| format_duration_milliseconds(it['durationMillis']) if it['durationMillis'].to_i > 0 },
159
159
  "Start Date" => lambda {|it| format_local_dt(it['startDate']) },
160
160
  "End Date" => lambda {|it| format_local_dt(it['endDate']) },
161
161
  }
@@ -168,4 +168,5 @@ module Morpheus::Cli::BackupsHelper
168
168
  def format_backup_restore_status(backup_restore, return_color=cyan)
169
169
  format_backup_result_status(backup_restore, return_color)
170
170
  end
171
+
171
172
  end
@@ -84,6 +84,7 @@ module Morpheus::Cli::JobsHelper
84
84
  end
85
85
  if process_data[:error] && process_data[:error].strip.length > 0
86
86
  print_h2 "Error"
87
+ print red
87
88
  print (process['message'] || process['error']).to_s.strip
88
89
  print reset,"\n"
89
90
  end
@@ -129,6 +130,8 @@ module Morpheus::Cli::JobsHelper
129
130
  out << "#{green}#{status_string.upcase}"
130
131
  elsif ['error', 'offline', 'failed', 'failure'].include?(status_string)
131
132
  out << "#{red}#{status_string.upcase}"
133
+ elsif ['running'].include?(status_string)
134
+ out << "#{cyan}#{status_string.upcase}"
132
135
  else
133
136
  out << "#{yellow}#{status_string.upcase}"
134
137
  end
@@ -514,7 +514,8 @@ module Morpheus::Cli::PrintHelper
514
514
  else
515
515
  percent = ((used_value.to_f / max_value.to_f) * 100)
516
516
  end
517
- percent_label = ((used_value.nil? || max_value.to_f == 0.0) ? "n/a" : "#{percent.round(percent_sigdig)}%").rjust(6, ' ')
517
+ unlimited_label = opts[:unlimited_label] || "n/a"
518
+ percent_label = ((used_value.nil? || max_value.to_f == 0.0) ? unlimited_label : "#{percent.round(percent_sigdig)}%").rjust(6, ' ')
518
519
  bar_display = ""
519
520
  if percent > 100
520
521
  max_bars.times { bars << "|" }
@@ -1000,6 +1001,83 @@ module Morpheus::Cli::PrintHelper
1000
1001
  print as_description_list(obj, columns, opts)
1001
1002
  end
1002
1003
 
1004
+ def print_pretty_details(obj, opts={})
1005
+ print as_pretty_details(obj, opts)
1006
+ end
1007
+
1008
+ def as_pretty_details(obj, opts={})
1009
+ print as_pretty_details(obj, opts.merge({pretty: true}))
1010
+ end
1011
+
1012
+ def print_details(obj, opts={})
1013
+ print as_details(obj, opts)
1014
+ end
1015
+
1016
+ def as_details(obj, opts={})
1017
+ #return "" if obj.nil?
1018
+ columns = {}
1019
+ keys = obj.keys
1020
+ if opts[:sort]
1021
+ keys.sort!
1022
+ end
1023
+ keys.each do |key|
1024
+ display_proc = nil
1025
+ if opts[:column_format] && opts[:column_format].key?(key.to_sym)
1026
+ display_proc = opts[:column_format][key.to_sym]
1027
+ else
1028
+ display_proc = lambda {|it| format_detail_value(it[key]) }
1029
+ end
1030
+ label = opts[:pretty] ? key.to_s.titleize : key.to_s
1031
+ columns[label] = display_proc
1032
+ end
1033
+ as_description_list(obj, columns, opts)
1034
+ end
1035
+
1036
+ def format_detail_value(value)
1037
+ rtn = value
1038
+ if value.is_a?(Array)
1039
+ # show the first three objects
1040
+ rtn = value.first(3).collect { |row| format_abbreviated_value(row) }.join(", ")
1041
+ elsif value.is_a?(Hash)
1042
+ # show the first three properties
1043
+ keys = values.keys.select { |key| value[key].is_a?(Numeric) || value[key].is_a?(String) }.first(3)
1044
+ rtn = keys.collect { |key|
1045
+ "#{key.to_s.titleize}: #{format_abbreviated_value(value[key])}"
1046
+ }.join(", ")
1047
+ elsif value.is_a?(TrueClass) || value.is_a?(FalseClass)
1048
+ rtn = format_boolean(value)
1049
+ else
1050
+ rtn = value.to_s
1051
+ end
1052
+ return rtn
1053
+ end
1054
+
1055
+ def format_abbreviated_value(value)
1056
+ if value.is_a?(Hash)
1057
+ if value.keys.size == 0
1058
+ "{}"
1059
+ else
1060
+ # show the first three properties
1061
+ keys = value.keys.select { |key| value[key].is_a?(Numeric) || value[key].is_a?(String) }.first(3)
1062
+ keys.collect { |key|
1063
+ "#{key.to_s.titleize}: #{value[key]}"
1064
+ }.join(", ")
1065
+ end
1066
+ elsif value.is_a?(Array)
1067
+ if value.size == 0
1068
+ return "[]"
1069
+ elsif obj.size == 1
1070
+ "[(#{obj.size})]"
1071
+ else
1072
+ "[(#{obj.size})]"
1073
+ end
1074
+ elsif value.is_a?(TrueClass) || value.is_a?(FalseClass)
1075
+ format_boolean(value)
1076
+ else
1077
+ value.to_s
1078
+ end
1079
+ end
1080
+
1003
1081
  # build_column_definitions constructs an Array of column definitions (OpenStruct)
1004
1082
  # Each column is defined by a label (String), and a display_method (Proc)
1005
1083
  #
@@ -1059,7 +1137,7 @@ module Morpheus::Cli::PrintHelper
1059
1137
  column_def.display_method = lambda {|data| get_object_value(data, v) }
1060
1138
  elsif v.is_a?(Proc)
1061
1139
  column_def.display_method = v
1062
- elsif v.is_a?(Hash) || v.is_a?(OStruct)
1140
+ elsif v.is_a?(Hash) || v.is_a?(OpenStruct)
1063
1141
  if v[:display_name] || v[:label]
1064
1142
  column_def.label = v[:display_name] || v[:label]
1065
1143
  end
@@ -1113,8 +1113,15 @@ module Morpheus
1113
1113
  value_found = false
1114
1114
  value = nil
1115
1115
  while !value_found do
1116
- print "#{option_type['fieldLabel']}#{option_type['fieldAddOn'] ? (' (' + option_type['fieldAddOn'] + ') ') : '' }#{!option_type['required'] ? ' (optional)' : ''}#{!option_type['defaultValue'].to_s.empty? ? ' ['+option_type['defaultValue'].to_s+']' : ''}: "
1117
- input = $stdin.gets.chomp!
1116
+ # print "#{option_type['fieldLabel']}#{option_type['fieldAddOn'] ? (' (' + option_type['fieldAddOn'] + ') ') : '' }#{!option_type['required'] ? ' (optional)' : ''}#{!option_type['defaultValue'].to_s.empty? ? ' ['+option_type['defaultValue'].to_s+']' : ''}: "
1117
+ # input = $stdin.gets.chomp!
1118
+ Readline.completion_append_character = ""
1119
+ Readline.basic_word_break_characters = ''
1120
+ Readline.completion_proc = nil
1121
+ prompt_label = "#{option_type['fieldLabel']}#{option_type['fieldAddOn'] ? (' (' + option_type['fieldAddOn'] + ') ') : '' }#{!option_type['required'] ? ' (optional)' : ''}#{!option_type['defaultValue'].to_s.empty? ? ' ['+option_type['defaultValue'].to_s+']' : ''}: "
1122
+ input = Readline.readline(prompt_label, false).to_s
1123
+ input = input.chomp #.strip
1124
+
1118
1125
  value = input.empty? ? option_type['defaultValue'] : input
1119
1126
  if input == '?'
1120
1127
  help_prompt(option_type)
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Morpheus
3
3
  module Cli
4
- VERSION = "6.3.3"
4
+ VERSION = "7.0.0"
5
5
  end
6
6
  end
@@ -223,9 +223,10 @@ module Morpheus::Routes
223
223
  path = "/admin/settings/environments"
224
224
  when "software-licenses"
225
225
  path = "/admin/settings/software-licenses"
226
- when "license"
226
+ when "license","licenses"
227
227
  path = "/admin/settings/#!license"
228
228
  end
229
+ # todo: this is weird, fix it so "view license matches license before software-licenses without needing the above alias..
229
230
  # dasherize path and attempt to match the plural first
230
231
  plural_path = path.pluralize
231
232
  paths = [path.dasherize]
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: 6.3.3
4
+ version: 7.0.0
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: 2024-01-09 00:00:00.000000000 Z
14
+ date: 2024-03-21 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -204,6 +204,7 @@ files:
204
204
  - lib/morpheus/api/backup_service_types_interface.rb
205
205
  - lib/morpheus/api/backup_services_interface.rb
206
206
  - lib/morpheus/api/backup_settings_interface.rb
207
+ - lib/morpheus/api/backup_types_interface.rb
207
208
  - lib/morpheus/api/backups_interface.rb
208
209
  - lib/morpheus/api/billing_interface.rb
209
210
  - lib/morpheus/api/blueprints_interface.rb
@@ -238,6 +239,7 @@ files:
238
239
  - lib/morpheus/api/guidance_interface.rb
239
240
  - lib/morpheus/api/guidance_settings_interface.rb
240
241
  - lib/morpheus/api/health_interface.rb
242
+ - lib/morpheus/api/hub_interface.rb
241
243
  - lib/morpheus/api/image_builder_boot_scripts_interface.rb
242
244
  - lib/morpheus/api/image_builder_image_builds_interface.rb
243
245
  - lib/morpheus/api/image_builder_interface.rb
@@ -381,6 +383,7 @@ files:
381
383
  - lib/morpheus/cli/commands/backup_results_command.rb
382
384
  - lib/morpheus/cli/commands/backup_services_command.rb
383
385
  - lib/morpheus/cli/commands/backup_settings_command.rb
386
+ - lib/morpheus/cli/commands/backup_types_command.rb
384
387
  - lib/morpheus/cli/commands/backups_command.rb
385
388
  - lib/morpheus/cli/commands/benchmark_command.rb
386
389
  - lib/morpheus/cli/commands/blueprints_command.rb
@@ -424,6 +427,7 @@ files:
424
427
  - lib/morpheus/cli/commands/health_command.rb
425
428
  - lib/morpheus/cli/commands/history_command.rb
426
429
  - lib/morpheus/cli/commands/hosts.rb
430
+ - lib/morpheus/cli/commands/hub.rb
427
431
  - lib/morpheus/cli/commands/image_builder_command.rb
428
432
  - lib/morpheus/cli/commands/instance_types.rb
429
433
  - lib/morpheus/cli/commands/instances.rb