morpheus-cli 4.1.14 → 4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) 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/library_container_types_interface.rb +1 -1
  5. data/lib/morpheus/api/library_instance_types_interface.rb +7 -7
  6. data/lib/morpheus/api/library_layouts_interface.rb +1 -1
  7. data/lib/morpheus/api/network_routers_interface.rb +101 -0
  8. data/lib/morpheus/api/tasks_interface.rb +12 -14
  9. data/lib/morpheus/cli.rb +1 -0
  10. data/lib/morpheus/cli/apps.rb +15 -12
  11. data/lib/morpheus/cli/cli_command.rb +40 -2
  12. data/lib/morpheus/cli/clusters.rb +13 -7
  13. data/lib/morpheus/cli/cypher_command.rb +5 -2
  14. data/lib/morpheus/cli/hosts.rb +1 -1
  15. data/lib/morpheus/cli/instances.rb +21 -5
  16. data/lib/morpheus/cli/jobs_command.rb +83 -27
  17. data/lib/morpheus/cli/library_cluster_layouts_command.rb +12 -12
  18. data/lib/morpheus/cli/library_container_scripts_command.rb +52 -40
  19. data/lib/morpheus/cli/library_container_types_command.rb +2 -60
  20. data/lib/morpheus/cli/library_instance_types_command.rb +22 -1
  21. data/lib/morpheus/cli/library_layouts_command.rb +65 -65
  22. data/lib/morpheus/cli/library_option_lists_command.rb +72 -59
  23. data/lib/morpheus/cli/library_option_types_command.rb +30 -186
  24. data/lib/morpheus/cli/library_spec_templates_command.rb +39 -64
  25. data/lib/morpheus/cli/mixins/library_helper.rb +213 -0
  26. data/lib/morpheus/cli/mixins/provisioning_helper.rb +89 -37
  27. data/lib/morpheus/cli/mixins/whoami_helper.rb +16 -1
  28. data/lib/morpheus/cli/network_routers_command.rb +1281 -0
  29. data/lib/morpheus/cli/networks_command.rb +164 -72
  30. data/lib/morpheus/cli/option_types.rb +187 -73
  31. data/lib/morpheus/cli/price_sets_command.rb +4 -4
  32. data/lib/morpheus/cli/prices_command.rb +15 -15
  33. data/lib/morpheus/cli/remote.rb +3 -3
  34. data/lib/morpheus/cli/service_plans_command.rb +17 -8
  35. data/lib/morpheus/cli/tasks.rb +437 -169
  36. data/lib/morpheus/cli/version.rb +1 -1
  37. data/lib/morpheus/formatters.rb +8 -0
  38. metadata +6 -3
@@ -31,7 +31,7 @@ class Morpheus::Cli::LibraryOptionTypesCommand
31
31
  options = {}
32
32
  optparse = Morpheus::Cli::OptionParser.new do |opts|
33
33
  opts.banner = subcommand_usage()
34
- build_common_options(opts, options, [:list, :query, :dry_run, :json, :remote])
34
+ build_standard_list_options(opts, options)
35
35
  opts.footer = "List option types."
36
36
  end
37
37
  optparse.parse!(args)
@@ -47,10 +47,8 @@ class Morpheus::Cli::LibraryOptionTypesCommand
47
47
 
48
48
  json_response = @option_types_interface.list(params)
49
49
 
50
- if options[:json]
51
- print JSON.pretty_generate(json_response), "\n"
52
- return
53
- end
50
+ render_result = render_with_format(json_response, options, 'optionTypes')
51
+ return 0 if render_result
54
52
 
55
53
  option_types = json_response['optionTypes']
56
54
  subtitles = []
@@ -94,12 +92,13 @@ class Morpheus::Cli::LibraryOptionTypesCommand
94
92
  options = {}
95
93
  optparse = Morpheus::Cli::OptionParser.new do |opts|
96
94
  opts.banner = subcommand_usage("[name]")
97
- build_common_options(opts, options, [:json, :yaml, :csv, :fields, :dry_run, :remote])
95
+ build_standard_get_options(opts, options)
96
+ opts.footer = "Get details about an option type.\n" +
97
+ "[name] is required. This is the name or id of an option type. Supports 1-N [name] arguments."
98
98
  end
