opennebula-cli 5.10.5 → 5.12.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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/bin/oneacct +4 -2
  3. data/bin/oneacl +4 -2
  4. data/bin/onecluster +4 -2
  5. data/bin/onedatastore +4 -2
  6. data/bin/oneflow +151 -552
  7. data/bin/oneflow-template +173 -293
  8. data/bin/onegroup +4 -2
  9. data/bin/onehook +4 -2
  10. data/bin/onehost +78 -10
  11. data/bin/oneimage +4 -2
  12. data/bin/onemarket +4 -2
  13. data/bin/onemarketapp +17 -4
  14. data/bin/onesecgroup +4 -2
  15. data/bin/oneshowback +4 -2
  16. data/bin/onetemplate +4 -2
  17. data/bin/oneuser +4 -2
  18. data/bin/onevcenter +4 -2
  19. data/bin/onevdc +4 -2
  20. data/bin/onevm +170 -17
  21. data/bin/onevmgroup +4 -2
  22. data/bin/onevnet +16 -41
  23. data/bin/onevntemplate +4 -2
  24. data/bin/onevrouter +4 -2
  25. data/bin/onezone +7 -2
  26. data/lib/cli_helper.rb +54 -30
  27. data/lib/command_parser.rb +53 -19
  28. data/lib/one_helper.rb +258 -6
  29. data/lib/one_helper/oneacct_helper.rb +1 -1
  30. data/lib/one_helper/oneacl_helper.rb +1 -1
  31. data/lib/one_helper/onecluster_helper.rb +4 -4
  32. data/lib/one_helper/onedatastore_helper.rb +1 -1
  33. data/lib/one_helper/oneflow_helper.rb +423 -0
  34. data/lib/one_helper/oneflowtemplate_helper.rb +312 -0
  35. data/lib/one_helper/onegroup_helper.rb +1 -1
  36. data/lib/one_helper/onehook_helper.rb +1 -1
  37. data/lib/one_helper/onehost_helper.rb +148 -68
  38. data/lib/one_helper/oneimage_helper.rb +2 -2
  39. data/lib/one_helper/onemarket_helper.rb +1 -1
  40. data/lib/one_helper/onemarketapp_helper.rb +1 -1
  41. data/lib/one_helper/oneprovision_helper.rb +104 -60
  42. data/lib/one_helper/onequota_helper.rb +1 -1
  43. data/lib/one_helper/onesecgroup_helper.rb +1 -1
  44. data/lib/one_helper/onetemplate_helper.rb +9 -180
  45. data/lib/one_helper/oneuser_helper.rb +1 -1
  46. data/lib/one_helper/onevcenter_helper.rb +5 -4
  47. data/lib/one_helper/onevdc_helper.rb +1 -1
  48. data/lib/one_helper/onevm_helper.rb +117 -21
  49. data/lib/one_helper/onevmgroup_helper.rb +1 -1
  50. data/lib/one_helper/onevnet_helper.rb +66 -2
  51. data/lib/one_helper/onevntemplate_helper.rb +1 -1
  52. data/lib/one_helper/onevrouter_helper.rb +1 -1
  53. data/lib/one_helper/onezone_helper.rb +3 -1
  54. metadata +8 -6
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
4
+ # Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
@@ -27,7 +27,9 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- Gem.use_paths(GEMS_LOCATION)
30
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
+ require 'rubygems'
32
+ Gem.use_paths(File.realpath(GEMS_LOCATION))
31
33
  end
32
34
 
33
35
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
4
+ # Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
@@ -27,7 +27,9 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- Gem.use_paths(GEMS_LOCATION)
30
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
+ require 'rubygems'
32
+ Gem.use_paths(File.realpath(GEMS_LOCATION))
31
33
  end
32
34
 
33
35
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -71,6 +73,13 @@ CommandParser::CmdParser.new(ARGV) do
71
73
  :description => 'lock all actions'
72
74
  }
73
75
 
76
+ FORCE = {
77
+ :name => 'force',
78
+ :large => '--force',
79
+ :description => 'Force execution of action, ' \
80
+ 'bypass the consistency checks'
81
+ }
82
+
74
83
  ########################################################################
