morpheus-cli 5.3.2 → 5.3.2.1

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.
@@ -94,46 +94,37 @@ module Morpheus
94
94
  end
95
95
 
96
96
  if !visible_option_check_value.to_s.empty?
97
- # support formats code=value or code:value OR code:(value|value2|value3)
98
- # OR fieldContext.fieldName=value
99
- parts = visible_option_check_value.include?("=") ? visible_option_check_value.split("=") : visible_option_check_value.split(":")
100
- depends_on_code = parts[0]
101
- depends_on_value = parts[1].to_s.strip
102
- depends_on_values = []
103
- if depends_on_value.size > 0
104
- # strip parenthesis
105
- if depends_on_value[0] && depends_on_value[0].chr == "("
106
- depends_on_value = depends_on_value[1..-1]
107
- end
108
- depends_on_value.chomp(")")
109
- depends_on_values = depends_on_value.split("|").collect { |it| it.strip }
110
- end
111
- depends_on_option_type = option_types.find {|it| it["code"] == depends_on_code }
112
- if !depends_on_option_type
113
- depends_on_option_type = option_types.find {|it|
114
- (it['fieldContext'] ? "#{it['fieldContext']}.#{it['fieldName']}" : it['fieldName']) == depends_on_code
115
- }
97
+ match_type = 'any'
98
+
99
+ if visible_option_check_value.include?('::')
100
+ match_type = 'all' if visible_option_check_value.start_with?('matchAll')
101
+ visible_option_check_value = visible_option_check_value[visible_option_check_value.index('::') + 2..-1]
116
102
  end
117
- if depends_on_option_type
118
- # dependent option type has a different value
119
- depends_on_field_key = depends_on_option_type['fieldContext'].nil? || depends_on_option_type['fieldContext'].empty? ? "#{depends_on_option_type['fieldName']}" : "#{depends_on_option_type['fieldContext']}.#{depends_on_option_type['fieldName']}"
120
- found_dep_value = get_object_value(results, depends_on_field_key) || get_object_value(options, depends_on_field_key)
121
-
122
- if depends_on_values.size > 0
123
- # must be in the specified values
124
- # todo: uhh this actually needs to change to parse regex
125
- if !depends_on_values.include?(found_dep_value)
126
- next
127
- end
128
- else
129
- # no value found
130
- if found_dep_value.to_s.empty?
131
- next
103
+
104
+ found_dep_value = match_type == 'all' ? true : false
105
+ visible_option_check_value.split(',').each do |value|
106
+ parts = value.split(':')
107
+ depends_on_code = parts[0]
108
+ depends_on_value = parts.count > 1 ? parts[1].to_s.strip : '.'
109
+ depends_on_option_type = option_types.find {|it| it["code"] == depends_on_code }
110
+ if !depends_on_option_type
111
+ depends_on_option_type = option_types.find {|it|
112
+ (it['fieldContext'] ? "#{it['fieldContext']}.#{it['fieldName']}" : it['fieldName']) == depends_on_code
113
+ }
114
+ end
115
+
116
+ if depends_on_option_type
117
+ depends_on_field_key = depends_on_option_type['fieldContext'].nil? || depends_on_option_type['fieldContext'].empty? ? "#{depends_on_option_type['fieldName']}" : "#{depends_on_option_type['fieldContext']}.#{depends_on_option_type['fieldName']}"
118
+ field_value = get_object_value(results, depends_on_field_key) || get_object_value(options, depends_on_field_key)
119
+
120
+ if !field_value.nil? && field_value.match?(depends_on_value)
121
+ found_dep_value = true if match_type != 'all'
122
+ else
123
+ found_dep_value = false if match_type == 'all'
132
124
  end
133
125
  end
134
- else
135
- # could not find the dependent option type, proceed and prompt
136
126
  end
127
+ next if !found_dep_value
137
128
  end
138
129
 
139
130
  cur_namespace = options
@@ -283,10 +274,9 @@ module Morpheus
283
274
 
284
275
  if option_type['type'] == 'multiSelect'
