morpheus-cli 8.0.0 → 8.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49afeaaa11ed794659cc20a46d3fc145990269dc96f1394a1cd95160bbc2f786
4
- data.tar.gz: cdcf88755b1638f3d1816dde28dcfea8f8c6be27b9300bdfc3c6e4798d3937dd
3
+ metadata.gz: c8074c5d41cd8ca2aa6f199a0b85f22f7c2b8d3647b2788604d42424b7abbd9b
4
+ data.tar.gz: 8176b21a71b63466b537ca4d43933e06411ae374cbb159ab451f4e37042299e5
5
5
  SHA512:
6
- metadata.gz: 56f27f9ab0323061846e4b3df32d570efff1b944083fe27700a9d729540ad605a1a39a5c2005cc5a0e19880d5f039a7aa3dbc12ff2c31c9b511426ec736f83a7
7
- data.tar.gz: 7d98ac1e35e7929f3f73ff3968d3a2d1221629d1a2c07d7cdd916b2aa184ca2d30041eaeaf2ac5d53c653650a0a36e0c39a33bebbb9bf02bdcf3e4f84e5173c8
6
+ metadata.gz: 05414d569b3e9d323ca0ebf0ff86778e9656f84b92af1a2e6520e826351dc444eb1c6d6721ef7137ffbe603be703832dcd15f4e14c31f28005b6de7c2cc454f8
7
+ data.tar.gz: fca09ddb93cf6cc58401d1652803a61d220fe9999427a931b0fed515c5a8e0a2933013299323722739a7f65c9b9b42edffe4a62972cad85e9b5651a4fcded2df
data/Dockerfile CHANGED
@@ -1,5 +1,5 @@
1
1
  FROM ruby:2.7.5
2
2
 
3
- RUN gem install morpheus-cli -v 8.0.0
3
+ RUN gem install morpheus-cli -v 8.0.1
4
4
 
5
5
  ENTRYPOINT ["morpheus"]
@@ -25,6 +25,13 @@ class Morpheus::ApplianceSettingsInterface < Morpheus::APIClient
25
25
  execute(opts)
26
26
  end
27
27
 
28
+ def locales(params={})
29
+ url = "#{base_path}/locales"
30
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
31
+ opts = {method: :get, url: url, headers: headers}
32
+ execute(opts)
33
+ end
34
+
28
35
  def maintenance(params={}, payload={})
29
36
  url = "#{base_path}/maintenance"
30
37
  headers = { params: params, authorization: "Bearer #{@access_token}" }
@@ -44,6 +44,12 @@ class Morpheus::VirtualImagesInterface < Morpheus::APIClient
44
44
  execute(method: :put, url: url, headers: headers, payload: payload.to_json)
45
45
  end
46
46
 
47
+ def convert(id, payload)
48
+ url = "#{@base_url}/api/virtual-images/#{id}/convert"
49
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
50
+ execute(method: :post, url: url, headers: headers, payload: payload.to_json)
51
+ end
52
+
47
53
  def destroy(id, params={})
48
54
  url = "#{@base_url}/api/virtual-images/#{id}"
49
55
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
@@ -7,7 +7,7 @@ class Morpheus::Cli::ApplianceSettingsCommand
7
7
  set_command_name :'appliance-settings'
8
8
 
9
9
  register_subcommands :get, :update, :toggle_maintenance, :'reindex'
10
-
10
+
11
11
  set_default_subcommand :get
12
12
 
13
13
  def connect(opts)
@@ -33,7 +33,7 @@ class Morpheus::Cli::ApplianceSettingsCommand
33
33
  raise_command_error "wrong number of arguments, expected 0 and got (#{args.count}) #{args}\n#{optparse}"
34
34
  return 1
35
35
  end
36
-
36
+
37
37
  begin
38
38
  @appliance_settings_interface.setopts(options)
39
39
 
@@ -220,6 +220,25 @@ class Morpheus::Cli::ApplianceSettingsCommand
220
220
  opts.on("--stats-retainment-period DAYS", Integer, "Stats retainment period. The number of days stats should be available. Can be 30, 60, or 90.") do |val|
221
221
  params['statsRetainmentPeriod'] = val.to_i
222
222
  end
223
+ opts.on("--cloud-sync-interval-seconds SECONDS", Integer, "Cloud sync interval in seconds") do |val|
224
+ params['cloudSyncIntervalSeconds'] = val.to_i
225
+ end
226
+ opts.on("--cluster-sync-interval-seconds SECONDS", Integer, "Cluster sync interval in seconds") do |val|
227
+ params['clusterSyncIntervalSeconds'] = val.to_i
228
+ end
229
+ opts.on("--usage-retainment-period DAYS", Integer, "Retainment period for usage records") do |val|
230
+ params['usageRetainmentPeriod'] = val.to_i
231
+ end
232
+ opts.on("--invoice-retainment-period DAYS", Integer, "Retainment period for invoice records") do |val|
233
+ params['invoiceRetainmentPeriod'] = val.to_i
234
+ end
235
+ opts.on("--max-option-list-size NUMBER", Integer, "Max option list size (x10^3)") do |val|
236
+ params['maxOptionListSize'] = val.to_i
237
+ end
238
+ opts.on("--default-locale STRING", String, "Default locale for the appliance") do |val|
239
+ params['defaultLocale'] = val == 'null' ? nil : val
240
+ end
241
+
223
242
  build_common_options(opts, options, [:json, :payload, :dry_run, :quiet, :remote])
