morpheus-cli 4.2.14 → 4.2.19

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 (78) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile +1 -1
  3. data/README.md +8 -6
  4. data/lib/morpheus/api/api_client.rb +32 -14
  5. data/lib/morpheus/api/auth_interface.rb +4 -2
  6. data/lib/morpheus/api/backup_jobs_interface.rb +9 -0
  7. data/lib/morpheus/api/backups_interface.rb +16 -0
  8. data/lib/morpheus/api/deploy_interface.rb +25 -56
  9. data/lib/morpheus/api/deployments_interface.rb +44 -55
  10. data/lib/morpheus/api/doc_interface.rb +57 -0
  11. data/lib/morpheus/api/instances_interface.rb +5 -0
  12. data/lib/morpheus/api/rest_interface.rb +40 -0
  13. data/lib/morpheus/api/user_sources_interface.rb +0 -15
  14. data/lib/morpheus/api/users_interface.rb +2 -3
  15. data/lib/morpheus/benchmarking.rb +2 -2
  16. data/lib/morpheus/cli.rb +4 -1
  17. data/lib/morpheus/cli/access_token_command.rb +27 -10
  18. data/lib/morpheus/cli/apps.rb +21 -15
  19. data/lib/morpheus/cli/backup_jobs_command.rb +276 -0
  20. data/lib/morpheus/cli/backups_command.rb +271 -0
  21. data/lib/morpheus/cli/blueprints_command.rb +27 -61
  22. data/lib/morpheus/cli/boot_scripts_command.rb +1 -1
  23. data/lib/morpheus/cli/cli_command.rb +183 -45
  24. data/lib/morpheus/cli/cli_registry.rb +3 -0
  25. data/lib/morpheus/cli/clouds.rb +7 -10
  26. data/lib/morpheus/cli/clusters.rb +0 -18
  27. data/lib/morpheus/cli/commands/standard/benchmark_command.rb +23 -20
  28. data/lib/morpheus/cli/commands/standard/man_command.rb +1 -1
  29. data/lib/morpheus/cli/credentials.rb +13 -9
  30. data/lib/morpheus/cli/deploy.rb +374 -0
  31. data/lib/morpheus/cli/deployments.rb +521 -197
  32. data/lib/morpheus/cli/deploys.rb +271 -126
  33. data/lib/morpheus/cli/doc.rb +182 -0
  34. data/lib/morpheus/cli/error_handler.rb +23 -8
  35. data/lib/morpheus/cli/errors.rb +3 -2
  36. data/lib/morpheus/cli/image_builder_command.rb +2 -2
  37. data/lib/morpheus/cli/instances.rb +136 -17
  38. data/lib/morpheus/cli/invoices_command.rb +339 -225
  39. data/lib/morpheus/cli/jobs_command.rb +2 -2
  40. data/lib/morpheus/cli/library_layouts_command.rb +1 -1
  41. data/lib/morpheus/cli/library_option_lists_command.rb +61 -125
  42. data/lib/morpheus/cli/library_option_types_command.rb +32 -37
  43. data/lib/morpheus/cli/login.rb +9 -3
  44. data/lib/morpheus/cli/mixins/accounts_helper.rb +158 -100
  45. data/lib/morpheus/cli/mixins/backups_helper.rb +115 -0
  46. data/lib/morpheus/cli/mixins/deployments_helper.rb +135 -0
  47. data/lib/morpheus/cli/mixins/library_helper.rb +32 -0
  48. data/lib/morpheus/cli/mixins/option_source_helper.rb +1 -1
  49. data/lib/morpheus/cli/mixins/print_helper.rb +149 -84
  50. data/lib/morpheus/cli/mixins/provisioning_helper.rb +2 -2
  51. data/lib/morpheus/cli/mixins/whoami_helper.rb +19 -6
  52. data/lib/morpheus/cli/network_routers_command.rb +1 -1
  53. data/lib/morpheus/cli/option_parser.rb +48 -5
  54. data/lib/morpheus/cli/option_types.rb +46 -10
  55. data/lib/morpheus/cli/price_sets_command.rb +1 -1
  56. data/lib/morpheus/cli/projects_command.rb +7 -7
  57. data/lib/morpheus/cli/remote.rb +3 -2
  58. data/lib/morpheus/cli/roles.rb +49 -92
  59. data/lib/morpheus/cli/security_groups.rb +7 -1
  60. data/lib/morpheus/cli/service_plans_command.rb +10 -10
  61. data/lib/morpheus/cli/setup.rb +1 -1
  62. data/lib/morpheus/cli/shell.rb +7 -6
  63. data/lib/morpheus/cli/subnets_command.rb +1 -1
  64. data/lib/morpheus/cli/tasks.rb +24 -10
  65. data/lib/morpheus/cli/tenants_command.rb +133 -163
  66. data/lib/morpheus/cli/user_groups_command.rb +20 -65
  67. data/lib/morpheus/cli/user_settings_command.rb +115 -13
  68. data/lib/morpheus/cli/user_sources_command.rb +57 -24
  69. data/lib/morpheus/cli/users.rb +210 -186
  70. data/lib/morpheus/cli/version.rb +1 -1
  71. data/lib/morpheus/cli/whitelabel_settings_command.rb +29 -5
  72. data/lib/morpheus/cli/whoami.rb +113 -6
  73. data/lib/morpheus/cli/workflows.rb +11 -8
  74. data/lib/morpheus/ext/hash.rb +21 -0
  75. data/lib/morpheus/formatters.rb +7 -19
  76. data/lib/morpheus/terminal.rb +1 -0
  77. metadata +12 -3
  78. data/lib/morpheus/cli/auth_command.rb +0 -105