285
276
  value = [value] if !value.nil? && !value.is_a?(Array)
286
- parent_context_map[parent_ns] = value
287
- else
288
- context_map[field_name] = value
277
+ # parent_context_map[parent_ns] = value
289
278
  end
279
+ context_map[field_name] = value
290
280
  end
291
281
  results
292
282
  end
@@ -248,41 +248,39 @@ EOT
248
248
 
249
249
 
250
250
  def remove(args)
251
+ params = {}
251
252
  options = {}
252
253
  optparse = Morpheus::Cli::OptionParser.new do |opts|
253
- opts.banner = subcommand_usage("[name]")
254
- build_common_options(opts, options, [:auto_confirm, :json, :remote, :dry_run])
254
+ opts.banner = subcommand_usage("[tenant]")
255
+ opts.on('--remove-resources [on|off]', ['on','off'], "Remove Infrastructure. Default is off.") do |val|
256
+ params[:removeResources] = val.nil? ? 'on' : val
257
+ end
258
+ build_standard_remove_options(opts, options)
259
+ opts.footer = <<-EOT
260
+ Delete a tenant.
261
+ [tenant] is required. This is the name or id of a tenant.
262
+ EOT
255
263
  end
256
264
  optparse.parse!(args)
257
- if args.count < 1
258
- puts optparse
259
- exit 1
260
- end
265
+ verify_args!(args:args, optparse:optparse, count:1)
266
+ optparse.parse!(args)
261
267
  connect(options)
262
268
  begin
263
269
  # allow finding by ID since name is not unique!
264
270
  account = find_account_by_name_or_id(args[0])
265
- exit 1 if account.nil?
266
- unless options[:yes] || Morpheus::Cli::OptionTypes.confirm("Are you sure you want to delete the account #{account['name']}?")
267
- exit
268
- end
269
- if options[:dry_run] && options[:json]
270
- puts as_json(payload, options)
271
- return 0
271
+ return 1, "tenant not found" if account.nil?
272
+ unless options[:yes] || Morpheus::Cli::OptionTypes.confirm("Are you sure you want to delete the tenant #{account['name']}?")
273
+ return 9, "aborted command"
272
274
  end
273
275
  @accounts_interface.setopts(options)
274
276
  if options[:dry_run]
275
- print_dry_run @accounts_interface.dry.destroy(account['id'])
277
+ print_dry_run @accounts_interface.dry.destroy(account['id'], params)
276
278
  return
277
279
  end
278
- json_response = @accounts_interface.destroy(account['id'])
279
- if options[:json]
280
- print JSON.pretty_generate(json_response)
281
- print "\n"
282
- else
280
+ json_response = @accounts_interface.destroy(account['id'], params)
281
+ render_response(json_response, options) do
283
282
  print_green_success "Tenant #{account['name']} removed"
284
283
  end
285
-
286
284
  rescue RestClient::Exception => e
287
285
  print_rest_exception(e, options)
288
286
  exit 1
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Morpheus
3
3
  module Cli
4
- VERSION = "5.3.2"
4
+ VERSION = "5.3.2.1"
5
5
  end
6
6
  end
@@ -0,0 +1,41 @@
1
+ class String
2
+
3
+ def pluralize
4
+ value = self
5
+ if value == ""
6
+ value
7
+ elsif value[-1].chr == "y"
8
+ value[0..-2] + "ies"
9
+ elsif value[-1].chr == "s"
10
+ if value[-2..-1] == "es"
11
+ value
12
+ else
13
+ value + "es"
14
+ end
15
+ else
16
+ value + "s"
17
+ end
18
+ end
19
+
20
+ def singularize
21
+ value = self
22
+ if value == ""
23
+ value
24
+ elsif value.size > 3 && value[-3..-1] == "ies"
25
+ value[0..-4] + "y"
26
+ elsif value.size > 2 && value[-3..-1] == "ses"
27
+ value[0..-3]
28
+ elsif value[-1] == "s"
29
+ value[0..-2]
30
+ end
31
+ end
32
+
33
+ def dasherize
34
+ self.gsub(" ", "-").gsub("_", "-")
35
+ end
36
+
37
+ def underscoreize
38
+ self.gsub(" ", "_").gsub("-", "_")
39
+ end
40
+
41
+ end
@@ -472,3 +472,7 @@ def format_name_values(obj)
472
472
  ""
