morpheus-cli 6.2.2 → 6.3.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 (38) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile +1 -1
  3. data/README.md +6 -0
  4. data/lib/morpheus/api/api_client.rb +12 -0
  5. data/lib/morpheus/api/clusters_interface.rb +7 -0
  6. data/lib/morpheus/api/network_security_server_types_interface.rb +9 -0
  7. data/lib/morpheus/api/network_server_types_interface.rb +9 -0
  8. data/lib/morpheus/api/network_servers_interface.rb +4 -0
  9. data/lib/morpheus/cli/cli_command.rb +1 -0
  10. data/lib/morpheus/cli/commands/clouds.rb +101 -28
  11. data/lib/morpheus/cli/commands/clouds_types.rb +141 -0
  12. data/lib/morpheus/cli/commands/clusters.rb +43 -0
  13. data/lib/morpheus/cli/commands/instances.rb +1 -0
  14. data/lib/morpheus/cli/commands/network_dhcp_relays_command.rb +1 -42
  15. data/lib/morpheus/cli/commands/network_dhcp_servers_command.rb +3 -44
  16. data/lib/morpheus/cli/commands/network_edge_clusters_command.rb +1 -42
  17. data/lib/morpheus/cli/commands/network_firewalls_command.rb +1 -41
  18. data/lib/morpheus/cli/commands/network_pool_servers_command.rb +3 -1
  19. data/lib/morpheus/cli/commands/network_routers_command.rb +4 -6
  20. data/lib/morpheus/cli/commands/network_security_server_types.rb +20 -0
  21. data/lib/morpheus/cli/commands/network_server_types_command.rb +20 -0
  22. data/lib/morpheus/cli/commands/network_servers_command.rb +368 -0
  23. data/lib/morpheus/cli/commands/network_transport_zones_command.rb +1 -41
  24. data/lib/morpheus/cli/commands/networks_command.rb +1 -1
  25. data/lib/morpheus/cli/commands/options.rb +135 -2
  26. data/lib/morpheus/cli/commands/policies_command.rb +112 -128
  27. data/lib/morpheus/cli/commands/roles.rb +3 -0
  28. data/lib/morpheus/cli/mixins/accounts_helper.rb +2 -0
  29. data/lib/morpheus/cli/mixins/infrastructure_helper.rb +103 -2
  30. data/lib/morpheus/cli/mixins/networks_helper.rb +62 -0
  31. data/lib/morpheus/cli/mixins/print_helper.rb +28 -7
  32. data/lib/morpheus/cli/mixins/prompt_helper.rb +15 -0
  33. data/lib/morpheus/cli/mixins/provisioning_helper.rb +25 -9
  34. data/lib/morpheus/cli/mixins/rest_command.rb +1 -1
  35. data/lib/morpheus/cli/option_types.rb +3 -3
  36. data/lib/morpheus/cli/version.rb +1 -1
  37. data/lib/morpheus/logging.rb +6 -3
  38. metadata +10 -2
@@ -58,7 +58,7 @@ module Morpheus::Cli::PrintHelper
58
58
  # title - subtitle1, subtitle2
59
59
  # ==================
60
60
  #
61
- def print_h1(title, subtitles=nil, options=nil)
61
+ def print_h1(title, subtitles=nil, options=nil, suffix_content="\n")
62
62
  # ok, support all these formats for now:
63
63
  # print_h1(title, options={})
64
64
  # print_h1(title, subtitles, options={})
@@ -89,14 +89,18 @@ module Morpheus::Cli::PrintHelper
89
89
  end
90
90
  out << "\n"
91
91
  if options[:border_style] == :thin
92
- out << "\n"
92
+
93
93
  else
94
- out << "#{color}#{bold}==================#{reset}\n\n"
94
+ out << "#{color}#{bold}==================#{reset}\n"
95
+ end
96
+ # Default suffix_content is typically one extra newline
97
+ if !suffix_content.to_s.empty?
98
+ out << suffix_content.to_s
95
99
  end
96
100
  print out
97
101
  end
98
102
 
99
- def print_h2(title, subtitles=nil, options=nil)
103
+ def print_h2(title, subtitles=nil, options=nil, suffix_content="\n")
100
104
  # ok, support all these formats for now:
101
105
  # print_h2(title={})
102
106
  # print_h2(title, options={})
@@ -117,9 +121,13 @@ module Morpheus::Cli::PrintHelper
117
121
  end
118
122
  out << "\n"
119
123
  if options[:border_style] == :thin
120
- out << "\n"
124
+
121
125
  else
122
- out << "#{color}---------------------#{reset}\n\n"
126
+ out << "#{color}---------------------#{reset}\n"
127
+ end
128
+ # Default suffix_content is typically one extra newline
129
+ if !suffix_content.to_s.empty?
130
+ out << suffix_content.to_s
123
131
  end