@@ -279,7 +279,7 @@ class Morpheus::Cli::BootScriptsCommand
279
279
  options = {}
280
280
  optparse = Morpheus::Cli::OptionParser.new do |opts|
281
281
  opts.banner = subcommand_usage("[boot-script]")
282
- build_common_options(opts, options, [:account, :auto_confirm, :json, :dry_run, :remote])
282
+ build_common_options(opts, options, [:auto_confirm, :json, :dry_run, :remote])
283
283
  end
284
284
  optparse.parse!(args)
285
285
 
@@ -1,5 +1,6 @@
1
1
  require 'yaml'
2
2
  require 'json'
3
+ require 'fileutils'
3
4
  require 'morpheus/logging'
4
5
  require 'morpheus/benchmarking'
5
6
  require 'morpheus/cli/option_parser'
@@ -169,14 +170,18 @@ module Morpheus
169
170
  full_field_name = "#{field_namespace.join('.')}.#{field_name}"
170
171
  end
171
172
 
172
- description = "#{option_type['fieldLabel']}#{option_type['fieldAddOn'] ? ('(' + option_type['fieldAddOn'] + ') ') : '' }#{!option_type['required'] ? ' (optional)' : ''}#{option_type['defaultValue'] ? ' Default: '+option_type['defaultValue'].to_s : ''}"
173
+ description = "#{option_type['fieldLabel']}#{option_type['fieldAddOn'] ? ('(' + option_type['fieldAddOn'] + ') ') : '' }#{!option_type['required'] ? ' (optional)' : ''}"
173
174
  if option_type['description']
174
175
  # description << "\n #{option_type['description']}"
175
176
  description << " - #{option_type['description']}"
176
177
  end
178
+ if option_type['defaultValue']
179
+ description << ". Default: #{option_type['defaultValue']}"
180
+ end
177
181
  if option_type['helpBlock']
178
182
  description << "\n #{option_type['helpBlock']}"
179
183
  end
184
+
180
185
  # description = option_type['description'].to_s
181
186
  # if option_type['defaultValue']
182
187
  # description = "#{description} Default: #{option_type['defaultValue']}"
@@ -228,11 +233,11 @@ module Morpheus
228
233
  ## the standard options for a command that makes api requests (most of them)
229
234
 
230
235
  def build_standard_get_options(opts, options, includes=[], excludes=[])
231
- build_common_options(opts, options, [:query, :json, :yaml, :csv, :fields, :quiet, :dry_run, :remote] + includes, excludes)
236
+ build_common_options(opts, options, includes + [:query, :json, :yaml, :csv, :fields, :quiet, :dry_run, :remote], excludes)
232
237
  end
233
238
 
234
239
  def build_standard_post_options(opts, options, includes=[], excludes=[])