224
243
  end
225
244
 
@@ -506,7 +506,7 @@ class Morpheus::Cli::Apps
506
506
  # prompt for cloudFormation config
507
507
  # todo
508
508
  else
509
- print yellow, "Unknown template type: #{template_type})", "\n"
509
+ print yellow, "Unknown template type: #{blueprint_type})", "\n"
510
510
  end
511
511
  end
512
512
  end
@@ -1183,7 +1183,7 @@ EOT
1183
1183
 
1184
1184
  # Details (zoneType.optionTypes)
1185
1185
 
1186
- if cloud_type && cloud_type['optionTypes']
1186
+ if cloud_type && cloud_type['optionTypes'] && cloud_type['code'] != 'standard'
1187
1187
  if !cloud_type['optionTypes'].find {|opt| opt['type'] == 'credential'}
1188
1188
  tmp_option_types << {'fieldName' => 'type', 'fieldLabel' => 'Credentials', 'type' => 'credential', 'optionSource' => 'credentials', 'required' => true, 'defaultValue' => 'local', 'config' => {'credentialTypes' => get_cloud_type_credential_types(cloud_type['code'])}, 'displayOrder' => 7}
1189
1189
  cloud_type['optionTypes'].select {|opt| ['username', 'password', 'serviceUsername', 'servicePassword'].include?(opt['fieldName'])}.each {|opt| opt['localCredential'] = true}
@@ -6,7 +6,7 @@ class Morpheus::Cli::VirtualImages
6
6
  include Morpheus::Cli::CliCommand
7
7
  include Morpheus::Cli::ProvisioningHelper
8
8
 
9
- register_subcommands :list, :get, :add, :add_file, :remove_file, :update, :remove, :types => :virtual_image_types
9
+ register_subcommands :list, :get, :add, :add_file, :remove_file, :update, :remove, :convert, :types => :virtual_image_types
10
10
  register_subcommands :list_locations, :get_location, :remove_location
11
11
 
12
12
  # def initialize()
@@ -302,7 +302,7 @@ EOT
302
302
  options = {}
303
303
  tenants_list = nil
304
304
  optparse = Morpheus::Cli::OptionParser.new do |opts|
305
- opts.banner = subcommand_usage("[name] [options]")
305
+ opts.banner = subcommand_usage("[image] [options]")
306
306
  opts.on('--tenants LIST', Array, "Tenant Access, comma separated list of account IDs") do |list|
307
307
  if list.size == 1 && list[0] == 'null' # hacky way to clear it
308
308
  tenants_list = []
@@ -324,7 +324,7 @@ EOT
324
324
  end
325
325
  build_common_options(opts, options, [:options, :payload, :json, :dry_run, :remote])
326
326
  opts.footer = "Update a virtual image." + "\n" +
327
- "[name] is required. This is the name or id of a virtual image."
327
+ "[image] is required. This is the name or id of a virtual image."
328
328
  end
329
329
  optparse.parse!(args)
330
330
  verify_args!(args:args, optparse:optparse, count:1)
@@ -377,6 +377,56 @@ EOT
377
377
 
378
378
  end
379
379
 
380
+ def convert(args)
381
+ image_name = args[0]
382
+ options = {}
383
+ # storageProviderId, format, name
384
+ optparse = Morpheus::Cli::OptionParser.new do |opts|
385
+ opts.banner = subcommand_usage("[image] [options]")
386
+ opts.on('-n', '--name NAME', String, "Name (optional) of the new converted image. Default is name of the original image.") do |val|
387
+ options[:options]['name'] = val
388
+ end
389
+ opts.on('-f', '--format FORMAT', String, "Format (optional). Default is 'qcow2'") do |val|
390
+ options[:options]['format'] = val
391
+ end
392
+ opts.on('--storageProvider VALUE', String, "Storage Provider ID (optional). Default is storage provider of the original image.") do |val|
393
+ options[:options]['storageProvider'] = val.to_s
394
+ end
395
+ build_common_options(opts, options, [:options, :payload, :json, :dry_run, :remote])
396
+ opts.footer = "Convert a virtual image to a new format." + "\n" +
397
+ "[image] is required. This is the name or id of a virtual image."
398
+ end
399
+ optparse.parse!(args)
400
+ verify_args!(args:args, optparse:optparse, min:1, max:4)
401
+
402
+ connect(options)
403
+
404
+ virtual_image = find_virtual_image_by_name_or_id(image_name)
405
+ return 1, "Virtual image not found for #{image_name}" if virtual_image.nil?
406
+
407
+ passed_options = parse_passed_options(options)
408
+ payload = nil
409
+ if options[:payload]
410
+ payload = options[:payload]
411
+ payload.deep_merge!({virtual_image_object_key => passed_options}) unless passed_options.empty?
412
+ else
413
+ virtual_image_payload = passed_options
414
+ virtual_image_payload['storageProvider'] = {'id' => virtual_image_payload['storageProvider']} unless virtual_image_payload['storageProvider'].nil?
415
+ payload = virtual_image_payload
416
+ end
417
+ @virtual_images_interface.setopts(options)
418
+ if options[:dry_run]
419
+ print_dry_run @virtual_images_interface.dry.convert(virtual_image['id'], payload)
420
+ return
421
+ end
422
+ json_response = @virtual_images_interface.convert(virtual_image['id'], payload)
423
+ render_response(json_response, options, 'virtualImage') do
424
+ print_green_success "Updated virtual image #{virtual_image['name']}"
425
+ _get(virtual_image["id"], {}, options)
426
+ end
427
+ return 0, nil
428
+ end
429
+
380
430
  def virtual_image_types(args)