124
132
  print out
125
133
  end
@@ -1505,8 +1513,21 @@ module Morpheus::Cli::PrintHelper
1505
1513
  def format_option_types_table(option_types, options={}, domain_name=nil)
1506
1514
  columns = [
1507
1515
  {"FIELD LABEL" => lambda {|it| it['fieldLabel'] } },
1508
- {"FIELD NAME" => lambda {|it| [it['fieldContext'] == domain_name ? nil : it['fieldContext'], it['fieldName']].select {|it| !it.to_s.empty? }.join('.') } },
1516
+ {"FIELD NAME" => lambda {|it|
1517
+ if it['fieldContext'] && it['fieldContext'] != domain_name && it['fieldContext'] != 'domain'
1518
+ "#{it['fieldContext']}.#{it['fieldName']}"
1519
+ else
1520
+ "#{it['fieldName']}"
1521
+ end
1522
+ } },
1509
1523
  {"TYPE" => lambda {|it| it['type'] } },
1524
+ {"OPTION SOURCE" => lambda {|it|
1525
+ if it['optionSourceType']
1526
+ "#{it['optionSourceType']}/#{it['optionSource']}"
1527
+ else
1528
+ "#{it['optionSource']}"
1529
+ end
1530
+ } },
1510
1531
  {"DEFAULT" => lambda {|it| it['defaultValue'] } },
1511
1532
  {"REQUIRED" => lambda {|it| format_boolean it['required'] } },
1512
1533
  ]
@@ -0,0 +1,15 @@
1
+ # Mixin for Morpheus::Cli command classes
2
+ # Provides common methods for prompting for input
3
+ module Morpheus::Cli::PromptHelper
4
+
5
+ # prompt for a single option type and and return the input value
6
+ # @param option_type [Hash] The OptionType input record to prompt for , contians fieldName, fieldLabel, etc.
7
+ # @param options [Hash] The context being constructed, checks this for the value before prompting the user for input.
8
+ # @param no_prompt [Boolean] The context being constructed, checks this for the value before prompting the user for input.
9
+ # @param api_params [Hash] Optional map of parameters to include in API request for select option types
10
+ # @return input value for the option type, usually a string or number if the value is an ID or of type: number
11
+ def prompt_value(option_type, options, no_prompt=false, api_params={})
12
+ # this does not work with fieldContext, so get rid of it
13
+ return Morpheus::Cli::OptionTypes.prompt([option_type.merge({'fieldContext' => nil})], options, @api_client, api_params, no_prompt)[option_type['fieldName']]
14
+ end
15
+ end
@@ -915,8 +915,8 @@ module Morpheus::Cli::ProvisioningHelper
915
915
 
916
916
  # Security Groups
917
917
  # look for securityGroups option type... this is old and goofy
918
- sg_option_type = option_type_list.find {|opt| ((opt['code'] == 'provisionType.amazon.securityId') || (opt['name'] == 'securityId')) }
919
- option_type_list = option_type_list.reject {|opt| ((opt['code'] == 'provisionType.amazon.securityId') || (opt['name'] == 'securityId')) }
918
+ sg_option_type = option_type_list.find {|opt| ((opt['code'] == 'provisionType.amazon.securityId') || (opt['fieldName'] == 'securityId' || opt['name'] == 'securityId')) }
919
+ option_type_list = option_type_list.reject {|opt| ((opt['code'] == 'provisionType.amazon.securityId') || (opt['fieldName'] == 'securityId' || opt['name'] == 'securityId')) }
920
920
  if locked_fields.include?('securityGroups')
921
921
  # payload['securityGroups'] = options[:options]['securityGroups'] if options[:options]['securityGroups']
922
922
  else
@@ -924,19 +924,35 @@ module Morpheus::Cli::ProvisioningHelper
924
924
  # ok.. seed data has changed and serverTypes do not have this optionType anymore...
925
925
  if sg_option_type.nil?
926
926
  if provision_type && (provision_type["code"] == 'amazon')
927
- sg_option_type = {'fieldContext' => 'config', 'fieldName' => 'securityId', 'type' => 'select', 'fieldLabel' => 'Security Group', 'optionSource' => 'amazonSecurityGroup', 'required' => true, 'description' => 'Select security group.', 'defaultValue' => options[:default_security_group]}
927
+ sg_option_type = {'fieldContext' => 'config', 'fieldName' => 'securityId', 'type' => 'select', 'fieldLabel' => 'Security Group', 'optionSource' => 'amazonSecurityGroup', 'optionSourceType' => 'amazon', 'required' => true, 'description' => 'Select security group.', 'defaultValue' => options[:default_security_group]}
928
928
  end
929
929
  end
930
930
  sg_api_params = {zoneId: cloud_id, poolId: pool_id}