235
- build_common_options(opts, options, [:options, :payload, :json, :quiet, :dry_run, :remote] + includes, excludes)
240
+ build_common_options(opts, options, includes + [:options, :payload, :json, :quiet, :dry_run, :remote], excludes)
236
241
  end
237
242
 
238
243
  def build_standard_put_options(opts, options, includes=[], excludes=[])
@@ -240,7 +245,7 @@ module Morpheus
240
245
  end
241
246
 
242
247
  def build_standard_delete_options(opts, options, includes=[], excludes=[])
243
- build_common_options(opts, options, [:auto_confirm, :query, :json, :quiet, :dry_run, :remote] + includes, excludes)
248
+ build_common_options(opts, options, includes + [:auto_confirm, :query, :json, :quiet, :dry_run, :remote], excludes)
244
249
  end
245
250
 
246
251
  # list is GET that supports phrase,max,offset,sort,direction
@@ -281,13 +286,24 @@ module Morpheus
281
286
  while (option_key = option_keys.shift) do
282
287
  case option_key.to_sym
283
288
 
284
- when :account
285
- opts.on('-a','--account ACCOUNT', "Account Name or ID") do |val|
289
+ when :tenant, :account
290
+ # todo: let's deprecate this in favor of :tenant --tenant to keep -a reserved for --all perhaps?
291
+ opts.on('--tenant TENANT', String, "Tenant (Account) Name or ID") do |val|
292
+ options[:account] = val
293
+ end
294
+ opts.on('--tenant-id ID', String, "Tenant (Account) ID") do |val|
295
+ options[:account_id] = val
296
+ end
297
+ # todo: let's deprecate this in favor of :tenant --tenant to keep -a reserved for --all perhaps?
298
+ opts.on('-a','--account ACCOUNT', "Alias for --tenant") do |val|
286
299
  options[:account] = val
287
300
  end
288
- opts.on('-A','--account-id ID', "Account ID") do |val|
301
+ opts.on('-A','--account-id ID', "Tenant (Account) ID") do |val|
289
302
  options[:account_id] = val
290
303
  end
304
+ opts.add_hidden_option('--tenant-id') if opts.is_a?(Morpheus::Cli::OptionParser)
305
+ opts.add_hidden_option('-a, --account') if opts.is_a?(Morpheus::Cli::OptionParser)
306
+ opts.add_hidden_option('-A, --account-id') if opts.is_a?(Morpheus::Cli::OptionParser)
291
307
 
292
308
  when :options
293
309
  options[:options] ||= {}
@@ -455,7 +471,7 @@ module Morpheus
455
471
  end
456
472
 
457
473
  # arbitrary query parameters in the format -Q "category=web&phrase=nginx"
458
- # opts.on( '-Q', '--query PARAMS', "Query parameters. PARAMS format is 'phrase=foobar&category=web'" ) do |val|
474
+ # opts.on( '-Q', '--query PARAMS', "Query parameters. PARAMS format is 'foo=bar&category=web'" ) do |val|
459
475
  # options[:query_filters_raw] = val
460
476
  # options[:query_filters] = {}
461
477
  # # todo: smarter parsing
@@ -473,7 +489,7 @@ module Morpheus
473
489
 
474
490
  when :query, :query_filters
475
491
  # arbitrary query parameters in the format -Q "category=web&phrase=nginx"
476
- opts.on( '-Q', '--query PARAMS', "Query parameters. PARAMS format is 'phrase=foobar&category=web'" ) do |val|
492
+ opts.on( '-Q', '--query PARAMS', "Query parameters. PARAMS format is 'foo=bar&category=web'" ) do |val|
477
493
  options[:query_filters_raw] = val
478
494
  options[:query_filters] = {}
479
495
  # todo: smarter parsing
@@ -508,6 +524,12 @@ module Morpheus
508
524
  end
509
525
  end
510
526
 
527
+ when :find_by_name
528
+ opts.on('--find-by-name', "Always treat the identifier argument as a name, never an ID. Useful for specifying names that look like numbers. eg. '1234'" ) do
529
+ options[:find_by_name] = true
530
+ end
531
+ # opts.add_hidden_option('--find-by-name') if opts.is_a?(Morpheus::Cli::OptionParser)
532
+
511
533
  when :remote