99
99
  optparse.parse!(args)
100
100
  if args.count < 1
101
- puts optparse
102
- return 1
101
+ raise_command_error "wrong number of arguments, expected 1-N and got (#{args.count}) #{args.join(', ')}\n#{optparse}"
103
102
  end
104
103
  connect(options)
105
104
  id_list = parse_id_list(args)
@@ -122,16 +121,9 @@ class Morpheus::Cli::LibraryOptionTypesCommand
122
121
  option_type = find_option_type_by_name_or_id(id)
123
122
  return 1 if option_type.nil?
124
123
  json_response = {'optionType' => option_type}
125
- if options[:json]
126
- puts as_json(json_response, options, "optionType")
127
- return 0
128
- elsif options[:yaml]
129
- puts as_yaml(json_response, options, "optionType")
130
- return 0
131
- elsif options[:csv]
132
- puts records_as_csv([json_response['optionType']], options)
133
- return 0
134
- end
124
+
125
+ render_result = render_with_format(json_response, options, 'optionType')
126
+ return 0 if render_result
135
127
 
136
128
  print_h1 "Option Type Details"
137
129
  print cyan
@@ -145,24 +137,24 @@ class Morpheus::Cli::LibraryOptionTypesCommand
145
137
  "Full Field Name" => lambda {|it| [it['fieldContext'], it['fieldName']].select {|it| !it.to_s.empty? }.join('.') },
146
138
  "Type" => lambda {|it| it['type'].to_s.capitalize },
147
139
  "Placeholder" => 'placeHolder',
148
- "Default Value" => 'defaultValue'
140
+ "Default Value" => 'defaultValue',
141
+ "Required" => lambda {|it| format_boolean(it['required']) },
149
142
  }, option_type)
150
143
  print reset,"\n"
151
-
144
+ return 0
152
145
  rescue RestClient::Exception => e
153
146
  print_rest_exception(e, options)
154
- exit 1
147
+ return 1
155
148
  end
156
149
  end
157
150
 
158
151
  def add(args)
159
- # JD: this is annoying because our option_types (for prompting and help)
160
- # are the same type of object being managed here.., options options options
161
152
  options = {}
162
153
  optparse = Morpheus::Cli::OptionParser.new do |opts|
163
154
  opts.banner = subcommand_usage("[options]")
164
155
  build_option_type_options(opts, options, new_option_type_option_types)
165
- build_common_options(opts, options, [:options, :payload, :json, :dry_run, :remote])
156
+ build_standard_add_options(opts, options)
157
+ opts.footer = "Create a new option type."
166
158
  end
167
159
  optparse.parse!(args)
168
160
  connect(options)
@@ -189,10 +181,8 @@ class Morpheus::Cli::LibraryOptionTypesCommand
189
181
  return
190
182
  end
191
183
  json_response = @option_types_interface.create(payload)
192
- if options[:json]
193
- print JSON.pretty_generate(json_response), "\n"
194
- return
195
- end
184
+ render_result = render_with_format(json_response, options)
185
+ return 0 if render_result
196
186
  option_type = json_response['optionType']
197
187
  print_green_success "Added Option Type #{option_type['name']}"
198
188
  #list([])
@@ -204,13 +194,13 @@ class Morpheus::Cli::LibraryOptionTypesCommand
204
194
  end
205
195
 
206
196
  def update(args)
207
- # JD: this is annoying because our option_types (for prompting and help)
208
- # are the same type of object being managed here.., options options options
209
197
  options = {}
210
198
  optparse = Morpheus::Cli::OptionParser.new do |opts|
211
199
  opts.banner = subcommand_usage("[name] [options]")
212
200
  build_option_type_options(opts, options, update_option_type_option_types)
213
- build_common_options(opts, options, [:options, :payload, :json, :dry_run, :remote])
201
+ build_standard_update_options(opts, options)
202
+ opts.footer = "Update an option type.\n" +
203
+ "[name] is required. This is the name or id of an option type."
214
204
  end
215
205
  optparse.parse!(args)
216
206
  connect(options)