931
- has_security_groups = !!sg_option_type
932
- available_security_groups = []
933
- if sg_option_type && sg_option_type['type'] == 'select' && sg_option_type['optionSource']
934
- sg_option_results = options_interface.options_for_source(sg_option_type['optionSource'], sg_api_params, sg_option_type['optionSourceType'])
935
- available_security_groups = sg_option_results['data'].collect do |it|
936
- {"id" => it["value"] || it["id"], "name" => it["name"], "value" => it["value"] || it["id"]}
931
+ # The amazon plugin uses a new optionSource options/amazon/awsPluginEc2SecurityGroup
932
+ # which expects parameter config.resourcePoolId=pool-ID
933
+ if sg_option_type
934
+ if sg_option_type['optionSource'] == 'awsPluginEc2SecurityGroup'
935
+ if pool_id
936
+ sg_api_params[:config] ||= {}
937
+ sg_api_params[:config][:resourcePoolId] = pool_id
938
+ end
939
+ # convert multiSelect to select to make prompt_security_groups() work
940
+ # though we should should be able to skip the prompt_security_groups and use multiSelect instead
941
+ sg_option_type['type'] = 'select' if sg_option_type['type'] == 'multiSelect'
942
+ sg_option_type['type'] = 'typeahead' if sg_option_type['type'] == 'multiTypeahead'
943
+ sg_option_type['fieldLabel'] = 'Security Group' if sg_option_type['fieldLabel'] == 'Security Groups'
944
+ sg_option_type['required'] = true
937
945
  end
938
946
  end
947
+ has_security_groups = !!sg_option_type
939
948
  if options[:security_groups]
949
+ available_security_groups = []
950
+ if sg_option_type && sg_option_type['optionSource']
951
+ sg_option_results = options_interface.options_for_source(sg_option_type['optionSource'], sg_api_params, sg_option_type['optionSourceType'])
952
+ available_security_groups = sg_option_results['data'].collect do |it|
953
+ {"id" => it["value"] || it["id"], "name" => it["name"], "value" => it["value"] || it["id"]}
954
+ end
955
+ end
940
956
  # work with id or names, API expects ids though.