75
84
  # Global Options
76
85
  ########################################################################
@@ -169,9 +178,9 @@ CommandParser::CmdParser.new(ARGV) do
169
178
  Removes an address range from the Virtual Network
170
179
  EOT
171
180
 
172
- command :rmar, rmar_desc, :vnetid, :ar_id do
181
+ command :rmar, rmar_desc, :vnetid, :ar_id, :options => FORCE do
173
182
  helper.perform_action(args[0], options, 'address range removed') do |vn|
174
- vn.rm_ar(args[1])
183
+ vn.rm_ar(args[1], options[:force] || false)
175
184
  end
176
185
  end
177
186
 
@@ -342,43 +351,9 @@ CommandParser::CmdParser.new(ARGV) do
342
351
  Update Address Range variables. SIZE, IP, MAC and TYPE cannot be updated
343
352
  EOT
344
353
 
345
- command :updatear, update_ar_desc, :vnetid, :ar_id, [:file, nil] do
346
- helper.perform_action(args[0], options, 'modified') do |obj|
347
- rc = obj.info
348
-
349
- if OpenNebula.is_error?(rc)
350
- puts rc.message
351
- exit(-1)
352
- end
353
-
354
- obj.delete_element("AR_POOL/AR[AR_ID!=#{args[1]}]")
355
- obj.delete_element('AR_POOL/AR/LEASES')
356
- obj.delete_element('AR_POOL/AR/USED_LEASES')
357
- obj.delete_element('AR_POOL/AR/MAC_END')
358
- obj.delete_element('AR_POOL/AR/IP_END')
359
- obj.delete_element('AR_POOL/AR/IP6_ULA')
360
- obj.delete_element('AR_POOL/AR/IP6_ULA_END')
361
- obj.delete_element('AR_POOL/AR/IP6_GLOBAL')
362
- obj.delete_element('AR_POOL/AR/IP6_GLOBAL_END')
363
-
364
- if obj.template_like_str('AR_POOL').empty?
365
- puts "Address Range #{args[1]} does not exist for " \
366
- "Virtual Network #{args[0]}"
367
- exit(-1)
368
- end
369
-
370
- str = OpenNebulaHelper.update_template_helper(false,
371
- args[0],
372
- obj,
373
- args[2],
374
- 'AR_POOL',
375
- false)
376
-
377
- helper.set_client(options)
378
- obj = helper.retrieve_resource(obj.id)
379
-
380
- obj.update_ar(str)
381
- end
354
+ command :updatear, update_ar_desc, :vnetid, :ar_id, [:file, nil],
355
+ :options => OpenNebulaHelper::APPEND do
356
+ helper.update_ar(args[0], args[1], args[2], options)
382
357
  end
383
358
 
384
359
  rename_desc = <<-EOT.unindent
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
4
+ # Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
@@ -27,7 +27,9 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- Gem.use_paths(GEMS_LOCATION)
30
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
+ require 'rubygems'
32
+ Gem.use_paths(File.realpath(GEMS_LOCATION))
31
33
  end
32
34
 
33
35
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
4
+ # Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
@@ -27,7 +27,9 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- Gem.use_paths(GEMS_LOCATION)
30
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
+ require 'rubygems'
32
+ Gem.use_paths(File.realpath(GEMS_LOCATION))
31
33
  end
32
34
 
33
35
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
4
+ # Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
@@ -27,7 +27,9 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- Gem.use_paths(GEMS_LOCATION)
30
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
+ require 'rubygems'
32
+ Gem.use_paths(File.realpath(GEMS_LOCATION))
31
33
  end
32
34
 
33
35
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -230,6 +232,9 @@ CommandParser::CmdParser.new(ARGV) do
230
232
 
231
233
  command :serversync, sync_desc, :server, :options => [DATABASE] do
232
234
  begin
235
+ # Suppress augeas require warning message
236
+ $VERBOSE = nil
237
+
233
238
  gem 'augeas', '~> 0.6'
234
239
  require 'augeas'
235
240
  rescue Gem::LoadError
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -181,9 +181,15 @@ module CLIHelper
181
181
  ANSI_YELLOW = "\33[33m"