@@ -245,16 +235,14 @@ class Morpheus::Cli::LibraryOptionTypesCommand
245
235
  return
246
236
  end
247
237
  json_response = @option_types_interface.update(option_type['id'], payload)
248
- if options[:json]
249
- print JSON.pretty_generate(json_response), "\n"
250
- return
251
- end
238
+ render_result = render_with_format(json_response, options)
239
+ return 0 if render_result
252
240
  print_green_success "Updated Option Type #{option_type_payload['name']}"
253
241
  #list([])
254
242
  get([option_type['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
255
243
  rescue RestClient::Exception => e
256
244
  print_rest_exception(e, options)
257
- exit 1
245
+ return 1
258
246
  end
259
247
  end
260
248
 
@@ -262,7 +250,9 @@ class Morpheus::Cli::LibraryOptionTypesCommand
262
250
  options = {}
263
251
  optparse = Morpheus::Cli::OptionParser.new do |opts|
264
252
  opts.banner = subcommand_usage("[name]")
265
- build_common_options(opts, options, [:auto_confirm, :json, :dry_run, :remote])
253
+ build_standard_remove_options(opts, options)
254
+ opts.footer = "Delete an option type.\n" +
255
+ "[name] is required. This is the name or id of an option type."
266
256
  end
267
257
  optparse.parse!(args)
268
258
  if args.count < 1
@@ -285,10 +275,8 @@ class Morpheus::Cli::LibraryOptionTypesCommand
285
275
  end
286
276
  json_response = @option_types_interface.destroy(option_type['id'])
287
277
 
288
- if options[:json]
289
- print JSON.pretty_generate(json_response), "\n"
290
- return
291
- end
278
+ render_result = render_with_format(json_response, options)
279
+ return 0 if render_result
292
280
 
293
281
  print_green_success "Removed Option Type #{option_type['name']}"
294
282
  #list([])
@@ -397,73 +385,7 @@ class Morpheus::Cli::LibraryOptionTypesCommand
397
385
  ]
398
386
  end
399
387
 
400
- # Prompts user for exposed ports array
401
- # returns array of port objects
402
- def prompt_exposed_ports(options={}, api_client=nil, api_params={})
403
- #puts "Configure ports:"
404
- no_prompt = (options[:no_prompt] || (options[:options] && options[:options][:no_prompt]))
405
-
406
- ports = []
407
- port_index = 0
408
- has_another_port = options[:options] && options[:options]["exposedPort#{port_index}"]
409
- add_another_port = has_another_port || (!no_prompt && Morpheus::Cli::OptionTypes.confirm("Add an exposed port?"))
410
- while add_another_port do
411
- field_context = "exposedPort#{port_index}"
412
-
413
- port = {}
414
- #port['name'] ||= "Port #{port_index}"
415
- port_label = port_index == 0 ? "Port" : "Port [#{port_index+1}]"
416
- v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldContext' => field_context, 'fieldName' => 'name', 'type' => 'text', 'fieldLabel' => "#{port_label} Name", 'required' => false, 'description' => 'Choose a name for this port.', 'defaultValue' => port['name']}], options[:options])
417
- port['name'] = v_prompt[field_context]['name']
418
-
419
- v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldContext' => field_context, 'fieldName' => 'port', 'type' => 'number', 'fieldLabel' => "#{port_label} Number", 'required' => true, 'description' => 'A port number. eg. 8001', 'defaultValue' => (port['port'] ? port['port'].to_i : nil)}], options[:options])
420
- port['port'] = v_prompt[field_context]['port']
421
-
422
- v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldContext' => field_context, 'fieldName' => 'loadBalanceProtocol', 'type' => 'select', 'fieldLabel' => "#{port_label} LB", 'selectOptions' => load_balance_protocols, 'required' => false, 'skipSingleOption' => true, 'description' => 'Choose a load balance protocol.', 'defaultValue' => port['loadBalanceProtocol']}], options[:options])
423
- port['loadBalanceProtocol'] = v_prompt[field_context]['loadBalanceProtocol']
424
-
425
- ports << port
426
- port_index += 1
427
- has_another_port = options[:options] && options[:options]["exposedPort#{port_index}"]
428
- add_another_port = has_another_port || (!no_prompt && Morpheus::Cli::OptionTypes.confirm("Add another exposed port?"))
429
-
430
- end
431
-
432
-
433
- return ports
434
- end
435
-
436
- def find_option_type_by_name_or_id(val)
437
- if val.to_s =~ /\A\d{1,}\Z/
438
- return find_option_type_by_id(val)
439
- else
440
- return find_option_type_by_name(val)
441
- end
442
- end
443
-
444
- def find_option_type_by_id(id)
445
- begin
446
- json_response = @option_types_interface.get(id.to_i)
447
- return json_response['optionType']
448
- rescue RestClient::Exception => e
449
- if e.response && e.response.code == 404
450
- print_red_alert "Option Type not found by id #{id}"
451
- exit 1
452
- else
453
- raise e
454
- end
455
- end
456
- end
457
-
458
- def find_option_type_by_name(name)
459
- json_results = @option_types_interface.list({name: name.to_s})
460
- if json_results['optionTypes'].empty?
461
- print_red_alert "Option Type not found by name #{name}"
462
- exit 1
463
- end
464
- option_type = json_results['optionTypes'][0]
465
- return option_type
466
- end
388
+ # finders are in LibraryHelper
467
389
 
468
390
  # lol
469
391
  def new_option_type_option_types
@@ -489,82 +411,4 @@ class Morpheus::Cli::LibraryOptionTypesCommand
489
411
  list
490
412
  end
491
413
 
492
- # def find_option_type_list_by_name_or_id(val)
493
- # if val.to_s =~ /\A\d{1,}\Z/
494
- # return find_option_type_list_by_id(val)
495
- # else
496
- # return find_option_type_list_by_name(val)
497
- # end
498
- # end
499
-
500
- # def find_option_type_list_by_id(id)
501
- # begin
502
- # json_response = @option_type_lists_interface.get(id.to_i)
503
- # return json_response['optionTypeList']
504
- # rescue RestClient::Exception => e
505
- # if e.response && e.response.code == 404
506
- # print_red_alert "Option List not found by id #{id}"
507
- # exit 1
508
- # else
509
- # raise e
510
- # end
511
- # end
512
- # end
513
-
514
- # def find_option_type_list_by_name(name)
515
- # json_results = @option_type_lists_interface.list({name: name.to_s})
516
- # if json_results['optionTypeLists'].empty?
517
- # print_red_alert "Option List not found by name #{name}"
518
- # exit 1
519
- # end
520
- # option_type_list = json_results['optionTypeLists'][0]
521
- # return option_type_list
522
- # end
523
-
524
- # def get_available_option_list_types
525
- # [
526
- # {'name' => 'Rest', 'value' => 'rest'},
527
- # {'name' => 'Manual', 'value' => 'manual'}
528
- # ]
529
- # end
530
-
531
- # def find_option_list_type(code)
532
- # get_available_option_list_types.find {|it| code == it['value'] || code == it['name'] }
533
- # end
534
-
535
- # def new_option_type_list_option_types(list_type='rest')
536
- # if list_type.to_s.downcase == 'rest'
537
- # [
538
- # {'fieldName' => 'name', 'fieldLabel' => 'Name', 'type' => 'text', 'required' => true, 'displayOrder' => 1},
539
- # {'fieldName' => 'description', 'fieldLabel' => 'Description', 'type' => 'text', 'displayOrder' => 2},
540
- # #{'fieldName' => 'type', 'fieldLabel' => 'Type', 'type' => 'select', 'selectOptions' => get_available_option_list_types, 'defaultValue' => 'rest', 'required' => true, 'displayOrder' => 3},
541
- # {'fieldName' => 'sourceUrl', 'fieldLabel' => 'Source Url', 'type' => 'text', 'required' => true, 'description' => "A REST URL can be used to fetch list data and is cached in the appliance database.", 'displayOrder' => 4},
542
- # {'fieldName' => 'ignoreSSLErrors', 'fieldLabel' => 'Ignore SSL Errors', 'type' => 'checkbox', 'defaultValue' => 'off', 'displayOrder' => 5},
543
- # {'fieldName' => 'sourceMethod', 'fieldLabel' => 'Source Method', 'type' => 'select', 'selectOptions' => [{'name' => 'GET', 'value' => 'GET'}, {'name' => 'POST', 'value' => 'POST'}], 'defaultValue' => 'GET', 'required' => true, 'displayOrder' => 6},
544
- # {'fieldName' => 'initialDataset', 'fieldLabel' => 'Initial Dataset', 'type' => 'code-editor', 'description' => "Create an initial json dataset to be used as the collection for this option list. It should be a list containing objects with properties 'name', and 'value'. However, if there is a translation script, that will also be passed through.", 'displayOrder' => 7},
545
- # {'fieldName' => 'translationScript', 'fieldLabel' => 'Translation Script', 'type' => 'code-editor', 'description' => "Create a js script to translate the result data object into an Array containing objects with properties name, and value. The input data is provided as data and the result should be put on the global variable results.", 'displayOrder' => 8},
546
- # ]
547
- # elsif list_type.to_s.downcase == 'manual'
548
- # [
549
- # {'fieldName' => 'name', 'fieldLabel' => 'Name', 'type' => 'text', 'required' => true, 'displayOrder' => 1},
550
- # {'fieldName' => 'description', 'fieldLabel' => 'Description', 'type' => 'text', 'displayOrder' => 2},
551
- # #{'fieldName' => 'type', 'fieldLabel' => 'Type', 'type' => 'select', 'selectOptions' => [{'name' => 'Rest', 'value' => 'rest'}, {'name' => 'Manual', 'value' => 'manual'}], 'defaultValue' => 'rest', 'required' => true, 'displayOrder' => 3},
552
- # {'fieldName' => 'initialDataset', 'fieldLabel' => 'Dataset', 'type' => 'code-editor', 'required' => true, 'description' => "Create an initial JSON or CSV dataset to be used as the collection for this option list. It should be a list containing objects with properties 'name', and 'value'.", 'displayOrder' => 4},
553
- # ]
554
- # else
555
- # print_red_alert "Unknown Option List type '#{list_type}'"
556
- # exit 1
557
- # end
558
- # end
559
-
560
- # def update_option_type_list_option_types(list_type='rest')
561
- # list = new_option_type_list_option_types(list_type)
562
- # list.each {|it|
563
- # it.delete('required')
564
- # it.delete('defaultValue')
565
- # it.delete('skipSingleOption')
566
- # }
567
- # list
568
- # end
569
-
570
414
  end
@@ -180,24 +180,23 @@ class Morpheus::Cli::LibrarySpecTemplatesCommand
180
180
  params = {}
181
181
  file_params = {}
182
182
  template_type = nil
183
- source_type = nil
184
183
  optparse = Morpheus::Cli::OptionParser.new do |opts|
185
184
  opts.banner = subcommand_usage("[name]")
186
185
  opts.on('--name VALUE', String, "Name") do |val|
187
186
  params['name'] = val
188
187
  end
189
- opts.on('-t', '--type TYPE', "Spec Template Type. kubernetes, helm, terraform, cloudFormation") do |val|
188
+ opts.on('-t', '--type TYPE', "Spec Template Type. i.e. arm, cloudFormation, helm, kubernetes, oneview, terraform, ucs") do |val|
190
189
  template_type = val.to_s
191
190
  end
192
191
  opts.on('--source VALUE', String, "Source Type. local, repository, url") do |val|
193
- source_type = val.to_s
192
+ file_params['sourceType'] = val
194
193
  end
195
194
  opts.on('--content TEXT', String, "Contents of the template. This implies source is local.") do |val|
196
- source_type = 'local' if source_type.nil?
195
+ file_params['sourceType'] = 'local' if file_params['sourceType'].nil?
197
196
  file_params['content'] = val
198
197
  end
199
198
  opts.on('--file FILE', "File containing the template. This can be used instead of --content" ) do |filename|
200
- source_type = 'local' if source_type.nil?
199
+ file_params['sourceType'] = 'local' if file_params['sourceType'].nil?
201
200
  full_filename = File.expand_path(filename)
202
201
  if File.exists?(full_filename)
203
202
  file_params['content'] = File.read(full_filename)
@@ -263,33 +262,38 @@ class Morpheus::Cli::LibrarySpecTemplatesCommand
263
262
  template_type = template_type_obj['code']
264
263
  params['type'] = {'code' => template_type}
265
264
  end
266
- # source
267
- if source_type.nil?
268
- source_type = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'source', 'fieldLabel' => 'Source', 'type' => 'select', 'optionSource' => 'fileContentSource', 'required' => true, 'defaultValue' => 'local'}], options[:options], @api_client,{})['source']
269
- file_params['sourceType'] = source_type
270
- end
271
- # source type options
272
- if source_type == "local"
273
- # prompt for content
274
- if file_params['content'].nil?
275
- file_params['content'] = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'content', 'type' => 'code-editor', 'fieldLabel' => 'Content', 'required' => true, 'description' => 'The file content'}], options[:options])['content']
276
- end
277
- elsif source_type == "url"
278
- if file_params['contentPath'].nil?
279
- file_params['contentPath'] = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'url', 'fieldLabel' => 'URL', 'type' => 'text', 'required' => true}], options[:options], @api_client,{})['url']
280
- end
281
- elsif source_type == "repository"
282
- if file_params['repository'].nil?
283
- repository_id = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'repositoryId', 'fieldLabel' => 'Repository', 'type' => 'select', 'optionSource' => 'codeRepositories', 'required' => true}], options[:options], @api_client,{})['repositoryId']
284
- file_params['repository'] = {'id' => repository_id}
285
- end
286
- if file_params['contentPath'].nil?
287
- file_params['contentPath'] = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'path', 'fieldLabel' => 'File Path', 'type' => 'text', 'required' => true}], options[:options], @api_client,{})['path']
288
- end
289
- if file_params['contentRef'].nil?
290
- file_params['contentRef'] = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'ref', 'fieldLabel' => 'Version Ref', 'type' => 'text'}], options[:options], @api_client,{})['ref']
291
- end
292
- end
265
+
266
+ # file content
267
+ options[:options]['file'] ||= {}
268
+ options[:options]['file'].merge!(file_params)
269
+ file_params = Morpheus::Cli::OptionTypes.file_content_prompt({'fieldName' => 'file', 'fieldLabel' => 'File Content', 'type' => 'file-content', 'required' => true}, options[:options], @api_client, {})
270
+
271
+ # if source_type.nil?
272
+ # source_type = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'source', 'fieldLabel' => 'Source', 'type' => 'select', 'optionSource' => 'fileContentSource', 'required' => true, 'defaultValue' => 'local'}], options[:options], @api_client,{})['source']
273
+ # file_params['sourceType'] = source_type
274
+ # end
275
+ # # source type options
276
+ # if source_type == "local"
277
+ # # prompt for content
278
+ # if file_params['content'].nil?
279
+ # file_params['content'] = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'content', 'type' => 'code-editor', 'fieldLabel' => 'Content', 'required' => true, 'description' => 'The file content'}], options[:options])['content']
280
+ # end
281
+ # elsif source_type == "url"
282
+ # if file_params['contentPath'].nil?
283
+ # file_params['contentPath'] = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'url', 'fieldLabel' => 'URL', 'type' => 'text', 'required' => true}], options[:options], @api_client,{})['url']
284
+ # end
285
+ # elsif source_type == "repository"
286
+ # if file_params['repository'].nil?
287
+ # repository_id = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'repositoryId', 'fieldLabel' => 'Repository', 'type' => 'select', 'optionSource' => 'codeRepositories', 'required' => true}], options[:options], @api_client,{})['repositoryId']
288
+ # file_params['repository'] = {'id' => repository_id}
289
+ # end
290
+ # if file_params['contentPath'].nil?
291
+ # file_params['contentPath'] = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'path', 'fieldLabel' => 'File Path', 'type' => 'text', 'required' => true}], options[:options], @api_client,{})['path']
292
+ # end
293
+ # if file_params['contentRef'].nil?
294
+ # file_params['contentRef'] = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'ref', 'fieldLabel' => 'Version Ref', 'type' => 'text'}], options[:options], @api_client,{})['ref']
295
+ # end
296
+ # end
293
297
  # config