941
957
  payload['securityGroups'] = options[:security_groups].collect {|sg_id|
942
958
  found_sg = available_security_groups.find {|it| sg_id && (sg_id.to_s == it['id'].to_s || sg_id.to_s == it['name'].to_s) }
@@ -982,7 +982,7 @@ EOT
982
982
  # print_description_list(config.keys, config)
983
983
  # end
984
984
  # Option Types
985
- if record['optionTypes'] && record['optionTypes'].sort { |x,y| x['displayOrder'].to_i <=> y['displayOrder'].to_i }.size > 0
985
+ if record['optionTypes'] && record['optionTypes'].size > 0
986
986
  print_h2 "Option Types", options
987
987
  print format_option_types_table(record['optionTypes'], options, rest_object_key)
988
988
  end
@@ -673,9 +673,9 @@ module Morpheus
673
673
  if input.empty? && default_value
674
674
  input = default_value.to_s
675
675
  end
676
- matched_option = select_options.find{|it| (!it['value'].nil? && it['value'].to_s == input) || (!it[value_field].nil? && it[value_field].to_s == input) || (it[value_field].nil? && input.empty?)}
676
+ matched_option = (select_options || []).find{|it| (!it['value'].nil? && it['value'].to_s == input) || (!it[value_field].nil? && it[value_field].to_s == input) || (it[value_field].nil? && input.empty?)}
677
677
  if matched_option.nil?
678
- matched_options = select_options.select {|it| it['name'] == input } # should probably be case insensitive
678
+ matched_options = (select_options || []).select {|it| it['name'] == input } # should probably be case insensitive
679
679
  if matched_options.size > 1
680
680
  print Term::ANSIColor.red, "\nInvalid Option #{option_type['fieldLabel']}: [#{input}]\n\n", Term::ANSIColor.reset
681
681
  print Term::ANSIColor.red, " * #{option_type['fieldLabel']} [-O #{option_type['fieldContext'] ? (option_type['fieldContext']+'.') : ''}#{option_type['fieldName']}=] - #{option_type['description']}\n", Term::ANSIColor.reset
@@ -699,7 +699,7 @@ module Morpheus
699
699
 
700
700
  if input == '?'
701
701
  help_prompt(option_type)
702
- display_select_options(option_type, select_options, paging)
702
+ display_select_options(option_type, (select_options || []), paging)
703
703
  if paging
704
704
  paging[:cur_page] = (paging[:cur_page] + 1) * paging[:page_size] < paging[:total] ? paging[:cur_page] + 1 : 0
705
705
  end
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Morpheus
3
3
  module Cli
4
- VERSION = "6.2.2"
4
+ VERSION = "6.3.0"
5
5
  end
6
6
  end
@@ -94,9 +94,12 @@ module Morpheus::Logging
94
94
  end
95
95
  msg.gsub!(/password\"\: "[^"]+/, 'password": "************') # json properties ending with password
96
96
  msg.gsub!(/Password\"\: "[^"]+/, 'Password": "************') # json properties ending with Password
97
- msg.gsub!(/password\"\s?\=\>\s?\"[^"]+/i, 'password"=>"************')
98
- msg.gsub!(/password\=\"[^"]+/i, 'password="************')
99
- msg.gsub!(/password\=[^"'&]+/i, 'password=************') # buggy, wont work with ampersand or quotes in passwords! heh
97
+ msg.gsub!(/password\"\s?\=\>\s?\"[^"]+/, 'password"=>"************')
98
+ msg.gsub!(/Password\"\s?\=\>\s?\"[^"]+/, 'Password"=>"************')
99
+ msg.gsub!(/password\=\"[^"]+/, 'password="************')
100
+ msg.gsub!(/Password\=\"[^"]+/, 'Password="************')
101
+ msg.gsub!(/password\=[^"'&]+/, 'password=************') # buggy, wont work with ampersand or quotes in passwords! heh
102
+ msg.gsub!(/Password\=[^"'&]+/, 'Password=************')
100
103
  msg.gsub!(/passwordConfirmation\=[^" ]+/i, 'passwordConfirmation="************')
101
104
  msg.gsub!(/passwordConfirmation\=[^" ]+/i, 'passwordConfirmation=************')
102
105
  end
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.2.2
4
+ version: 6.3.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: 2023-09-13 00:00:00.000000000 Z
14
+ date: 2023-10-30 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -291,8 +291,10 @@ files:
291
291
  - lib/morpheus/api/network_pools_interface.rb
292
292
  - lib/morpheus/api/network_proxies_interface.rb
293
293
  - lib/morpheus/api/network_routers_interface.rb
294
+ - lib/morpheus/api/network_security_server_types_interface.rb
294
295
  - lib/morpheus/api/network_security_servers_interface.rb
295
296
  - lib/morpheus/api/network_server_groups_interface.rb
297
+ - lib/morpheus/api/network_server_types_interface.rb
296
298
  - lib/morpheus/api/network_servers_interface.rb
297
299
  - lib/morpheus/api/network_services_interface.rb
298
300
  - lib/morpheus/api/network_static_routes_interface.rb
@@ -391,6 +393,7 @@ files:
391
393
  - lib/morpheus/cli/commands/cloud_folders_command.rb
392
394
  - lib/morpheus/cli/commands/cloud_resource_pools_command.rb
393
395
  - lib/morpheus/cli/commands/clouds.rb
396
+ - lib/morpheus/cli/commands/clouds_types.rb
394
397
  - lib/morpheus/cli/commands/clusters.rb
395
398
  - lib/morpheus/cli/commands/coloring_command.rb
396
399
  - lib/morpheus/cli/commands/containers_command.rb
@@ -469,7 +472,10 @@ files:
469
472
  - lib/morpheus/cli/commands/network_pools_command.rb
470
473
  - lib/morpheus/cli/commands/network_proxies_command.rb
471
474
  - lib/morpheus/cli/commands/network_routers_command.rb
475
+ - lib/morpheus/cli/commands/network_security_server_types.rb
472
476
  - lib/morpheus/cli/commands/network_server_groups_command.rb
477
+ - lib/morpheus/cli/commands/network_server_types_command.rb
478
+ - lib/morpheus/cli/commands/network_servers_command.rb
473
479
  - lib/morpheus/cli/commands/network_services_command.rb
474
480
  - lib/morpheus/cli/commands/network_static_routes_command.rb
475
481
  - lib/morpheus/cli/commands/network_transport_zones_command.rb
@@ -552,10 +558,12 @@ files:
552
558
  - lib/morpheus/cli/mixins/load_balancers_helper.rb
553
559
  - lib/morpheus/cli/mixins/logs_helper.rb
554
560
  - lib/morpheus/cli/mixins/monitoring_helper.rb
561
+ - lib/morpheus/cli/mixins/networks_helper.rb
555
562
  - lib/morpheus/cli/mixins/operations_helper.rb
556
563
  - lib/morpheus/cli/mixins/option_source_helper.rb
557
564
  - lib/morpheus/cli/mixins/print_helper.rb
558
565
  - lib/morpheus/cli/mixins/processes_helper.rb
566
+ - lib/morpheus/cli/mixins/prompt_helper.rb
559
567
  - lib/morpheus/cli/mixins/provisioning_helper.rb
560
568
  - lib/morpheus/cli/mixins/remote_helper.rb
561
569
  - lib/morpheus/cli/mixins/rest_command.rb