182
182
 
183
183
  # CLI states
184
- OK_STATES = %w[runn rdy on configured SUCCESS]
185
- BAD_STATES = %w[fail err error ERROR]
186
- REGULAR_STATES = %w[pending]
184
+ OK_STATES = %w[runn rdy on configured SUCCESS RUNNING]
185
+ BAD_STATES = %w[fail
186
+ err
187
+ error
188
+ ERROR
189
+ FAILED_DEPLOYING
190
+ FAILED_UNDEPLOYING
191
+ FAILED_SCALING]
192
+ REGULAR_STATES = %w[pending WARNING]
187
193
 
188
194
  # Set state color
189
195
  #
@@ -350,6 +356,12 @@ module CLIHelper
350
356
  # @param options [Hash] Object with CLI user options
351
357
  # @param top [Boolean] True to not update columns again
352
358
  def show(data, options = {}, top = false)
359
+ if options[:list]
360
+ @cli_columns = options[:list].collect {|o| o.upcase.to_sym }
361
+ else
362
+ @cli_columns = @default_columns
363
+ end
364
+
353
365
  update_columns(options) unless top
354
366
 
355
367
  if data.is_a? Hash
@@ -471,7 +483,7 @@ module CLIHelper
471
483
 
472
484
  # Get header in string format
473
485
  def header_str
474
- @default_columns.collect do |c|
486
+ @cli_columns.collect do |c|
475
487
  if @columns[c]
476
488
  format_str(c, c.to_s)
477
489
  else
@@ -489,12 +501,12 @@ module CLIHelper
489
501
 
490
502
  update_columns_size(options)
491
503
 
504
+ options[:csv_del] ? del = options[:csv_del] : del = ','
505
+
492
506
  if !options[:csv] && (!options.key? :no_header)
493
507
  CLIHelper.print_header(header_str)
494
- end
495
-
496
- if options[:csv] && (!options.key? :no_header)
497
- print_csv_data([@default_columns], options[:csv_del])
508
+ elsif options[:csv] && (!options.key? :no_header)
509
+ puts CSV.generate_line(@cli_columns, :col_sep => del)
498
510
  end
499
511
 
500
512
  @res_data ? print_data(@res_data, options) : puts
@@ -522,7 +534,13 @@ module CLIHelper
522
534
  del ? del = del : del = ','
523
535
 
524
536
  data.each do |l|
525
- puts CSV.generate_line(l, :col_sep => del)
537
+ result = []
538
+
539
+ @cli_columns.each do |col|
540
+ result << l[@default_columns.index(col)]
541
+ end
542
+
543
+ puts CSV.generate_line(result, :col_sep => del)
526
544
  end
527
545
  end
528
546
 
@@ -531,25 +549,26 @@ module CLIHelper
531
549
  # @param data [Array] Array with data to show
532
550
  # @param stat_column [String] Name of the state column
533
551
  def print_normal_data(data, stat_column)
534
- ncolumns = @default_columns.length
535
-
536
552
  if stat_column
537
- stat = stat_column.upcase.to_sym
538
- stat_column = @default_columns.index(stat)
553
+ stat = stat_column.upcase.to_sym
539
554
  else
540
- stat_column = @default_columns.index(:STAT)
555
+ stat = :STAT
541
556
  end
542
557
 
543
558
  data.each do |l|
544
559
  result = []
545
560
 
546
- ncolumns.times do |i|
561
+ @cli_columns.each do |col|
562
+ i = @default_columns.index(col)
563
+
564
+ # Column might not exist
565
+ next unless i
566
+
547
567
  dat = l[i]
548
- col = @default_columns[i]
549
568
 
550
569
  str = format_str(col, dat)
551
570
 
552
- str = CLIHelper.color_state(str) if i == stat_column
571
+ str = CLIHelper.color_state(str) if col == stat
553
572
 
554
573
  result << str
555
574
  end
@@ -564,8 +583,17 @@ module CLIHelper
564
583
  #
565
584
  # @return [Array] Array with selected columns information
566
585
  def data_array(data, options)
