morpheus-cli 6.3.0 → 6.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 02effa7bdd51120b68b2253e21f9be4df3a3388424975e21ec4add33a6ad516e
4
- data.tar.gz: 55ce2d5a93cce0ac5aa77ed3d993af5daa41fd3473bddeae773e6d18ac324442
3
+ metadata.gz: '0190e52b071314ef69df636c03de5f81f01dabe1e8314ea96d52d6877b95f0b2'
4
+ data.tar.gz: '098aaf12c061b7bd684956750d14c5f6093e3b8a6dd66d558d510834af6ebcd0'
5
5
  SHA512:
6
- metadata.gz: c8a17ab56472e03157c1e9d2fd2cbaf36dd98dbc4c0d06270b84dfd8b0064d93f2259206a0f6623dc2a51995cd0888ba7ea3785cbcf43936fe7998f4f54577b7
7
- data.tar.gz: 3086104a09b6739bab99d963937dec66d8f1de208270aae3a7bb23374c3c848e1636e6bd7086f37dee0e259f6dc718e57b7a15213b615d37a985805fcc620f43
6
+ metadata.gz: '0853e9c37a2ac7f3b96d4b581c223ed0f729eaf299698415dfa821199b83269afb92fe55ee081b7d78c2bc8cea40ea98852172d6c56a4fce85bea4ac8af18e8b'
7
+ data.tar.gz: a5bf1ce5b619a150debf9b6558bc758208e1bd31c30fbfdbe3d3fc8d9bc1ea752294b49462e9f42dacf7e4c8a14fe9f4d191b565662fd1334a586b348a5b60e5
data/Dockerfile CHANGED
@@ -1,5 +1,5 @@
1
1
  FROM ruby:2.7.5
2
2
 
3
- RUN gem install morpheus-cli -v 6.3.0
3
+ RUN gem install morpheus-cli -v 6.3.2
4
4
 
5
5
  ENTRYPOINT ["morpheus"]
data/README.md CHANGED
@@ -54,12 +54,6 @@ New CLI commands get added under the library directory: `lib/morpheus/cli/comman
54
54
 
55
55
  While developing, you can quickly reload your code changes in a morpheus shell while developing:
56
56
 
57
- ```shell
58
- morpheus shell
59
- ```
60
-
61
- or
62
-
63
57
  ```shell
64
58
  bundle exec morpheus shell —debug