381
431
  options = {}
382
432
  optparse = Morpheus::Cli::OptionParser.new do |opts|
@@ -621,7 +671,7 @@ EOT
621
671
  do_gzip = false
622
672
  options = {}
623
673
  optparse = Morpheus::Cli::OptionParser.new do |opts|
624
- opts.banner = subcommand_usage("[name] [filepath]")
674
+ opts.banner = subcommand_usage("[image] [filepath]")
625
675
  opts.on('--filename FILENAME', String, "Filename for uploaded file. Derived from [filepath] by default." ) do |val|
626
676
  file_name = val
627
677
  end
@@ -633,7 +683,7 @@ EOT
633
683
  end
634
684
  build_common_options(opts, options, [:json, :dry_run, :quiet, :remote])
635
685
  opts.footer = "Upload a virtual image file." + "\n" +
636
- "[name] is required. This is the name or id of a virtual image." + "\n" +
686
+ "[image] is required. This is the name or id of a virtual image." + "\n" +
637
687
  "[filepath] or --url is required. This is location of the virtual image file."
638
688
  end
639
689
  optparse.parse!(args)
@@ -700,7 +750,7 @@ EOT
700
750
  def remove_file(args)
701
751
  options = {}
702
752
  optparse = Morpheus::Cli::OptionParser.new do |opts|
703
- opts.banner = subcommand_usage("[name] [filename]")
753
+ opts.banner = subcommand_usage("[image] [filename]")
704
754
  build_common_options(opts, options, [:auto_confirm, :json, :dry_run, :remote])
705
755
  end
706
756
  optparse.parse!(args)
@@ -509,13 +509,15 @@ module Morpheus::Cli::PrintHelper
509
509
  bars = []
510
510
  percent = 0
511
511
  percent_sigdig = opts[:percent_sigdig] || 2
512
- if max_value.to_i == 0
512
+ if max_value.nil?
513
513
  percent = 0
514
+ elsif max_value == 0
515
+ percent = used_value.to_f == 0 ? 0 : 100
514
516
  else
515
517
  percent = ((used_value.to_f / max_value.to_f) * 100)
516
518
  end
517
519
  unlimited_label = opts[:unlimited_label] || "n/a"
518
- percent_label = ((used_value.nil? || max_value.to_f == 0.0) ? unlimited_label : "#{percent.round(percent_sigdig)}%").rjust(6, ' ')
520
+ percent_label = (max_value.nil? ? unlimited_label : "#{percent.round(percent_sigdig)}%").rjust(6, ' ')
519
521
  bar_display = ""
520
522
  if percent > 100
521
523
  max_bars.times { bars << "|" }
@@ -508,16 +508,17 @@ module Morpheus::Cli::ProvisioningHelper
508
508
 
509
509
  while instance_name.nil? do
510
510
  name_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'name', 'fieldLabel' => 'Instance Name', 'type' => 'text', 'required' => options[:name_required], 'defaultValue' => options[:default_name]}], options[:options])
511
-
512
- if name_prompt['name'].nil? && !options[:name_required]
511
+ name = name_prompt['name']
512
+ if name.nil? && !options[:name_required]
513
513
  break
514
514
  else
515
- if instances_interface.list({name: name_prompt['name']})['instances'].empty?
516
- instance_name = name_prompt['name']
515
+ if instances_interface.list({name: name})['instances'].empty?
516
+ instance_name = name
517
517
  else
518
- print_red_alert "Name must be unique"
518
+ print_red_alert "Name must be unique, #{name} already exists"
519
+ options[:options].delete('name')
519
520
  exit 1 if no_prompt
520
- if options[:default_name] == name_prompt['name']
521
+ if options[:default_name] == name
521
522
  options[:default_name] += '-2'
522
523
  end
523
524
  end
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Morpheus
3
3
  module Cli
4
- VERSION = "8.0.0"
4
+ VERSION = "8.0.1"
5
5
  end
6
6
  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: 8.0.0
4
+ version: 8.0.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: 2024-11-15 00:00:00.000000000 Z
14
+ date: 2024-12-13 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: public_suffix