586
+ # Take default table columns and desired ones by the user
587
+ cols = @default_columns
588
+
589
+ @cli_columns.each do |col|
590
+ next if @default_columns.include?(col)
591
+
592
+ @default_columns.insert(@cli_columns.index(col) + 1, col)
593
+ end
594
+
567
595
  res_data = data.collect do |d|
568
- @default_columns.collect do |c|
596
+ cols.collect do |c|
569
597
  @columns[c][:proc].call(d).to_s if @columns[c]
570
598
  end
571
599
  end
@@ -602,7 +630,7 @@ module CLIHelper
602
630
  def config_expand_data
603
631
  ret = []
604
632
 
605
- @default_columns.each do |column|
633
+ @cli_columns.each do |column|
606
634
  expand_c = @columns[column][:expand]
607
635
 
608
636
  next unless expand_c
@@ -623,7 +651,7 @@ module CLIHelper
623
651
  def config_adjust_data
624
652
  ret = []
625
653
 
626
- @default_columns.each do |column|
654
+ @cli_columns.each do |column|
627
655
  next unless @columns[column][:adjust]
628
656
 
629
657
  ret << column.to_s.downcase
@@ -647,13 +675,13 @@ module CLIHelper
647
675
 
648
676
  return if terminal_size.nil?
649
677
 
650
- default_columns = columns_info(@default_columns)
678
+ default_columns = columns_info(@cli_columns)
651
679
  expand_columns = columns_info(expand_columns)
652
680
 
653
681
  total_size = total_columns_size(default_columns)
654
682
  columns_size = total_columns_size(expand_columns)
655
683
 
656
- terminal_size -= (@default_columns.size - 1)
684
+ terminal_size -= (@cli_columns.size - 1)
657
685
  left_size = terminal_size - total_size
658
686
  remaining_size = left_size
659
687
 
@@ -725,7 +753,7 @@ module CLIHelper
725
753
  expand_data = []
726
754
 
727
755
  if expand_all
728
- expand_data = @default_columns
756
+ expand_data = @cli_columns
729
757
  elsif expand
730
758
  expand_data += options[:expand]
731
759
  end
@@ -739,7 +767,7 @@ module CLIHelper
739
767
  unless expand_all
740
768
  adjust.each do |column|
741
769
  column = column.upcase.to_sym
742
- size = max_size(@default_columns.index(column))
770
+ size = max_size(@cli_columns.index(column))
743
771
 
744
772
  if size && size > @columns[column][:size]
745
773
  @columns[column][:adjust] = true
@@ -791,10 +819,6 @@ module CLIHelper
791
819
  rescue StandardError => e
792
820
  CLIHelper.fail(e.message)
793
821
  end
794
-
795
- return unless options[:list]
796
-
797
- @default_columns = options[:list].collect {|o| o.upcase.to_sym }
798
822
  end
799
823
 
800
824
  # Filter data