65
59
  ```
@@ -72,6 +66,9 @@ reload
72
66
 
73
67
  Don't forget to add unit tests for your new commands under the directory: `test/`.
74
68
 
69
+
70
+
71
+
75
72
  ## Testing
76
73
 
77
74
  To run the CLI unit tests, first create a `test_config.yaml` and then run `rake test`.
@@ -600,6 +600,10 @@ class Morpheus::APIClient
600
600
  Morpheus::OptionTypeListsInterface.new(common_interface_options).setopts(@options)
601
601
  end
602
602
 
603
+ def option_type_forms
604
+ Morpheus::OptionTypeFormsInterface.new(common_interface_options).setopts(@options)
605
+ end
606
+
603
607
  def scale_thresholds
604
608
  Morpheus::ScaleThresholdsInterface.new(common_interface_options).setopts(@options)
605
609
  end
@@ -766,6 +770,10 @@ class Morpheus::APIClient
766
770
  Morpheus::LibraryClusterLayoutsInterface.new(common_interface_options).setopts(@options)
767
771
  end
768
772
 
773
+ def library_cluster_packages
774
+ Morpheus::LibraryClusterPackagesInterface.new(common_interface_options).setopts(@options)
775
+ end
776
+
769
777
  def library_spec_templates
770
778
  Morpheus::LibrarySpecTemplatesInterface.new(common_interface_options).setopts(@options)
771
779
  end
@@ -0,0 +1,60 @@
1
+ require 'morpheus/api/api_client'
2
+
3
+ class Morpheus::LibraryClusterPackagesInterface < Morpheus::APIClient
4
+
5
+ def list(params={})
6
+ url = "#{@base_url}/api/library/cluster-packages"
7
+ params['sort'] = 'name'
8
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
9
+ opts = {method: :get, url: url, headers: headers}
10
+ execute(opts)
11
+ end
12
+
13
+ def get(id, params={})
14
+ raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
15
+ url = "#{@base_url}/api/library/cluster-packages/#{id}"
16
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
17
+ opts = {method: :get, url: url, headers: headers}
18
+ execute(opts)
19
+ end
20
+
21
+ def create(payload)
22
+ url = "#{@base_url}/api/library/cluster-packages"
23
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
24
+ opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
25
+ execute(opts)
26
+ end
27
+
28
+ def update(id, payload)
29
+ url = "#{@base_url}/api/library/cluster-packages/#{id}"
30
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
31
+ opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
32
+ execute(opts)
33
+ end
34
+
35
+ def destroy(id, payload={})
36
+ url = "#{@base_url}/api/library/cluster-packages/#{id}"
37
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
38
+ opts = {method: :delete, url: url, headers: headers, payload: payload.to_json}
39
+ execute(opts)
40
+ end
41
+
42
+ def update_logo(id, logo_file, dark_logo_file=nil)
43
+ url = "#{@base_url}/api/library/cluster-packages/#{id}"
44
+ headers = { :params => {}, :authorization => "Bearer #{@access_token}"}
45
+ payload = {}
46
+ payload["clusterPackage"] = {}
47
+ if logo_file
48
+ payload["clusterPackage"]["logo"] = logo_file
49
+ end
50
+ if dark_logo_file
51
+ payload["clusterPackage"]["darkLogo"] = dark_logo_file
52
+ end
53
+ if logo_file.is_a?(File) || dark_logo_file.is_a?(File)
54
+ payload[:multipart] = true
55
+ else
56
+ headers['Content-Type'] = 'application/x-www-form-urlencoded'
57
+ end
58
+ execute(method: :put, url: url, headers: headers, payload: payload)
59
+ end
60
+ end
@@ -0,0 +1,9 @@
1
+ require 'morpheus/api/rest_interface'
2
+
3
+ class Morpheus::OptionTypeFormsInterface < Morpheus::RestInterface
4
+
5
+ def base_path
6
+ "/api/library/option-type-forms"
7
+ end
8
+
9
+ end
@@ -268,7 +268,6 @@ module Morpheus
268
268
  build_standard_post_options(opts, options, includes, excludes)
269
269
  end
270
270
 
271
- # todo: this can go away once every command is using execute_api()
272
271
  def build_standard_add_many_options(opts, options, includes=[], excludes=[])
273
272
  build_standard_post_options(opts, options, includes + [:payloads], excludes)
274
273
  end
@@ -1579,6 +1578,9 @@ module Morpheus
1579
1578
  # could use parse_passed_options() here to support exclusion of certain options
1580
1579
  #passed_options = parse_passed_options(options, options[:apply_options] || {})
1581
1580
  passed_options = options[:options].reject {|k,v| k.is_a?(Symbol)}
1581
+ if options[:apply_options_exclude]
1582
+ passed_options = options[:options].reject {|k,v| options[:skip_apply_options].include?(k.to_s) || options[:skip_apply_options].include?(k.to_sym) }
1583
+ end
1582
1584
  if object_key
1583
1585
  payload.deep_merge!({object_key => passed_options})
1584
1586
  else
@@ -95,12 +95,10 @@ module Morpheus
95
95
  suggestions = find_command_suggestions(command_name)
96
96
  if suggestions && suggestions.size == 1
97
97
  msg += "\nThe most similar command is:\n"
98
- suggestions.first(5).each do |suggestion|
99
- msg += "\t" + suggestion + "\n"
100
- end
98
+ msg += "\t" + suggestions.first + "\n"
101
99
  elsif suggestions && suggestions.size > 1
102
100
  msg += "\nThe most similar commands are:\n"
103
- suggestions.first(5).each do |suggestion|
101
+ suggestions.first(50).each do |suggestion|
104
102
  msg += "\t" + suggestion + "\n"
105
103
  end
106
104
  end
@@ -283,7 +283,7 @@ EOT
283
283
  return 1 if backup.nil?
284
284
  parse_options(options, params)
285
285
  confirm!("Are you sure you want to delete the backup #{backup['name']}?", options)
286
- execute_api(@backups_interface, :destroy, [backup['id']], options, 'backup') do |json_response|
286
+ execute_api(@backups_interface, :destroy, [backup['id']], options) do |json_response|
287
287
  print_green_success "Removed backup #{backup['name']}"
288
288
  end
289
289
  end
@@ -1,16 +1,15 @@
1
1
  require 'morpheus/cli/cli_command'
2
2
 
3
- # CLI command self service
4
- # UI is Tools: Self Service - Catalog
5
- # API is /catalog-item-types and returns catalogItemTypes
3
+ # CLI command Catalog Item Types
4
+ # UI is Library > Blueprints > Catalog Items
5
+ # API is /api/catalog-item-types and returns catalogItemTypes
6
6
  class Morpheus::Cli::CatalogItemTypesCommand
7
7
  include Morpheus::Cli::CliCommand
8
8
  include Morpheus::Cli::LibraryHelper
9
9
  include Morpheus::Cli::OptionSourceHelper
10
10
 
11
- # set_command_name :'catalog-types'
12
- set_command_name :'self-service'
13
- set_command_description "Self Service: View and manage catalog item types"
11
+ set_command_name :'catalog-item-types'
12
+ set_command_description "View and manage catalog item types"
14
13
 
15
14
  register_subcommands :list, :get, :add, :update, :remove
16
15
  register_subcommands({:'update-logo' => :update_logo, :'update-dark-logo' => :update_dark_logo})
@@ -152,13 +151,28 @@ EOT
152
151
  print_h1 "Catalog Item Type Details", [], options
153
152
  print cyan
154
153
  show_columns = catalog_item_type_column_definitions
154
+ show_columns.delete("Form") unless catalog_item_type['form']
155
155
  show_columns.delete("Blueprint") unless catalog_item_type['blueprint']
156
156
  show_columns.delete("Workflow") unless catalog_item_type['workflow']
157
157
  show_columns.delete("Context") unless catalog_item_type['context'] # workflow context
158
158
  print_description_list(show_columns, catalog_item_type)
159
159
 
160
+ option_type_form = catalog_item_type['form']
161
+ if option_type_form
162
+ print_h2 "Form Inputs"
163
+ form_inputs = (option_type_form['options'] || [])
164
+ if option_type_form['fieldGroups']
165
+ option_type_form['fieldGroups'].each { |field_group| form_inputs += (field_group['options'] || []) }
166
+ end
167
+ # print format_simple_option_types_table(form_inputs, options)
168
+ print format_option_types_table(form_inputs, options, 'config.customOptions')
169
+ print reset,"\n"
170
+ else
171
+ # print cyan,"No form inputs found for this catalog item.","\n",reset
172
+ end
173
+
160
174
  if catalog_item_type['optionTypes'] && catalog_item_type['optionTypes'].size > 0
161
- print_h2 "Option Types"
175
+ print_h2 "Inputs"
162
176
  opt_columns = [
163
177
  {"ID" => lambda {|it| it['id'] } },
164
178
  {"NAME" => lambda {|it| it['name'] } },
@@ -313,7 +327,13 @@ EOT
313
327
  options[:options]['config'] = params['config'] # or file_content
314
328
  end
315
329
  end
316
- opts.on('--option-types [x,y,z]', Array, "List of Option Type IDs") do |list|
330
+ opts.on('--form-type form|optionTypes', String, "Form Type determines if input comes from a Form or list of Option Types") do |val|
331
+ params['formType'] = val
332
+ end
333
+ opts.on('--form FORM', String, "Form Name or ID") do |val|
334
+ params['form'] = val
335
+ end
336
+ opts.on('--option-types [x,y,z]', Array, "List of Option Type IDs") do |val|
317
337
  if list.nil?
318
338
  params['optionTypes'] = []
319
339
  else
@@ -379,11 +399,24 @@ EOT
379
399
  # massage association params a bit
380
400
  params['workflow'] = {'id' => params['workflow']} if params['workflow'] && !params['workflow'].is_a?(Hash)
381
401
  params['blueprint'] = {'id' => params['blueprint']} if params['blueprint'] && !params['blueprint'].is_a?(Hash)
382
- prompt_results = prompt_for_option_types(params, options, @api_client)
383
- if prompt_results[:success]
384
- params['optionTypes'] = prompt_results[:data] unless prompt_results[:data].nil?
402
+ if params['formType'].to_s.empty?
403
+ params['formType'] = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'formType', 'fieldLabel' => 'Form Type', 'type' => 'select', 'selectOptions' => [{'name' => 'Form', 'value' => 'form'}, {'name' => 'Inputs', 'value' => 'optionTypes'}], 'defaultValue' => 'optionTypes', 'required' => true}], options[:options], @api_client, options[:params])['formType']
404
+ end
405
+ if params['formType'] == 'form'
406
+ # using formType = 'form'
407
+ # prompt for Form
408
+ options[:options]['form'] = params['form'] if params['form']
409
+ form_id = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'form', 'fieldLabel' => 'Form', 'type' => 'select', 'optionSource' => 'forms', 'required' => true}], options[:options], @api_client, options[:params])['form']
410
+ params['form'] = {'id' => form_id}
385
411
  else
386
- return 1, "failed to parse optionTypes"
412
+ # using formType = 'optionTypes'
413
+ # prompt for Option Types
414
+ prompt_results = prompt_for_option_types(params, options, @api_client)
415
+ if prompt_results[:success]
416
+ params['optionTypes'] = prompt_results[:data] unless prompt_results[:data].nil?
417
+ else
418
+ return 1, "failed to parse optionTypes"
419
+ end
387
420
  end
388
421
  payload[catalog_item_type_object_key].deep_merge!(params)
389
422
  end
@@ -470,6 +503,12 @@ EOT
470
503
  options[:options]['config'] = params['config'] # or file_content
471
504
  end
472
505
  end
506
+ opts.on('--form-type form|optionTypes', String, "Form Type determines if input comes from a Form or list of Option Types") do |val|
507
+ params['formType'] = val
508
+ end
509
+ opts.on('--form FORM', String, "Form Name or ID") do |val|
510
+ params['form'] = val
511
+ end
473
512
  opts.on('--option-types [x,y,z]', Array, "List of Option Type IDs") do |list|
474
513
  if list.nil?
475
514
  params['optionTypes'] = []
@@ -693,6 +732,7 @@ EOT
693
732
  "Workflow" => lambda {|it| it['workflow'] ? it['workflow']['name'] : nil },
694
733
  "Context" => lambda {|it| it['context'] },
695
734
  # "Content" => lambda {|it| it['content'] },
735
+ "Form Type" => lambda {|it| it['formType'] == 'form' ? "Form" : "Inputs" },
696
736
  "Enabled" => lambda {|it| format_boolean(it['enabled']) },
697
737
  "Featured" => lambda {|it| format_boolean(it['featured']) },
698
738
  #"Config" => lambda {|it| it['config'] },
@@ -716,6 +756,8 @@ EOT
716
756
  "Workflow" => lambda {|it| it['workflow'] ? it['workflow']['name'] : nil },
717
757
  "Context" => lambda {|it| it['context'] },
718
758
  # "Content" => lambda {|it| it['content'] },
759
+ "Form Type" => lambda {|it| it['formType'] == 'form' ? "Form" : "Inputs" },
760
+ "Form" => lambda {|it| it['form'] ? it['form']['name'] : nil },
719
761
  "Enabled" => lambda {|it| format_boolean(it['enabled']) },
720
762
  "Featured" => lambda {|it| format_boolean(it['featured']) },
721
763
  "Allow Quantity" => lambda {|it| format_boolean(it['allowQuantity']) },
@@ -175,7 +175,7 @@ EOT
175
175
  end
176
176
  # reject hardcoded optionTypes
177
177
  config_option_types = config_option_types.reject {|it| it['fieldName'] == 'name' || it['fieldName'] == 'description' || it['fieldName'] == 'domainName' }
178
- config_prompt = Morpheus::Cli::OptionTypes.prompt(config_option_types, options[:options], @api_client, options[:params])
178
+ config_prompt = Morpheus::Cli::OptionTypes.prompt(config_option_types, options[:options], @api_client, {certType: certificate_type['id']})
179
179
  config_prompt.deep_compact!
180
180
  params.deep_merge!(config_prompt)
181
181
  end
@@ -181,7 +181,8 @@ class Morpheus::Cli::CloudFoldersCommand
181
181
  #"Type" => lambda {|it| it['type'].to_s.capitalize },
182
182
  "Cloud" => lambda {|it| it['zone'] ? it['zone']['name'] : '' },
183
183
  "Active" => lambda {|it| format_boolean(it['active']) },
184
- "Default" => lambda {|it| format_boolean(it['defaultPool']) },
184
+ "Default" => lambda {|it| format_boolean(it['defaultFolder']) },
185
+ "Image Target" => lambda {|it| format_boolean(it['defaultStore']) },
185
186
  "Visibility" => lambda {|it| it['visibility'].to_s.capitalize },
186
187
  #"Tenants" => lambda {|it| it['tenants'] ? it['tenants'].collect {|it| it['name'] }.uniq.join(', ') : '' }
187
188
  # "Owner" => lambda {|it| it['owner'] ? it['owner']['name'] : '' },
@@ -319,6 +320,12 @@ class Morpheus::Cli::CloudFoldersCommand
319
320
  opts.on('--active [on|off]', String, "Can be used to disable a resource folder") do |val|
320
321
  options['active'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == ''
321
322
  end
323
+ opts.on('--default-folder [on|off]', String, "Default Folder") do |val|
324
+ options['defaultFolder'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == ''
325
+ end
326
+ opts.on('--image-target [on|off]', String, "Image Target") do |val|
327
+ options['defaultStore'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == ''
328
+ end
322
329
  build_common_options(opts, options, [:options, :payload, :json, :dry_run, :remote])
323
330
  opts.footer = "Update a resource folder." + "\n" +
324
331
  "[cloud] is required. This is the name or id of the cloud." + "\n"
@@ -408,6 +415,16 @@ class Morpheus::Cli::CloudFoldersCommand
408
415
  if options['active'] != nil
409
416
  payload['folder']['active'] = options['active']
410
417
  end
418
+
419
+ # Default
420
+ if options['defaultFolder'] != nil
421
+ payload['folder']['defaultFolder'] = options['defaultFolder']
422
+ end
423
+
424
+ # Image Target
425
+ if options['defaultStore'] != nil
426
+ payload['folder']['defaultStore'] = options['defaultStore']
427
+ end
411
428
 
412
429
  # Visibility
413
430
  if options['visibility'] != nil