512
534
  opts.on( '-r', '--remote REMOTE', "Remote name. The current remote is used by default." ) do |val|
513
535
  options[:remote] = val
@@ -599,9 +621,17 @@ module Morpheus
599
621
  opts.add_hidden_option('json-raw') if opts.is_a?(Morpheus::Cli::OptionParser)
600
622
 
601
623
  when :yaml
602
- opts.on(nil, '--yaml', "YAML Output") do
603
- options[:yaml] = true
604
- options[:format] = :yaml
624
+ # -y for --yes and for --yaml
625
+ if includes.include?(:auto_confirm)
626
+ opts.on(nil, '--yaml', "YAML Output") do
627
+ options[:yaml] = true
628
+ options[:format] = :yaml
629
+ end
630
+ else
631
+ opts.on('-y', '--yaml', "YAML Output") do
632
+ options[:yaml] = true
633
+ options[:format] = :yaml
634
+ end
605
635
  end
606
636
  opts.on(nil, '--yml', "alias for --yaml") do
607
637
  options[:yaml] = true
@@ -779,7 +809,11 @@ module Morpheus
779
809
  end
780
810
  opts.add_hidden_option('--no-debug') if opts.is_a?(Morpheus::Cli::OptionParser)
781
811
 
782
-
812
+ opts.on('--hidden-help', "Print help that includes all the hidden options, like this one." ) do
813
+ puts opts.full_help_message({show_hidden_options:true})
814
+ exit # return 0 maybe?
815
+ end
816
+ opts.add_hidden_option('--hidden-help') if opts.is_a?(Morpheus::Cli::OptionParser)
783
817
  opts.on('-h', '--help', "Print this help" ) do
784
818
  puts opts
785
819
  exit # return 0 maybe?
@@ -804,6 +838,20 @@ module Morpheus
804
838
  self.class.subcommand_aliases
805
839
  end
806
840
 