473
473
  end
474
474
  end
475
+
476
+ def a_or_an(v)
477
+ v.to_s =~ /^[aeiou]/i ? "an" : "a"
478
+ 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: 5.3.2
4
+ version: 5.3.2.1
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: 2021-07-12 00:00:00.000000000 Z
14
+ date: 2021-08-11 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -236,6 +236,9 @@ files:
236
236
  - lib/morpheus/api/library_spec_template_types_interface.rb
237
237
  - lib/morpheus/api/library_spec_templates_interface.rb
238
238
  - lib/morpheus/api/license_interface.rb
239
+ - lib/morpheus/api/load_balancer_pools_interface.rb
240
+ - lib/morpheus/api/load_balancer_types_interface.rb
241
+ - lib/morpheus/api/load_balancer_virtual_servers_interface.rb
239
242
  - lib/morpheus/api/load_balancers_interface.rb
240
243
  - lib/morpheus/api/log_settings_interface.rb
241
244
  - lib/morpheus/api/logs_interface.rb
@@ -279,6 +282,8 @@ files:
279
282
  - lib/morpheus/api/rest_interface.rb
280
283
  - lib/morpheus/api/roles_interface.rb
281
284
  - lib/morpheus/api/search_interface.rb
285
+ - lib/morpheus/api/secondary_read_interface.rb
286
+ - lib/morpheus/api/secondary_rest_interface.rb
282
287
  - lib/morpheus/api/security_group_rules_interface.rb
283
288
  - lib/morpheus/api/security_groups_interface.rb
284
289
  - lib/morpheus/api/server_types_interface.rb
@@ -392,6 +397,7 @@ files:
392
397
  - lib/morpheus/cli/library_spec_templates_command.rb
393
398
  - lib/morpheus/cli/library_upgrades_command.rb
394
399
  - lib/morpheus/cli/license.rb
400
+ - lib/morpheus/cli/load_balancer_types.rb
395
401
  - lib/morpheus/cli/load_balancers.rb
396
402
  - lib/morpheus/cli/log_settings_command.rb
397
403
  - lib/morpheus/cli/login.rb
@@ -402,6 +408,7 @@ files:
402
408
  - lib/morpheus/cli/mixins/deployments_helper.rb
403
409
  - lib/morpheus/cli/mixins/infrastructure_helper.rb
404
410
  - lib/morpheus/cli/mixins/library_helper.rb
411
+ - lib/morpheus/cli/mixins/load_balancers_helper.rb
405
412
  - lib/morpheus/cli/mixins/logs_helper.rb
406
413
  - lib/morpheus/cli/mixins/monitoring_helper.rb
407
414
  - lib/morpheus/cli/mixins/operations_helper.rb
@@ -410,6 +417,7 @@ files:
410
417
  - lib/morpheus/cli/mixins/processes_helper.rb
411
418
  - lib/morpheus/cli/mixins/provisioning_helper.rb
412
419
  - lib/morpheus/cli/mixins/remote_helper.rb
420
+ - lib/morpheus/cli/mixins/rest_command.rb
413
421
  - lib/morpheus/cli/mixins/vdi_helper.rb
414
422
  - lib/morpheus/cli/mixins/whoami_helper.rb
415
423
  - lib/morpheus/cli/monitoring_alerts_command.rb
@@ -473,6 +481,7 @@ files:
473
481
  - lib/morpheus/ext/hash.rb
474
482
  - lib/morpheus/ext/nil_class.rb
475
483
  - lib/morpheus/ext/rest_client.rb
484
+ - lib/morpheus/ext/string.rb
476
485
  - lib/morpheus/formatters.rb
477
486
  - lib/morpheus/logging.rb
478
487
  - lib/morpheus/morpkg.rb