294
298
  if template_type.to_s.downcase == "cloudformation"
295
299
  # JD: the field names the UI uses are inconsistent, should fix in api...
@@ -329,7 +333,6 @@ class Morpheus::Cli::LibrarySpecTemplatesCommand
329
333
  params = {}
330
334
  file_params = {}
331
335
  template_type = nil
332
- source_type = nil
333
336
  optparse = Morpheus::Cli::OptionParser.new do |opts|
334
337
  opts.banner = subcommand_usage("[name]")
335
338
  opts.on('--name VALUE', String, "Name") do |val|
@@ -339,14 +342,14 @@ class Morpheus::Cli::LibrarySpecTemplatesCommand
339
342
  template_type = val.to_s
340
343
  end
341
344
  opts.on('--source VALUE', String, "Source Type. local, repository, url") do |val|
342
- source_type = val.to_s
345
+ file_params['sourceType'] = val
343
346
  end
344
347
  opts.on('--content TEXT', String, "Contents of the template. This implies source is local.") do |val|
345
- source_type = 'local' if source_type.nil?
348
+ # file_params['sourceType'] = 'local' if file_params['sourceType'].nil?
346
349
  file_params['content'] = val
347
350
  end
348
351
  opts.on('--file FILE', "File containing the template. This can be used instead of --content" ) do |filename|