841
+ # def subcommand_descriptions
842
+ # self.class.subcommand_descriptions
843
+ # end
844
+
845
+ def get_subcommand_description(subcmd)
846
+ self.class.get_subcommand_description(subcmd)
847
+ end
848
+
849
+ def subcommand_description()
850
+ calling_method = caller[0][/`([^']*)'/, 1].to_s.sub('block in ', '')
851
+ subcommand_name = subcommands.key(calling_method)
852
+ subcommand_name ? get_subcommand_description(subcommand_name) : nil
853
+ end
854
+
807
855
  def default_subcommand
808
856
  self.class.default_subcommand
809
857
  end
@@ -845,8 +893,11 @@ module Morpheus
845
893
  if !subcommands.empty?
846
894
  out << "Commands:"
847
895
  out << "\n"
848
- subcommands.sort.each {|cmd, method|
849
- out << "\t#{cmd.to_s}\n"
896
+ subcommands.sort.each {|subcmd, method|
897
+ desc = get_subcommand_description(subcmd)
898
+ out << "\t#{subcmd.to_s}"
899
+ out << "\t#{desc}" if desc
900
+ out << "\n"
850
901
  }
851
902
  end
852
903
  # out << "\n"
@@ -990,7 +1041,7 @@ module Morpheus
990
1041
  # raise_command_error "Please specify a remote appliance with -r or see the command `remote use`"
991
1042
  # end
992
1043
 
993
- Morpheus::Logging::DarkPrinter.puts "establishing connection to remote #{display_appliance(@appliance_name, @appliance_url)}" if Morpheus::Logging.debug?
1044
+ Morpheus::Logging::DarkPrinter.puts "establishing connection to remote #{display_appliance(@appliance_name, @appliance_url)}" if Morpheus::Logging.debug? # && !options[:quiet]
994
1045
 
995
1046
  if options[:no_authorization]
996
1047
  # maybe handle this here..
@@ -1061,7 +1112,7 @@ module Morpheus
1061
1112
  else
1062
1113
  if opts[:min]
1063
1114
  if args.count < opts[:min]
1064
- raise_args_error("not many arguments, expected #{opts[:min] || '0'}-#{opts[:max] || 'N'} and got #{args.count == 0 ? '0' : args.count.to_s + ': '}#{args.join(', ')}", args, opts[:optparse])
1115
+ raise_args_error("not enough arguments, expected #{opts[:min] || '0'}-#{opts[:max] || 'N'} and got #{args.count == 0 ? '0' : args.count.to_s + ': '}#{args.join(', ')}", args, opts[:optparse])
1065
1116
  end
1066
1117
  end
1067
1118
  if opts[:max]
@@ -1152,22 +1203,32 @@ module Morpheus
1152
1203
  payload
1153
1204
  end
1154
1205
 
1155
- def render_response(json_response, options, object_key=nil, &block)
1156
- render_result = render_with_format(json_response, options, object_key)
1157
- if render_result
1158
- return 0, nil
1159
- else
1160
- if block_given?
1161
- return yield
1206
+ def validate_outfile(outfile, options)
1207
+ full_filename = File.expand_path(outfile)
1208
+ outdir = File.dirname(full_filename)
1209
+ if Dir.exists?(full_filename)
1210
+ print_red_alert "[local-file] is invalid. It is the name of an existing directory: #{outfile}"
1211
+ return false
1212
+ end
1213
+ if !Dir.exists?(outdir)
1214
+ if options[:mkdir]
1215
+ print cyan,"Creating local directory #{outdir}",reset,"\n"
1216
+ FileUtils.mkdir_p(outdir)
1162
1217
  else
1163
- return 0, nil
1218
+ print_red_alert "[local-file] is invalid. Directory not found: #{outdir}"
1219
+ return false
1164
1220
  end
1165
1221
  end
1222
+ if File.exists?(full_filename) && !options[:overwrite]
1223
+ print_red_alert "[local-file] is invalid. File already exists: #{outfile}\nUse -f to overwrite the existing file."
1224
+ return false
1225
+ end
1226
+ return true
1166
1227
  end
1167
1228
 
1168
1229
  # basic rendering for options :json, :yml, :csv, :quiet, and :outfile
1169
1230
  # returns the string rendered, or nil if nothing was rendered.
1170
- def render_with_format(json_response, options, object_key=nil, &block)
1231
+ def render_response(json_response, options, object_key=nil, &block)
1171
1232
  output = nil
1172
1233
  if options[:json]
1173
1234
  output = as_json(json_response, options, object_key)
@@ -1180,32 +1241,50 @@ module Morpheus
1180
1241
  else
1181
1242
  output = records_as_csv([row], options)
1182
1243
  end
1183
- elsif options[:quiet]
1184
- # note: returning non nil means the calling function knows to return rght away.. kinda weird..
1185
- # but means we need less if options[:quiet] blocks in every action.
1186
- return ""
1187
1244
  end
1188
- if output
1189
- if options[:outfile]
1245
+ if options[:outfile]
1246
+ full_outfile = File.expand_path(options[:outfile])
1247
+ if output
1190
1248
  print_to_file(output, options[:outfile], options[:overwrite])
1249
+ print "#{cyan}Wrote output to file #{options[:outfile]} (#{File.size(full_outfile)} B)\n" unless options[:quiet]
1191
1250
  else
1192
- puts output
1251
+ # uhhh ok lets try this
1252
+ Morpheus::Logging::DarkPrinter.puts "using experimental feature: --out without a common format like json, yml or csv" if Morpheus::Logging.debug?
1253
+ result = with_stdout_to_file(options[:outfile], options[:overwrite], 'w+', &block)
1254
+ if result && result != 0
1255
+ return result
1256
+ end
1257
+ print "#{cyan}Wrote output to file #{options[:outfile]} (#{File.size(full_outfile)} B)\n" unless options[:quiet]
1258
+ return 0, nil
1193
1259
  end
1194
1260
  else
1195
- if block_given?
1196
- # invoke the user given block to render (print output)
1197
- # hope it returned something well formed, there's a parse method for that..
1198
- cmd_render_result = yield
1199
- # could try to support writing output to options[:outfile] here too..
1200
- # output is already printed inside block though
1201
- # if cmd_render_result
1202
- # return output
1203
- # end
1204
- end
1261
+ # --quiet means do not render, still want to print to outfile though
1262
+ if options[:quiet]
1263
+ return 0, nil
1264
+ end
1265
+ # render ouput generated above
1266
+ if output
1267
+ puts output
1268
+ return 0, nil
1269
+ else
1270
+ # no render happened, so calling the block if given
1271
+ if block_given?
1272
+ result = yield
1273
+ if result
1274
+ return result
1275
+ else
1276
+ return 0, nil
1277
+ end
1278
+ else
1279
+ # nil means nothing was rendered, some methods still using render_with_format() are relying on this
1280
+ return nil
1281
+ end
1282
+ end
1205
1283
  end
1206
- return output
1207
1284
  end
1208
1285
 
1286
+ alias :render_with_format :render_response
1287
+
1209
1288
  module ClassMethods
1210
1289
 
1211
1290
  def set_command_name(cmd_name)
@@ -1277,12 +1356,46 @@ module Morpheus
1277
1356
  v = cmd.to_s.gsub('-', '_')
1278
1357
  register_subcommands({(k) => v})
1279
1358
  else
1280
- raise "Unable to register command of type: #{cmd.class} #{cmd}"
1359
+ raise Morpheus::Cli::CliRegistry::BadCommandDefinition.new("Unable to register command of type: #{cmd.class} #{cmd}")
1281
1360
  end
1282
1361
  }
1283
1362
  return
1284
1363
  end
1285
1364
 
1365
+ # this might be the new hotness
1366
+ # register_subcommand(:show) # do not do this, always define a description!
1367
+ # register_subcommand(:list, "List things")
1368
+ # register_subcommand("update-all", "update_all", "Update all things")
1369
+ # If the command name =~ method, no need to pass both
1370
+ # command names will have "-" swapped in for "_" and vice versa for method names.
1371
+ def register_subcommand(*args)
1372
+ args = args.flatten
1373
+ cmd_name = args[0]
1374
+ cmd_method = nil
1375
+ cmd_desc = nil
1376
+ if args.count == 1
1377
+ cmd_method = cmd_name
1378
+ elsif args.count == 2
1379
+ if args[1].is_a?(Symbol)
1380
+ cmd_method = args[1]
1381
+ else
1382
+ cmd_method = cmd_name
1383
+ cmd_desc = args[1]
1384
+ end
1385
+ elsif args.count == 3
1386
+ cmd_method = args[1]
1387
+ cmd_desc = args[2]
1388
+ else
1389
+ raise Morpheus::Cli::CliRegistry::BadCommandDefinition.new("register_subcommand expects 1-3 arguments, got #{args.size} #{args.inspect}")
1390
+ end
1391
+ cmd_name = cmd_name.to_s.gsub("_", "-").to_sym
1392
+ cmd_method = (cmd_method || cmd_name).to_s.gsub("-", "_").to_sym
1393
+ cmd_definition = {(cmd_name) => cmd_method}
1394
+ register_subcommands(cmd_definition)
1395
+ add_subcommand_description(cmd_name, cmd_desc)
1396
+ return
1397
+ end
1398
+
1286
1399
  def set_default_subcommand(cmd)
1287
1400
  @default_subcommand = cmd
1288
1401
  end
@@ -1341,6 +1454,31 @@ module Morpheus
1341
1454
  @subcommand_aliases.delete(alias_cmd_name.to_s)
1342
1455
  end
1343
1456
 
1457
+ def subcommand_descriptions
1458
+ @subcommand_descriptions ||= {}
1459
+ end
1460
+
1461
+ def add_subcommand_description(cmd_name, description)
1462
+ @subcommand_descriptions ||= {}
1463
+ @subcommand_descriptions[cmd_name.to_s.gsub('_', '-')] = description
1464
+ end
1465
+
1466
+ def get_subcommand_description(cmd_name)
1467
+ desc = subcommand_descriptions[cmd_name.to_s.gsub('_', '-')]
1468
+ if desc
1469
+ return desc
1470
+ else
1471
+ cmd_method = subcommands.key(cmd_name)
1472
+ return cmd_method ? subcommand_descriptions[cmd_method.to_s.gsub('_', '-')] : nil
1473
+ end
1474
+ end
1475
+
1476
+ def set_subcommand_descriptions(cmd_map)
1477
+ cmd_map.each do |cmd_name, description|
1478
+ add_subcommand_description(cmd_name, description)
1479
+ end
1480
+ end
1481
+
1344
1482
  end
1345
1483
  end
1346
1484
  end
@@ -9,6 +9,9 @@ module Morpheus
9
9
  module Cli
10
10
  class CliRegistry
11
11
 
12
+ class BadCommandDefinition < StandardError
13
+ end
14
+
12
15
  class BadAlias < StandardError
13
16
  end
14
17
 
@@ -46,11 +46,15 @@ class Morpheus::Cli::Clouds
46
46
  opts.on( '-t', '--type TYPE', "Cloud Type" ) do |val|
47
47
  options[:zone_type] = val
48
48
  end
49
- build_common_options(opts, options, [:list, :query, :json, :yaml, :csv, :fields, :dry_run, :remote])
49
+ build_standard_list_options(opts, options)
50
50
  opts.footer = "List clouds."
51
51
  end
52
52
  optparse.parse!(args)
53
53
  connect(options)
54
+ # verify_args!(args:args, optparse:optparse, count:0)
55
+ if args.count > 0
56
+ options[:phrase] = args.join(" ")
57
+ end
54
58
  begin
55
59
  if options[:zone_type]
56
60
  cloud_type = cloud_type_for_name(options[:zone_type])
@@ -71,15 +75,7 @@ class Morpheus::Cli::Clouds
71
75
  end
72
76
 
73
77
  json_response = @clouds_interface.list(params)
74
- if options[:json]
75
- puts as_json(json_response, options, "zones")
76
- return 0
77
- elsif options[:yaml]
78
- puts as_yaml(json_response, options, "zones")
79
- return 0
80
- elsif options[:csv]
81
- puts records_as_csv(json_response['zones'], options)
82
- else
78
+ render_response(json_response, options, 'zones') do
83
79
  clouds = json_response['zones']
84
80
  title = "Morpheus Clouds"
85
81
  subtitles = []
@@ -99,6 +95,7 @@ class Morpheus::Cli::Clouds
99
95
  end
100
96
  print reset,"\n"
101
97
  end
98
+ return 0, nil
102
99
  rescue RestClient::Exception => e
103
100
  print_rest_exception(e, options)
104
101
  exit 1
@@ -609,15 +609,6 @@ class Morpheus::Cli::Clusters
609
609
  option_type_list = ((controller_type['optionTypes'].reject { |type| !type['enabled'] || type['fieldComponent'] } rescue []) + layout['optionTypes'] +
610
610
  (cluster_type['optionTypes'].reject { |type| !type['enabled'] || !type['creatable'] || type['fieldComponent'] } rescue [])).sort { |type| type['displayOrder'] }
611
611
 
612
- # remove volume options if volumes were configured
613
- if !server_payload['volumes'].empty?
614
- option_type_list = reject_volume_option_types(option_type_list)
615
- end
616
- # remove networkId option if networks were configured above
617
- if !server_payload['networkInterfaces'].empty?
618
- option_type_list = reject_networking_option_types(option_type_list)
619
- end
620
-
621
612
  server_payload.deep_merge!(Morpheus::Cli::OptionTypes.prompt(option_type_list, options[:options], @api_client, {zoneId: cloud['id'], siteId: group['id'], layoutId: layout['id']}))
622
613
 
623
614
  # Worker count
@@ -1197,15 +1188,6 @@ class Morpheus::Cli::Clusters
1197
1188
  (type['fieldContext'] == 'instance.networkDomain' && type['fieldName'] == 'id')
1198
1189
  } rescue [])
1199
1190
 
1200
- # remove volume options if volumes were configured
1201
- if !server_payload['volumes'].empty?
1202
- option_type_list = reject_volume_option_types(option_type_list)
1203
- end
1204
- # remove networkId option if networks were configured above
1205
- if !server_payload['networkInterfaces'].empty?
1206
- option_type_list = reject_networking_option_types(option_type_list)
1207
- end
1208
-
1209
1191
  server_payload.deep_merge!(Morpheus::Cli::OptionTypes.prompt(option_type_list, options[:options], @api_client, {zoneId: cloud['id'], siteId: group['id'], layoutId: layout['id']}))
1210
1192
 
1211
1193
  # Create User