@@ -815,7 +839,7 @@ module CLIHelper
815
839
  m = s.match(/^(.*?)#{operators}(.*?)$/)
816
840
 
817
841
  if m
818
- index = @default_columns.index(m[1].to_sym)
842
+ index = @default_columns.index(m[1].upcase.to_sym)
819
843
 
820
844
  if index
821
845
  {
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -140,6 +140,7 @@ module CommandParser
140
140
  # @option options [String] :name
141
141
  # @option options [String] :short
142
142
  # @option options [String] :large
143
+ # @option options [Boolean] :multiple
143
144
  # @option options [String] :description
144
145
  # @option options [Class] :format
145
146
  # @option options [Block] :proc The block receives the value of the
@@ -294,6 +295,11 @@ module CommandParser
294
295
  cmd[:arity]+=1 unless args.include?(nil)
295
296
  cmd[:args_format] << args
296
297
  elsif args.instance_of?(Hash) && args[:options]
298
+ if args[:options].is_a? Array
299
+ args[:options].flatten!
300
+ args[:options] = args[:options].sort_by {|o| o[:name] }
301
+ end
302
+
297
303
  cmd[:options] << args[:options]
298
304
  else
299
305
  cmd[:arity]+=1
@@ -452,7 +458,7 @@ module CommandParser
452
458
 
453
459
  if comm.nil?
454
460
  print_help
455
- exit -1
461
+ exit 0
456
462
  end
457
463
 
458
464
  if comm[:deprecated]
@@ -463,16 +469,27 @@ module CommandParser
463
469
  parse(extra_options)
464
470
 
465
471
  if comm
466
- @before_proc.call if @before_proc
472
+ begin
473
+ @before_proc.call if @before_proc
474
+ rescue StandardError => e
475
+ STDERR.puts e.message
476
+ exit(-1)
477
+ end
467
478
 
468
479
  check_args!(comm_name, comm[:arity], comm[:args_format])
469
480
 
470
- rc = comm[:proc].call
471
- if rc.instance_of?(Array)
472
- puts rc[1]
473
- exit rc.first
474
- else
475
- exit(@exit_code || rc)
481
+ begin
482
+ rc = comm[:proc].call
483
+
484
+ if rc.instance_of?(Array)
485
+ puts rc[1]
486
+ exit rc.first
487
+ else
488
+ exit(@exit_code || rc)
489
+ end
490
+ rescue StandardError => e
491
+ STDERR.puts e.message
492
+ exit(-1)
476
493
  end
477
494
  end
478
495
  end
@@ -490,21 +507,28 @@ module CommandParser
490
507
  args = []
491
508
  args << e[:short] if e[:short]
492
509
  args << e[:large]
510
+ args << e[:multiple] if e[:multiple]
493
511
  args << e[:format]
494
512
  args << e[:description]
495
513
 
496
514
  opts.on(*args) do |o|
497
- if e[:proc]
515
+ if e[:proc] && !e[:multiple]
498
516
  @options[e[:name].to_sym]=o
499
517
  with_proc<<e
500
518
  elsif e[:name]=="help"
501
519
  print_help
502
- exit
520
+ exit 0
503
521
  elsif e[:name]=="version"
504
522
  puts @version
505
- exit
506
- else
523
+ exit 0
524
+ elsif !e[:multiple]
507
525
  @options[e[:name].to_sym]=o
526
+ else
527
+ if @options[e[:name].to_sym].nil?
528
+ @options[e[:name].to_sym] = []
529
+ end
530
+
531
+ @options[e[:name].to_sym] << o
508
532
  end
509
533
  end
510
534
  end
@@ -630,7 +654,7 @@ module CommandParser
630
654
  print_formatters
631
655
  puts
632
656
  if @version
633
- puts "## LICENSE"
657
+ puts "## VERSION"
634
658
  puts @version
635
659
  end
636
660
  end
@@ -660,7 +684,9 @@ module CommandParser
660
684
  def print_options
661
685
  puts "## OPTIONS"
662
686
 
663
- shown_opts = Array.new
687
+ shown_opts = []
688
+ options = []
689
+
664
690
  @command_list.each do |key|
665
691
  value = @commands[key]
666
692
 
@@ -669,14 +695,17 @@ module CommandParser
669
695
  next
670
696
  else
671
697
  shown_opts << o[:name]
672
-
673
- print_option(o)
698
+ options << o
674
699
  end
675
700
  end
676
701
  end
677
702
 
678
- @available_options.each do |o|
679
- print_option o
703
+ options << @available_options
704
+ options.flatten!
705
+ options = options.sort_by {|o| o[:name] }
706
+
707
+ options.each do |o|
708
+ print_option(o)
680
709
  end
681
710
  end
682
711
 
@@ -705,6 +734,8 @@ module CommandParser
705
734
  else
706
735
  puts "## COMMANDS"
707
736
 
737
+ @command_list.sort! if @command_list
738
+
708
739
  @command_list.each do |key|
709
740
  value = @commands[key]
710
741
  printf cmd_format5, "* #{key} "
@@ -747,6 +778,9 @@ module CommandParser
747
778
 
748
779
  cmd_format5 = "#{' '*3}%s"
749
780
  cmd_format10 = "#{' '*8}%s"
781
+
782
+ @formats = @formats.sort_by {|key, _| key } if @formats
783
+
750
784
  @formats.each{ |key,value|
751
785
  printf cmd_format5, "* #{key}"
752
786
  puts