349
- source_type = 'local' if source_type.nil?
352
+ file_params['sourceType'] = 'local' if file_params['sourceType'].nil?
350
353
  full_filename = File.expand_path(filename)
351
354
  if File.exists?(full_filename)
352
355
  file_params['content'] = File.read(full_filename)
@@ -400,34 +403,6 @@ class Morpheus::Cli::LibrarySpecTemplatesCommand
400
403
  template_type = template_type_obj['code']
401
404
  params['type'] = {'code' => template_type}
402
405
  end
403
- if !source_type.nil?
404
- file_params['sourceType'] = source_type
405
- end
406
- # if source_type == "local"
407
- # # prompt for content
408
- # if file_params['content'].nil?
409
- # file_params['content'] = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'content', 'type' => 'code-editor', 'fieldLabel' => 'Content', 'required' => true, 'description' => 'The file content'}], options[:options])['content']
410
- # end
411
- # elsif source_type == "url"
412
- # if file_params['contentPath'].nil?
413
- # file_params['contentPath'] = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'url', 'fieldLabel' => 'URL', 'type' => 'text', 'required' => true}], options[:options], @api_client,{})['url']
414
- # end
415
- # elsif source_type == "repository"
416
- # if file_params['repository'].nil?
417
- # repository_id = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'repositoryId', 'fieldLabel' => 'Repository', 'type' => 'select', 'optionSource' => 'codeRepositories', 'required' => true, 'defaultValue' => 'local'}], options[:options], @api_client,{})['repositoryId']
418
- # file_params['repository'] = {'id' => repository_id}
419
- # end
420
- # end
421
- # if template_type == "cloudFormation" # this right code?
422
- # # JD: the field names the UI uses are strange, we should make these consistent...
423
- # cloud_formation_option_types = [
424
- # {'fieldContext' => 'config', 'fieldName' => 'cloudformation.IAM', 'fieldLabel' => 'CAPABILITY_IAM', 'type' => 'checkbox'},
425
- # {'fieldContext' => 'config', 'fieldName' => 'cloudformation.CAPABILITY_NAMED_IAM', 'fieldLabel' => 'CAPABILITY_NAMED_IAM', 'type' => 'checkbox'},
426
- # {'fieldContext' => 'config', 'fieldName' => 'cloudformation.CAPABILITY_AUTO_EXPAND', 'fieldLabel' => 'CAPABILITY_AUTO_EXPAND', 'type' => 'checkbox'}
427
- # ]
428
- # v_prompt = Morpheus::Cli::OptionTypes.prompt(cloud_formation_option_types, options[:options], @api_client,{})
429
- # params.deep_merge!(v_prompt)
430
- # end
431
406
  if !file_params.empty?
432
407
  params['file'] = file_params
433
408
  end