opennebula-cli 7.4.1 → 7.4.2
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 +4 -4
- data/bin/oneform +26 -39
- data/bin/oneuser +0 -2
- data/bin/onevm +24 -6
- data/bin/onevnet +95 -0
- data/lib/command_parser.rb +1 -2
- data/lib/ods_helper.rb +150 -46
- data/lib/one_helper/oneform_helper.rb +46 -5
- data/lib/one_helper/onegroup_helper.rb +1 -2
- data/lib/one_helper/onehost_helper.rb +35 -1
- data/lib/one_helper/oneimage_helper.rb +3 -3
- data/lib/one_helper/oneuser_helper.rb +1 -2
- data/lib/one_helper/onevm_helper.rb +11 -15
- data/lib/one_helper/onevnet_helper.rb +48 -0
- data/lib/one_helper.rb +9 -4
- data/share/schemas/xsd/host.xsd +4 -0
- data/share/schemas/xsd/opennebula_configuration.xsd +2 -0
- data/share/schemas/xsd/vm.xsd +2 -0
- data/share/schemas/xsd/vnet.xsd +102 -0
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 14c05f2cc71209cc247927e1ab5c4b1db6f5f7fa5bbdc557bc973616c82133d2
|
|
4
|
+
data.tar.gz: c6caf1dcaf934eace2c4abfe96627fe97b16c2def9027c36bb17cb160985b337
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bcb4e95506ee403a8bf99b9cbc861c624ff1d37e81a885c21d19f07f771926270cb39488925ec07a57b2c49ad43a80db6f1c291881792c119aa3933f138890c2
|
|
7
|
+
data.tar.gz: 589bd2f618df0a2732888d43617ad040526a91fbf08fc2ffb2c714454f13c84c983def1eecdaa561be6757728660ac2ec0b9607c1d1fc8f380d588d5890a06c0
|
data/bin/oneform
CHANGED
|
@@ -38,8 +38,6 @@ USER_AGENT = 'CLI'
|
|
|
38
38
|
require 'command_parser'
|
|
39
39
|
require 'one_helper'
|
|
40
40
|
require 'opennebula/oneform_client'
|
|
41
|
-
require 'tempfile'
|
|
42
|
-
|
|
43
41
|
require 'one_helper/oneform_helper'
|
|
44
42
|
|
|
45
43
|
CommandParser::CmdParser.new(ARGV) do
|
|
@@ -56,7 +54,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
56
54
|
:name => 'enabled',
|
|
57
55
|
:short => '-e',
|
|
58
56
|
:large => '--enabled',
|
|
59
|
-
:description => 'Show only enabled
|
|
57
|
+
:description => 'Show only enabled drivers',
|
|
60
58
|
:default => false
|
|
61
59
|
}
|
|
62
60
|
|
|
@@ -73,8 +71,10 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
73
71
|
command :list,
|
|
74
72
|
list_desc,
|
|
75
73
|
:options => FORMAT + CLIHelper::OPTIONS + [OpenNebulaHelper::DESCRIBE, ENABLED] do
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
helper.list(helper.client(options), options)
|
|
75
|
+
rescue Interrupt
|
|
76
|
+
puts
|
|
77
|
+
exit(1)
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
top_desc = <<-EOT.unindent
|
|
@@ -84,11 +84,11 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
84
84
|
command :top,
|
|
85
85
|
top_desc,
|
|
86
86
|
:options => FORMAT + [CLIHelper::DELAY, ENABLED] do
|
|
87
|
-
Signal.trap('INT') { exit(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
87
|
+
Signal.trap('INT') { exit(1) }
|
|
88
|
+
helper.top(helper.client(options), options)
|
|
89
|
+
rescue Interrupt
|
|
90
|
+
puts
|
|
91
|
+
exit(1)
|
|
92
92
|
end
|
|
93
93
|
|
|
94
94
|
show_desc = <<-EOT.unindent
|
|
@@ -96,9 +96,10 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
96
96
|
EOT
|
|
97
97
|
|
|
98
98
|
command :show, show_desc, :driver_name, :options => FORMAT do
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
helper.show(helper.client(options), args[0], options)
|
|
100
|
+
rescue Interrupt
|
|
101
|
+
puts
|
|
102
|
+
exit(1)
|
|
102
103
|
end
|
|
103
104
|
|
|
104
105
|
sync_desc = <<-EOT.unindent
|
|
@@ -106,14 +107,10 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
106
107
|
EOT
|
|
107
108
|
|
|
108
109
|
command :sync, sync_desc do
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
return [response[:err_code], response[:message]] \
|
|
114
|
-
if CloudClient.is_error?(response)
|
|
115
|
-
|
|
116
|
-
0
|
|
110
|
+
helper.sync(helper.client(options))
|
|
111
|
+
rescue Interrupt
|
|
112
|
+
puts
|
|
113
|
+
exit(1)
|
|
117
114
|
end
|
|
118
115
|
|
|
119
116
|
enable_desc = <<-EOT.unindent
|
|
@@ -121,15 +118,10 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
121
118
|
EOT
|
|
122
119
|
|
|
123
120
|
command :enable, enable_desc, :driver_name do
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return [response[:err_code], response[:message]] \
|
|
130
|
-
if CloudClient.is_error?(response)
|
|
131
|
-
|
|
132
|
-
0
|
|
121
|
+
helper.enable(helper.client(options), args[0])
|
|
122
|
+
rescue Interrupt
|
|
123
|
+
puts
|
|
124
|
+
exit(1)
|
|
133
125
|
end
|
|
134
126
|
|
|
135
127
|
disable_desc = <<-EOT.unindent
|
|
@@ -137,14 +129,9 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
137
129
|
EOT
|
|
138
130
|
|
|
139
131
|
command :disable, disable_desc, :driver_name do
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
return [response[:err_code], response[:message]] \
|
|
146
|
-
if CloudClient.is_error?(response)
|
|
147
|
-
|
|
148
|
-
0
|
|
132
|
+
helper.disable(helper.client(options), args[0])
|
|
133
|
+
rescue Interrupt
|
|
134
|
+
puts
|
|
135
|
+
exit(1)
|
|
149
136
|
end
|
|
150
137
|
end
|
data/bin/oneuser
CHANGED
|
@@ -773,13 +773,11 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
773
773
|
auth_string = "#{user['NAME']}:#{token}"
|
|
774
774
|
auth_file = helper.auth_file(auth_string)
|
|
775
775
|
|
|
776
|
-
# rubocop:disable Lint/SuppressedException
|
|
777
776
|
begin
|
|
778
777
|
File.unlink(auth_file)
|
|
779
778
|
puts "Removing #{auth_file}"
|
|
780
779
|
rescue Errno::ENOENT
|
|
781
780
|
end
|
|
782
|
-
# rubocop:enable Lint/SuppressedException
|
|
783
781
|
|
|
784
782
|
0
|
|
785
783
|
end
|
data/bin/onevm
CHANGED
|
@@ -237,6 +237,13 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
237
237
|
:description => 'Select PCI device by its class ID'
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
+
PF = {
|
|
241
|
+
:name => 'pf',
|
|
242
|
+
:large => '--pf interface',
|
|
243
|
+
:format => String,
|
|
244
|
+
:description => 'Select a virtual function by its parent PF interface name'
|
|
245
|
+
}
|
|
246
|
+
|
|
240
247
|
RESET_BACKUP = {
|
|
241
248
|
:name => 'reset',
|
|
242
249
|
:large => '--reset',
|
|
@@ -659,10 +666,10 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
659
666
|
end
|
|
660
667
|
|
|
661
668
|
migrate_desc = <<-EOT.unindent
|
|
662
|
-
Migrates the given
|
|
669
|
+
Migrates the given VM to another Host. If used with --live
|
|
663
670
|
parameter the migration is done without downtime.
|
|
664
671
|
|
|
665
|
-
States: RUNNING
|
|
672
|
+
States: RUNNING, SUSPENDED, POWEROFF
|
|
666
673
|
EOT
|
|
667
674
|
|
|
668
675
|
command :migrate, migrate_desc, [:range, :vmid_list], :hostid,
|
|
@@ -867,6 +874,8 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
867
874
|
To hotplug a PCI device and use it as a NIC interface in the VM select
|
|
868
875
|
it with --pci (short_address) or --pci_device (device ID),
|
|
869
876
|
--pci_class (class ID) and/or --pci_vendor (vendor ID).
|
|
877
|
+
Use --pf (interface name) to select a virtual function from a physical
|
|
878
|
+
function. Specify the virtual network with --network.
|
|
870
879
|
|
|
871
880
|
States: RUNNING, POWEROFF
|
|
872
881
|
EOT
|
|
@@ -881,7 +890,8 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
881
890
|
PCI,
|
|
882
891
|
PCI_CLASS,
|
|
883
892
|
PCI_VENDOR,
|
|
884
|
-
PCI_DEVICE
|
|
893
|
+
PCI_DEVICE,
|
|
894
|
+
PF
|
|
885
895
|
] do
|
|
886
896
|
if options[:file]
|
|
887
897
|
template = File.read(options[:file])
|
|
@@ -893,7 +903,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
893
903
|
nic_alias = options[:alias]
|
|
894
904
|
nic_name = options[:nic_name]
|
|
895
905
|
|
|
896
|
-
is_pci = [:pci, :pci_device, :pci_vendor, :pci_class].any? do |o|
|
|
906
|
+
is_pci = [:pci, :pci_device, :pci_vendor, :pci_class, :pf].any? do |o|
|
|
897
907
|
!options[o].nil?
|
|
898
908
|
end
|
|
899
909
|
|
|
@@ -902,6 +912,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
902
912
|
pcid = options[:pci_device]
|
|
903
913
|
pcic = options[:pci_class]
|
|
904
914
|
pciv = options[:pci_vendor]
|
|
915
|
+
pf = options[:pf]
|
|
905
916
|
|
|
906
917
|
template = 'PCI = [ TYPE = NIC'
|
|
907
918
|
template << ", NETWORK_ID = #{network_id}"
|
|
@@ -909,6 +920,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
909
920
|
template << ", DEVICE = \"#{pcid}\"" if pcid
|
|
910
921
|
template << ", CLASS = \"#{pcic}\"" if pcic
|
|
911
922
|
template << ", VENDOR = \"#{pciv}\"" if pciv
|
|
923
|
+
template << ", PF_IFNAME = \"#{pf}\"" if pf
|
|
912
924
|
elsif nic_alias
|
|
913
925
|
template = "NIC_ALIAS = [ PARENT = #{nic_alias}"
|
|
914
926
|
template << ", NETWORK_ID = #{network_id}"
|
|
@@ -946,7 +958,13 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
946
958
|
end
|
|
947
959
|
|
|
948
960
|
nic_update_desc = <<-EOT.unindent
|
|
949
|
-
Updates
|
|
961
|
+
Updates the QoS attributes of a VM NIC. If the VM is running, also updates the NIC
|
|
962
|
+
on the host.
|
|
963
|
+
|
|
964
|
+
Only the following attributes can be updated:
|
|
965
|
+
INBOUND_AVG_BW, INBOUND_PEAK_BW, INBOUND_PEAK_KB,
|
|
966
|
+
OUTBOUND_AVG_BW, OUTBOUND_PEAK_BW, OUTBOUND_PEAK_KB.
|
|
967
|
+
Other NIC attributes are ignored.
|
|
950
968
|
|
|
951
969
|
States: Almost all, except BOOT*, MIGRATE and HOTPLUG-NIC
|
|
952
970
|
EOT
|
|
@@ -1448,7 +1466,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
1448
1466
|
RAW = ["DATA", "TYPE", "VALIDATE"]
|
|
1449
1467
|
CPU_MODEL = ["MODEL", "FEATURES"]
|
|
1450
1468
|
BACKUP_CONFIG = ["FS_FREEZE", "KEEP_LAST", "BACKUP_VOLATILE", "MODE", "INCREMENT_MODE", "INTERACTIVE"]
|
|
1451
|
-
CONTEXT (any value, ETH* if CONTEXT_ALLOW_ETH_UPDATES set in oned.conf, **variable substitution will be made**)
|
|
1469
|
+
CONTEXT (any value, ETH* if NETWORK is not YES or CONTEXT_ALLOW_ETH_UPDATES set in oned.conf, **variable substitution will be made**)
|
|
1452
1470
|
EOT
|
|
1453
1471
|
|
|
1454
1472
|
command :updateconf, updateconf_desc, :vmid, [:file, nil],
|
data/bin/onevnet
CHANGED
|
@@ -474,4 +474,99 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
474
474
|
vn.recover(result)
|
|
475
475
|
end
|
|
476
476
|
end
|
|
477
|
+
|
|
478
|
+
mirror_create_desc = <<-EOT.unindent
|
|
479
|
+
Creates a traffic mirror on the Virtual Network
|
|
480
|
+
EOT
|
|
481
|
+
|
|
482
|
+
command :'mirror-create', mirror_create_desc, :vnetid, [:file, nil] do
|
|
483
|
+
helper.perform_action(args[0], options, 'mirror created') do |vn|
|
|
484
|
+
template = args[1] ? File.read(args[1]) : OpenNebulaHelper.read_stdin
|
|
485
|
+
|
|
486
|
+
if template.empty?
|
|
487
|
+
STDERR.puts 'A mirror template must be provided as a file or on stdin'
|
|
488
|
+
exit(-1)
|
|
489
|
+
end
|
|
490
|
+
|
|
491
|
+
mirror_id = vn.mirror_create(template)
|
|
492
|
+
|
|
493
|
+
puts "Mirror ID: #{mirror_id}" unless OpenNebula.is_error?(mirror_id)
|
|
494
|
+
|
|
495
|
+
mirror_id
|
|
496
|
+
end
|
|
497
|
+
end
|
|
498
|
+
|
|
499
|
+
mirror_update_desc = <<-EOT.unindent
|
|
500
|
+
Updates traffic mirror configuration. Use mirror-addport and
|
|
501
|
+
mirror-delport to change selected VM NICs. If a path is not provided,
|
|
502
|
+
the editor will be launched with the current mirror configuration.
|
|
503
|
+
EOT
|
|
504
|
+
|
|
505
|
+
command :'mirror-update', mirror_update_desc, :vnetid, :mirror_id,
|
|
506
|
+
[:file, nil], :options => OpenNebulaHelper::APPEND do
|
|
507
|
+
begin
|
|
508
|
+
mirror_id = Integer(args[1], 10)
|
|
509
|
+
rescue ArgumentError, TypeError
|
|
510
|
+
STDERR.puts "Invalid mirror ID: #{args[1]}"
|
|
511
|
+
exit(-1)
|
|
512
|
+
end
|
|
513
|
+
|
|
514
|
+
helper.perform_action(args[0], options, 'mirror updated') do |vn|
|
|
515
|
+
if args[2]
|
|
516
|
+
template = File.read(args[2])
|
|
517
|
+
elsif !(stdin = OpenNebulaHelper.read_stdin).empty?
|
|
518
|
+
template = stdin
|
|
519
|
+
else
|
|
520
|
+
rc = vn.info
|
|
521
|
+
|
|
522
|
+
if OpenNebula.is_error?(rc)
|
|
523
|
+
STDERR.puts rc.message
|
|
524
|
+
exit(-1)
|
|
525
|
+
end
|
|
526
|
+
|
|
527
|
+
template = vn.template_like_str(
|
|
528
|
+
'TEMPLATE', true, "MIRROR[MIRROR_ID=#{mirror_id}]"
|
|
529
|
+
)
|
|
530
|
+
|
|
531
|
+
if template.empty?
|
|
532
|
+
STDERR.puts "MIRROR_ID #{mirror_id} does not exist"
|
|
533
|
+
exit(-1)
|
|
534
|
+
end
|
|
535
|
+
|
|
536
|
+
template = OpenNebulaHelper.editor_input(template)
|
|
537
|
+
end
|
|
538
|
+
|
|
539
|
+
vn.mirror_update(mirror_id, template, options[:append])
|
|
540
|
+
end
|
|
541
|
+
end
|
|
542
|
+
|
|
543
|
+
mirror_addport_desc = <<-EOT.unindent
|
|
544
|
+
Adds a comma-separated VM_ID:NIC_ID list to a traffic mirror
|
|
545
|
+
EOT
|
|
546
|
+
|
|
547
|
+
command :'mirror-addport', mirror_addport_desc, :vnetid, :mirror_id, :ports do
|
|
548
|
+
helper.perform_action(args[0], options, 'mirror ports added') do |vn|
|
|
549
|
+
vn.mirror_addport(args[1], args[2])
|
|
550
|
+
end
|
|
551
|
+
end
|
|
552
|
+
|
|
553
|
+
mirror_delport_desc = <<-EOT.unindent
|
|
554
|
+
Removes a comma-separated VM_ID:NIC_ID list from a traffic mirror
|
|
555
|
+
EOT
|
|
556
|
+
|
|
557
|
+
command :'mirror-delport', mirror_delport_desc, :vnetid, :mirror_id, :ports do
|
|
558
|
+
helper.perform_action(args[0], options, 'mirror ports removed') do |vn|
|
|
559
|
+
vn.mirror_delport(args[1], args[2])
|
|
560
|
+
end
|
|
561
|
+
end
|
|
562
|
+
|
|
563
|
+
mirror_delete_desc = <<-EOT.unindent
|
|
564
|
+
Deletes a traffic mirror from the Virtual Network
|
|
565
|
+
EOT
|
|
566
|
+
|
|
567
|
+
command :'mirror-delete', mirror_delete_desc, :vnetid, :mirror_id do
|
|
568
|
+
helper.perform_action(args[0], options, 'mirror deleted') do |vn|
|
|
569
|
+
vn.mirror_delete(args[1])
|
|
570
|
+
end
|
|
571
|
+
end
|
|
477
572
|
end
|
data/lib/command_parser.rb
CHANGED
|
@@ -97,9 +97,8 @@ module CommandParser
|
|
|
97
97
|
# @param [String] str
|
|
98
98
|
def usage(str)
|
|
99
99
|
@usage = str
|
|
100
|
-
# rubocop:disable Naming/MemoizedInstanceVariableName
|
|
100
|
+
# rubocop:disable-next Naming/MemoizedInstanceVariableName
|
|
101
101
|
@name ||= @usage.split(' ').first
|
|
102
|
-
# rubocop:enable Naming/MemoizedInstanceVariableName
|
|
103
102
|
end
|
|
104
103
|
|
|
105
104
|
# Defines the version the command
|
data/lib/ods_helper.rb
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
#--------------------------------------------------------------------------- #
|
|
16
16
|
require 'tempfile'
|
|
17
17
|
require 'json'
|
|
18
|
+
require 'io/console'
|
|
18
19
|
require 'yaml'
|
|
19
20
|
|
|
20
21
|
require 'one_helper'
|
|
@@ -203,27 +204,54 @@ class ODSHelper < OpenNebulaHelper::OneHelper
|
|
|
203
204
|
type = normalize_input_type(input[:type])
|
|
204
205
|
default = input[:default]
|
|
205
206
|
match = input[:match]
|
|
207
|
+
mandatory = input.fetch(:mandatory, false)
|
|
208
|
+
sensitive = input.fetch(:sensitive, false)
|
|
206
209
|
|
|
207
210
|
puts " * (#{name}) #{description} [type: #{input[:type]}]"
|
|
208
211
|
|
|
209
212
|
header = ' '
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
213
|
+
if input.key?(:default)
|
|
214
|
+
value =
|
|
215
|
+
if sensitive
|
|
216
|
+
'<hidden>'
|
|
217
|
+
elsif default.is_a?(Array) || default.is_a?(Hash)
|
|
218
|
+
JSON.generate(default)
|
|
219
|
+
else
|
|
220
|
+
default.to_s
|
|
221
|
+
end
|
|
222
|
+
header += "Press enter for default (#{value}). "
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
loop do
|
|
226
|
+
answer =
|
|
227
|
+
if sensitive
|
|
228
|
+
ask_sensitive_input(header, default, type, match)
|
|
229
|
+
else
|
|
230
|
+
case type
|
|
231
|
+
when 'string'
|
|
232
|
+
ask_string_input(header, default, match)
|
|
233
|
+
when 'number'
|
|
234
|
+
ask_number_input(header, default, match)
|
|
235
|
+
when 'bool'
|
|
236
|
+
ask_bool_input(header, default)
|
|
237
|
+
when 'list', 'tuple'
|
|
238
|
+
ask_list_input(header, default, match)
|
|
239
|
+
when 'map', 'object'
|
|
240
|
+
ask_map_input(header, default)
|
|
241
|
+
else
|
|
242
|
+
STDERR.puts "Unknown input type '#{input[:type]}' for '#{name}'"
|
|
243
|
+
exit(-1)
|
|
244
|
+
end
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
if answer.nil? && mandatory
|
|
248
|
+
puts ' A value is required.'
|
|
249
|
+
next
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
answers[name] = answer unless answer.nil?
|
|
253
|
+
break
|
|
254
|
+
end
|
|
227
255
|
end
|
|
228
256
|
|
|
229
257
|
answers
|
|
@@ -262,7 +290,7 @@ class ODSHelper < OpenNebulaHelper::OneHelper
|
|
|
262
290
|
# Open the editor with JSON content and return the edited file path.
|
|
263
291
|
# @param prefix [String]
|
|
264
292
|
# @param content [Object]
|
|
265
|
-
# @return [String]
|
|
293
|
+
# @return [String, nil]
|
|
266
294
|
def self.open_json_editor(prefix, content)
|
|
267
295
|
tmp = Tempfile.new(prefix)
|
|
268
296
|
path = tmp.path
|
|
@@ -311,6 +339,8 @@ class ODSHelper < OpenNebulaHelper::OneHelper
|
|
|
311
339
|
raw = STDIN.readline.strip
|
|
312
340
|
|
|
313
341
|
if raw.empty?
|
|
342
|
+
return if default.nil?
|
|
343
|
+
|
|
314
344
|
answer = default
|
|
315
345
|
return answer if options.include?(answer)
|
|
316
346
|
else
|
|
@@ -334,7 +364,7 @@ class ODSHelper < OpenNebulaHelper::OneHelper
|
|
|
334
364
|
# @param header [String]
|
|
335
365
|
# @param default [Object]
|
|
336
366
|
# @param match [Hash, nil]
|
|
337
|
-
# @return [Integer, Float]
|
|
367
|
+
# @return [Integer, Float, nil]
|
|
338
368
|
def ask_number_input(header, default, match)
|
|
339
369
|
min = match&.dig(:values, :min)
|
|
340
370
|
max = match&.dig(:values, :max)
|
|
@@ -344,6 +374,8 @@ class ODSHelper < OpenNebulaHelper::OneHelper
|
|
|
344
374
|
print "#{header}Enter a number#{range_msg}: "
|
|
345
375
|
|
|
346
376
|
raw = STDIN.readline.strip
|
|
377
|
+
return if raw.empty? && default.nil?
|
|
378
|
+
|
|
347
379
|
raw = default.to_s if raw.empty?
|
|
348
380
|
|
|
349
381
|
if raw.match?(/\A-?\d+\z/)
|
|
@@ -365,11 +397,28 @@ class ODSHelper < OpenNebulaHelper::OneHelper
|
|
|
365
397
|
end
|
|
366
398
|
end
|
|
367
399
|
|
|
400
|
+
# Prompt for boolean input
|
|
401
|
+
# @param header [String]
|
|
402
|
+
# @param default [Object]
|
|
403
|
+
# @return [Boolean, nil]
|
|
404
|
+
def ask_bool_input(header, default)
|
|
405
|
+
loop do
|
|
406
|
+
print "#{header}Enter true or false: "
|
|
407
|
+
raw = STDIN.readline.strip
|
|
408
|
+
|
|
409
|
+
return default if raw.empty?
|
|
410
|
+
return true if ['true', 'yes'].include?(raw.downcase)
|
|
411
|
+
return false if ['false', 'no'].include?(raw.downcase)
|
|
412
|
+
|
|
413
|
+
puts ' Input must be true or false.'
|
|
414
|
+
end
|
|
415
|
+
end
|
|
416
|
+
|
|
368
417
|
# Prompt for list input
|
|
369
418
|
# @param header [String]
|
|
370
419
|
# @param default [Object]
|
|
371
420
|
# @param match [Hash, nil]
|
|
372
|
-
# @return [Array]
|
|
421
|
+
# @return [Array, nil]
|
|
373
422
|
def ask_list_input(header, default, match)
|
|
374
423
|
loop do
|
|
375
424
|
print "#{header}Enter comma-separated values: "
|
|
@@ -379,8 +428,7 @@ class ODSHelper < OpenNebulaHelper::OneHelper
|
|
|
379
428
|
if default.is_a?(Array)
|
|
380
429
|
return default
|
|
381
430
|
else
|
|
382
|
-
|
|
383
|
-
next
|
|
431
|
+
return
|
|
384
432
|
end
|
|
385
433
|
end
|
|
386
434
|
|
|
@@ -403,37 +451,100 @@ class ODSHelper < OpenNebulaHelper::OneHelper
|
|
|
403
451
|
# Prompt for map input
|
|
404
452
|
# @param header [String]
|
|
405
453
|
# @param default [Object]
|
|
406
|
-
# @return [Hash]
|
|
454
|
+
# @return [Hash, nil]
|
|
407
455
|
def ask_map_input(header, default)
|
|
408
456
|
loop do
|
|
409
|
-
print "#{header}Enter KEY=VALUE pairs separated by commas: "
|
|
457
|
+
print "#{header}Enter a JSON object or KEY=VALUE pairs separated by commas: "
|
|
410
458
|
raw = STDIN.readline.strip
|
|
411
459
|
|
|
412
460
|
if raw.empty?
|
|
413
461
|
if default.is_a?(Hash)
|
|
414
462
|
return default
|
|
415
463
|
else
|
|
416
|
-
|
|
417
|
-
next
|
|
464
|
+
return
|
|
418
465
|
end
|
|
419
466
|
end
|
|
420
467
|
|
|
421
|
-
|
|
422
|
-
|
|
468
|
+
rc, answer = ODSHelper.parse_values_option(raw)
|
|
469
|
+
return answer if rc.zero?
|
|
423
470
|
|
|
424
|
-
|
|
425
|
-
|
|
471
|
+
puts ' Invalid map format. Expected KEY=VALUE,... or a JSON object.'
|
|
472
|
+
end
|
|
473
|
+
end
|
|
426
474
|
|
|
427
|
-
|
|
428
|
-
|
|
475
|
+
# Prompt without echoing the entered value and coerce it to its declared type
|
|
476
|
+
# @param header [String]
|
|
477
|
+
# @param default [Object]
|
|
478
|
+
# @param type [String]
|
|
479
|
+
# @param match [Hash, nil]
|
|
480
|
+
# @return [Object, nil]
|
|
481
|
+
def ask_sensitive_input(header, default, type, match)
|
|
482
|
+
loop do
|
|
483
|
+
print "#{header}Enter a value: "
|
|
484
|
+
raw = read_sensitive_value
|
|
429
485
|
|
|
430
|
-
|
|
431
|
-
end
|
|
486
|
+
return default if raw.nil?
|
|
432
487
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
488
|
+
return coerce_user_input(raw, type, match)
|
|
489
|
+
rescue ArgumentError => e
|
|
490
|
+
puts " #{e.message}"
|
|
491
|
+
end
|
|
492
|
+
end
|
|
493
|
+
|
|
494
|
+
# Reads a value from the terminal without echoing it
|
|
495
|
+
# @return [String, nil]
|
|
496
|
+
def read_sensitive_value
|
|
497
|
+
value = STDIN.noecho(&:gets)
|
|
498
|
+
puts
|
|
499
|
+
|
|
500
|
+
value&.chomp.then {|item| item.to_s.empty? ? nil : item }
|
|
501
|
+
end
|
|
502
|
+
|
|
503
|
+
# Coerces raw input for prompts that cannot use the visible type helpers
|
|
504
|
+
# @param raw [String]
|
|
505
|
+
# @param type [String]
|
|
506
|
+
# @param match [Hash, nil]
|
|
507
|
+
# @return [Object]
|
|
508
|
+
def coerce_user_input(raw, type, match)
|
|
509
|
+
case type
|
|
510
|
+
when 'string'
|
|
511
|
+
values = match[:values] if match&.dig(:type) == 'list'
|
|
512
|
+
raise ArgumentError, 'Input is not one of the allowed values.' \
|
|
513
|
+
if values && !values.include?(raw)
|
|
514
|
+
|
|
515
|
+
raw
|
|
516
|
+
when 'number'
|
|
517
|
+
number = Integer(raw, :exception => false) || Float(raw, :exception => false)
|
|
518
|
+
raise ArgumentError, 'Input must be a number.' unless number
|
|
519
|
+
|
|
520
|
+
min = match&.dig(:values, :min)
|
|
521
|
+
max = match&.dig(:values, :max)
|
|
522
|
+
raise ArgumentError, "Input must be greater than or equal to #{min}." \
|
|
523
|
+
if min && number < min
|
|
524
|
+
raise ArgumentError, "Input must be less than or equal to #{max}." \
|
|
525
|
+
if max && number > max
|
|
526
|
+
|
|
527
|
+
number
|
|
528
|
+
when 'bool'
|
|
529
|
+
return true if ['true', 'yes'].include?(raw.downcase)
|
|
530
|
+
return false if ['false', 'no'].include?(raw.downcase)
|
|
531
|
+
|
|
532
|
+
raise ArgumentError, 'Input must be true or false.'
|
|
533
|
+
when 'list', 'tuple'
|
|
534
|
+
values = raw.split(',').map(&:strip).reject(&:empty?)
|
|
535
|
+
allowed = Array(match[:values]) if match&.dig(:type) == 'list'
|
|
536
|
+
invalid = values - allowed if allowed
|
|
537
|
+
raise ArgumentError, "Invalid values: #{invalid.join(', ')}" \
|
|
538
|
+
if invalid&.any?
|
|
539
|
+
|
|
540
|
+
values
|
|
541
|
+
when 'map', 'object'
|
|
542
|
+
rc, value = ODSHelper.parse_values_option(raw)
|
|
543
|
+
raise ArgumentError, value unless rc.zero?
|
|
544
|
+
|
|
545
|
+
value
|
|
546
|
+
else
|
|
547
|
+
raise ArgumentError, "Unknown input type '#{type}'"
|
|
437
548
|
end
|
|
438
549
|
end
|
|
439
550
|
|
|
@@ -441,14 +552,7 @@ class ODSHelper < OpenNebulaHelper::OneHelper
|
|
|
441
552
|
# @param type [String]
|
|
442
553
|
# @return [String]
|
|
443
554
|
def normalize_input_type(type)
|
|
444
|
-
|
|
445
|
-
when /\Amap\(/
|
|
446
|
-
'map'
|
|
447
|
-
when /\Alist\(/
|
|
448
|
-
'list'
|
|
449
|
-
else
|
|
450
|
-
type
|
|
451
|
-
end
|
|
555
|
+
type.to_s.downcase.gsub(/\(.*\)\z/, '')
|
|
452
556
|
end
|
|
453
557
|
|
|
454
558
|
#------------------------------------------------------
|
|
@@ -14,9 +14,13 @@
|
|
|
14
14
|
# limitations under the License. #
|
|
15
15
|
#--------------------------------------------------------------------------- #
|
|
16
16
|
|
|
17
|
+
require 'json'
|
|
18
|
+
require 'yaml'
|
|
19
|
+
|
|
17
20
|
require 'one_helper'
|
|
21
|
+
require 'cloud/CloudClient'
|
|
18
22
|
|
|
19
|
-
#
|
|
23
|
+
# OneForm driver command helper
|
|
20
24
|
class OneFormHelper < OpenNebulaHelper::OneHelper
|
|
21
25
|
|
|
22
26
|
# Configuration file
|
|
@@ -65,7 +69,9 @@ class OneFormHelper < OpenNebulaHelper::OneHelper
|
|
|
65
69
|
#
|
|
66
70
|
# @param client [OneForm::Client] Petition client
|
|
67
71
|
# @param options [Hash] CLI options
|
|
68
|
-
def
|
|
72
|
+
def list(client, options)
|
|
73
|
+
params = {}
|
|
74
|
+
params[:enabled] = true if options[:enabled]
|
|
69
75
|
response = client.list_drivers(params)
|
|
70
76
|
|
|
71
77
|
if CloudClient.is_error?(response)
|
|
@@ -90,7 +96,7 @@ class OneFormHelper < OpenNebulaHelper::OneHelper
|
|
|
90
96
|
#
|
|
91
97
|
# @param client [OneForm::Client] Petition client
|
|
92
98
|
# @param options [Hash] CLI options
|
|
93
|
-
def
|
|
99
|
+
def top(client, options)
|
|
94
100
|
options[:delay] ? delay = options[:delay] : delay = 4
|
|
95
101
|
|
|
96
102
|
begin
|
|
@@ -98,7 +104,7 @@ class OneFormHelper < OpenNebulaHelper::OneHelper
|
|
|
98
104
|
CLIHelper.scr_cls
|
|
99
105
|
CLIHelper.scr_move(0, 0)
|
|
100
106
|
|
|
101
|
-
|
|
107
|
+
list(client, options)
|
|
102
108
|
|
|
103
109
|
sleep delay
|
|
104
110
|
end
|
|
@@ -115,7 +121,7 @@ class OneFormHelper < OpenNebulaHelper::OneHelper
|
|
|
115
121
|
# @param client [OneForm::Client] Petition client
|
|
116
122
|
# @param driver_name [String] driver name
|
|
117
123
|
# @param options [Hash] CLI options
|
|
118
|
-
def
|
|
124
|
+
def show(client, driver_name, options)
|
|
119
125
|
response = client.get_driver(driver_name)
|
|
120
126
|
|
|
121
127
|
if CloudClient.is_error?(response)
|
|
@@ -252,4 +258,39 @@ class OneFormHelper < OpenNebulaHelper::OneHelper
|
|
|
252
258
|
end
|
|
253
259
|
end
|
|
254
260
|
|
|
261
|
+
# Synchronize installed drivers
|
|
262
|
+
#
|
|
263
|
+
# @param client [OneForm::Client] Petition client
|
|
264
|
+
# @return [Integer, Array] CLI result
|
|
265
|
+
def sync(client)
|
|
266
|
+
response = client.sync_drivers
|
|
267
|
+
return [response[:err_code], response[:message]] if CloudClient.is_error?(response)
|
|
268
|
+
|
|
269
|
+
0
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
# Enable a driver
|
|
273
|
+
#
|
|
274
|
+
# @param client [OneForm::Client] Petition client
|
|
275
|
+
# @param driver_name [String] Driver name
|
|
276
|
+
# @return [Integer, Array] CLI result
|
|
277
|
+
def enable(client, driver_name)
|
|
278
|
+
response = client.enable_driver(driver_name)
|
|
279
|
+
return [response[:err_code], response[:message]] if CloudClient.is_error?(response)
|
|
280
|
+
|
|
281
|
+
0
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
# Disable a driver
|
|
285
|
+
#
|
|
286
|
+
# @param client [OneForm::Client] Petition client
|
|
287
|
+
# @param driver_name [String] Driver name
|
|
288
|
+
# @return [Integer, Array] CLI result
|
|
289
|
+
def disable(client, driver_name)
|
|
290
|
+
response = client.disable_driver(driver_name)
|
|
291
|
+
return [response[:err_code], response[:message]] if CloudClient.is_error?(response)
|
|
292
|
+
|
|
293
|
+
0
|
|
294
|
+
end
|
|
295
|
+
|
|
255
296
|
end
|
|
@@ -67,7 +67,7 @@ class OneGroupHelper < OpenNebulaHelper::OneHelper
|
|
|
67
67
|
def format_pool(_options)
|
|
68
68
|
config_file = self.class.table_conf
|
|
69
69
|
|
|
70
|
-
# rubocop:disable Style/FormatStringToken
|
|
70
|
+
# rubocop:disable-next Style/FormatStringToken
|
|
71
71
|
CLIHelper::ShowTable.new(config_file, self) do
|
|
72
72
|
pool_default_quotas = lambda do |path|
|
|
73
73
|
limit = @data.dsearch('/GROUP_POOL/DEFAULT_GROUP_QUOTAS/'+path)
|
|
@@ -231,7 +231,6 @@ class OneGroupHelper < OpenNebulaHelper::OneHelper
|
|
|
231
231
|
|
|
232
232
|
default :ID, :NAME, :USERS, :VMS, :MEMORY, :CPU, :PCI
|
|
233
233
|
end
|
|
234
|
-
# rubocop:enable Style/FormatStringToken
|
|
235
234
|
end
|
|
236
235
|
|
|
237
236
|
# Parses a OpenNebula template string and turns it into a Hash
|
|
@@ -688,6 +688,33 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
|
|
|
688
688
|
end
|
|
689
689
|
|
|
690
690
|
def print_pcis(pcis)
|
|
691
|
+
total_vfs = Hash.new(0)
|
|
692
|
+
available_vfs = Hash.new(0)
|
|
693
|
+
|
|
694
|
+
pcis.each do |pci|
|
|
695
|
+
next unless pci['SRIOV'] == 'vf' && pci['PF_ADDRESS']
|
|
696
|
+
|
|
697
|
+
total_vfs[pci['PF_ADDRESS']] += 1
|
|
698
|
+
available_vfs[pci['PF_ADDRESS']] += 1 if pci['VMID'] == '-1'
|
|
699
|
+
end
|
|
700
|
+
|
|
701
|
+
pcis = pcis.map do |pci|
|
|
702
|
+
next pci unless pci['SRIOV'] == 'pf'
|
|
703
|
+
|
|
704
|
+
total = total_vfs[pci['ADDRESS']]
|
|
705
|
+
available = available_vfs[pci['ADDRESS']]
|
|
706
|
+
|
|
707
|
+
pci.merge('VFS' => "#{available}/#{total}")
|
|
708
|
+
end
|
|
709
|
+
|
|
710
|
+
extra_columns = {
|
|
711
|
+
:IFNAME => 'Network interface',
|
|
712
|
+
:SRIOV => 'SR-IOV role',
|
|
713
|
+
:PF_IFNAME => 'Parent PF interface',
|
|
714
|
+
:VFS => 'Available/total virtual functions',
|
|
715
|
+
:ESWITCH_MODE => 'Embedded switch mode'
|
|
716
|
+
}.select {|name, _| pcis.any? {|pci| pci.key?(name.to_s) } }
|
|
717
|
+
|
|
691
718
|
puts
|
|
692
719
|
CLIHelper.print_header('PCI DEVICES', false)
|
|
693
720
|
puts
|
|
@@ -721,7 +748,14 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
|
|
|
721
748
|
d['VENDOR_NAME']
|
|
722
749
|
end
|
|
723
750
|
|
|
724
|
-
|
|
751
|
+
extra_columns.each do |name, description|
|
|
752
|
+
column name, description, :size => name.to_s.length,
|
|
753
|
+
:left => true, :adjust => true do |d|
|
|
754
|
+
d[name.to_s] || '-'
|
|
755
|
+
end
|
|
756
|
+
end
|
|
757
|
+
|
|
758
|
+
default :VM, :ADDR, :TYPE, :NAME, *extra_columns.keys
|
|
725
759
|
end
|
|
726
760
|
|
|
727
761
|
table.show(pcis)
|
|
@@ -406,7 +406,7 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
|
|
|
406
406
|
''
|
|
407
407
|
end
|
|
408
408
|
end
|
|
409
|
-
column :ID, 'Snapshot ID', :size=>3 do |d|
|
|
409
|
+
column :ID, 'Snapshot ID', :adjust, :size=>3 do |d|
|
|
410
410
|
d['ID']
|
|
411
411
|
end
|
|
412
412
|
|
|
@@ -449,11 +449,11 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
|
|
|
449
449
|
|
|
450
450
|
def format_backup_increments(image)
|
|
451
451
|
table=CLIHelper::ShowTable.new(nil, self) do
|
|
452
|
-
column :ID, 'Increment ID', :size=>3 do |d|
|
|
452
|
+
column :ID, 'Increment ID', :adjust, :size=>3 do |d|
|
|
453
453
|
d['ID']
|
|
454
454
|
end
|
|
455
455
|
|
|
456
|
-
column :PID, 'Parent increment ID', :size=>3 do |d|
|
|
456
|
+
column :PID, 'Parent increment ID', :adjust, :size=>3 do |d|
|
|
457
457
|
d['PARENT_ID']
|
|
458
458
|
end
|
|
459
459
|
|
|
@@ -263,7 +263,7 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
|
|
|
263
263
|
def format_pool(options)
|
|
264
264
|
config_file = self.class.table_conf
|
|
265
265
|
|
|
266
|
-
# rubocop:disable Style/FormatStringToken
|
|
266
|
+
# rubocop:disable-next Style/FormatStringToken
|
|
267
267
|
CLIHelper::ShowTable.new(config_file, self) do
|
|
268
268
|
pool_default_quotas = lambda do |path|
|
|
269
269
|
limit = @data.dsearch('/USER_POOL/DEFAULT_USER_QUOTAS/'+path)
|
|
@@ -434,7 +434,6 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
|
|
|
434
434
|
|
|
435
435
|
default :ID, :NAME, :ENABLED, :GROUP, :AUTH, :VMS, :MEMORY, :CPU, :PCI
|
|
436
436
|
end
|
|
437
|
-
# rubocop:enable Style/FormatStringToken
|
|
438
437
|
end
|
|
439
438
|
|
|
440
439
|
def find_token(user, token, group = nil, show_expired = false)
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and #
|
|
14
14
|
# limitations under the License. #
|
|
15
15
|
#--------------------------------------------------------------------------- #
|
|
16
|
-
# rubocop:disable Naming/UncommunicativeMethodParamName
|
|
17
16
|
|
|
18
17
|
if !ONE_LOCATION
|
|
19
18
|
MAD_LOCATION = '/usr/lib/one/mads'
|
|
@@ -904,7 +903,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
|
904
903
|
puts
|
|
905
904
|
CLIHelper.print_header(str_h1 % 'VM DISKS', false)
|
|
906
905
|
CLIHelper::ShowTable.new(nil, self) do
|
|
907
|
-
column :ID, '', :size => 3 do |d|
|
|
906
|
+
column :ID, '', :adjust, :size => 3 do |d|
|
|
908
907
|
d['DISK_ID']
|
|
909
908
|
end
|
|
910
909
|
|
|
@@ -1064,7 +1063,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
|
1064
1063
|
end
|
|
1065
1064
|
|
|
1066
1065
|
CLIHelper::ShowTable.new(nil, self) do
|
|
1067
|
-
column :ID, '', :size => 3 do |d|
|
|
1066
|
+
column :ID, '', :adjust, :size => 3 do |d|
|
|
1068
1067
|
if d['DOUBLE_ENTRY']
|
|
1069
1068
|
''
|
|
1070
1069
|
else
|
|
@@ -1161,12 +1160,11 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
|
1161
1160
|
|
|
1162
1161
|
puts
|
|
1163
1162
|
|
|
1164
|
-
# rubocop:disable Layout/LineLength
|
|
1163
|
+
# rubocop:disable-next Layout/LineLength
|
|
1165
1164
|
CLIHelper.print_header(str_h1 % 'SECURITY GROUP TYPE PROTOCOL NETWORK RANGE ', false)
|
|
1166
|
-
# rubocop:enable Layout/LineLength
|
|
1167
1165
|
|
|
1168
1166
|
CLIHelper::ShowTable.new(nil, self) do
|
|
1169
|
-
column :ID, '', :size => 4 do |d|
|
|
1167
|
+
column :ID, '', :adjust, :size => 4 do |d|
|
|
1170
1168
|
d['SECURITY_GROUP_ID']
|
|
1171
1169
|
end
|
|
1172
1170
|
|
|
@@ -1189,7 +1187,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
|
1189
1187
|
protocol
|
|
1190
1188
|
end
|
|
1191
1189
|
|
|
1192
|
-
column :VNET, '', :size => 4 do |d|
|
|
1190
|
+
column :VNET, '', :adjust, :size => 4 do |d|
|
|
1193
1191
|
d['NETWORK_ID']
|
|
1194
1192
|
end
|
|
1195
1193
|
|
|
@@ -1357,12 +1355,12 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
|
1357
1355
|
|
|
1358
1356
|
def format_history(vm)
|
|
1359
1357
|
table = CLIHelper::ShowTable.new(nil, self) do
|
|
1360
|
-
column :SEQ, 'Sequence number', :size => 3 do |d|
|
|
1358
|
+
column :SEQ, 'Sequence number', :adjust, :size => 3 do |d|
|
|
1361
1359
|
d['SEQ']
|
|
1362
1360
|
end
|
|
1363
1361
|
|
|
1364
1362
|
column :UID, 'UID of the user that performed the action',
|
|
1365
|
-
:left, :size => 4 do |d|
|
|
1363
|
+
:left, :adjust, :size => 4 do |d|
|
|
1366
1364
|
if d['UID'] != '-1'
|
|
1367
1365
|
d['UID']
|
|
1368
1366
|
else
|
|
@@ -1387,7 +1385,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
|
1387
1385
|
VirtualMachine.get_history_action d['ACTION']
|
|
1388
1386
|
end
|
|
1389
1387
|
|
|
1390
|
-
column :DS, 'System Datastore', :size => 4 do |d|
|
|
1388
|
+
column :DS, 'System Datastore', :adjust, :size => 4 do |d|
|
|
1391
1389
|
d['DS_ID']
|
|
1392
1390
|
end
|
|
1393
1391
|
|
|
@@ -1439,11 +1437,11 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
|
1439
1437
|
''
|
|
1440
1438
|
end
|
|
1441
1439
|
end
|
|
1442
|
-
column :ID, 'Snapshot ID', :size => 3 do |d|
|
|
1440
|
+
column :ID, 'Snapshot ID', :adjust, :size => 3 do |d|
|
|
1443
1441
|
d['ID']
|
|
1444
1442
|
end
|
|
1445
1443
|
|
|
1446
|
-
column :DISK, 'Disk ID', :size => 4 do |d|
|
|
1444
|
+
column :DISK, 'Disk ID', :adjust, :size => 4 do |d|
|
|
1447
1445
|
d['DISK_ID']
|
|
1448
1446
|
end
|
|
1449
1447
|
|
|
@@ -1520,7 +1518,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
|
1520
1518
|
|
|
1521
1519
|
def format_template_snapshots(vm)
|
|
1522
1520
|
table = CLIHelper::ShowTable.new(nil, self) do
|
|
1523
|
-
column :ID, '', :size => 4 do |d|
|
|
1521
|
+
column :ID, '', :adjust, :size => 4 do |d|
|
|
1524
1522
|
d['SNAPSHOT_ID'] unless d.nil?
|
|
1525
1523
|
end
|
|
1526
1524
|
|
|
@@ -1541,5 +1539,3 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
|
1541
1539
|
end
|
|
1542
1540
|
|
|
1543
1541
|
end
|
|
1544
|
-
|
|
1545
|
-
# rubocop:enable Naming/UncommunicativeMethodParamName
|
|
@@ -133,6 +133,10 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
|
|
|
133
133
|
VLAN_ID
|
|
134
134
|
]
|
|
135
135
|
|
|
136
|
+
MIRROR_COLUMNS = [
|
|
137
|
+
'MIRROR_ID', 'NAME', 'TYPE', 'DIRECTION', 'VLANS', 'PORTS'
|
|
138
|
+
].freeze
|
|
139
|
+
|
|
136
140
|
def self.rname
|
|
137
141
|
'VNET'
|
|
138
142
|
end
|
|
@@ -349,6 +353,10 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
|
|
|
349
353
|
|
|
350
354
|
def format_resource(vn, options = {})
|
|
351
355
|
vn_hash = vn.to_hash
|
|
356
|
+
mirrors = [vn_hash['VNET']['TEMPLATE']['MIRROR']].flatten.compact
|
|
357
|
+
mirror_xpath = '/VNET/TEMPLATE/MIRROR'
|
|
358
|
+
|
|
359
|
+
vn.delete_element(mirror_xpath) while vn.has_elements?(mirror_xpath)
|
|
352
360
|
|
|
353
361
|
str_h1='%-80s'
|
|
354
362
|
CLIHelper.print_header(format(str_h1,
|
|
@@ -398,6 +406,46 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
|
|
|
398
406
|
|
|
399
407
|
puts vn.template_str(false)
|
|
400
408
|
|
|
409
|
+
unless mirrors.empty?
|
|
410
|
+
puts
|
|
411
|
+
CLIHelper.print_header(format(str_h1, 'MIRRORS'), false)
|
|
412
|
+
|
|
413
|
+
CLIHelper::ShowTable.new(nil, self) do
|
|
414
|
+
column :ID, '', :adjust, :size => 3 do |d|
|
|
415
|
+
d['MIRROR_ID']
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
column :NAME, '', :left, :adjust, :size => 12 do |d|
|
|
419
|
+
d['NAME']
|
|
420
|
+
end
|
|
421
|
+
|
|
422
|
+
column :TYPE, '', :left, :size => 7 do |d|
|
|
423
|
+
d['TYPE']
|
|
424
|
+
end
|
|
425
|
+
|
|
426
|
+
column :DIRECTION, '', :left, :size => 9 do |d|
|
|
427
|
+
d['DIRECTION']
|
|
428
|
+
end
|
|
429
|
+
|
|
430
|
+
column :VLANS, '', :left, :adjust, :size => 8 do |d|
|
|
431
|
+
d['VLANS']
|
|
432
|
+
end
|
|
433
|
+
|
|
434
|
+
column :PORTS, '', :left, :adjust, :size => 12 do |d|
|
|
435
|
+
d['PORTS']
|
|
436
|
+
end
|
|
437
|
+
|
|
438
|
+
column :OPTIONS, '', :left, :adjust, :size => 15 do |d|
|
|
439
|
+
d.reject {|key, _value| MIRROR_COLUMNS.include?(key) }
|
|
440
|
+
.sort
|
|
441
|
+
.map {|key, value| "#{key}=#{value}" }
|
|
442
|
+
.join(',')
|
|
443
|
+
end
|
|
444
|
+
|
|
445
|
+
default :ID, :NAME, :TYPE, :DIRECTION, :VLANS, :PORTS, :OPTIONS
|
|
446
|
+
end.show(mirrors, {})
|
|
447
|
+
end
|
|
448
|
+
|
|
401
449
|
puts
|
|
402
450
|
|
|
403
451
|
CLIHelper.print_header(format(str_h1, 'ADDRESS RANGE POOL'), false)
|
data/lib/one_helper.rb
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
# limitations under the License. #
|
|
15
15
|
#--------------------------------------------------------------------------- #
|
|
16
16
|
|
|
17
|
+
require 'base64'
|
|
17
18
|
require 'cli_helper'
|
|
18
19
|
require 'open3'
|
|
19
20
|
require 'io/console'
|
|
@@ -1380,9 +1381,8 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
1380
1381
|
xsd = xsd['element']
|
|
1381
1382
|
end
|
|
1382
1383
|
|
|
1383
|
-
# rubocop:disable Style/ArrayCoercion
|
|
1384
|
+
# rubocop:disable-next Style/ArrayCoercion
|
|
1384
1385
|
xsd = [xsd] unless xsd.is_a? Array
|
|
1385
|
-
# rubocop:enable Style/ArrayCoercion
|
|
1386
1386
|
|
|
1387
1387
|
check_xsd(hash[ename], xsd)
|
|
1388
1388
|
|
|
@@ -1436,6 +1436,12 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
1436
1436
|
|
|
1437
1437
|
hash = hash['schema']['element']
|
|
1438
1438
|
|
|
1439
|
+
# Schemas may define several top-level elements (e.g. vnet.xsd
|
|
1440
|
+
# defines MIRROR and VNET), pick the one matching the resource
|
|
1441
|
+
if hash.is_a?(Array)
|
|
1442
|
+
hash = hash.find {|e| e['name'] == ename } || hash.first
|
|
1443
|
+
end
|
|
1444
|
+
|
|
1439
1445
|
replace_refs(hash)
|
|
1440
1446
|
end
|
|
1441
1447
|
|
|
@@ -2440,9 +2446,8 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
2440
2446
|
when 'g'
|
|
2441
2447
|
ret += rwx * 10
|
|
2442
2448
|
else
|
|
2443
|
-
# rubocop:disable Lint/UselessNumericOperation
|
|
2449
|
+
# rubocop:disable-next Lint/UselessNumericOperation
|
|
2444
2450
|
ret += rwx * 1
|
|
2445
|
-
# rubocop:enable Lint/UselessNumericOperation
|
|
2446
2451
|
end
|
|
2447
2452
|
end
|
|
2448
2453
|
|
data/share/schemas/xsd/host.xsd
CHANGED
|
@@ -77,9 +77,13 @@
|
|
|
77
77
|
<xs:element name="DEVICE" type="xs:string"/>
|
|
78
78
|
<xs:element name="DEVICE_NAME" type="xs:string"/>
|
|
79
79
|
<xs:element name="DOMAIN" type="xs:string"/>
|
|
80
|
+
<xs:element name="ESWITCH_MODE" type="xs:string" minOccurs="0"/>
|
|
80
81
|
<xs:element name="FUNCTION" type="xs:string"/>
|
|
81
82
|
<xs:element name="IFNAME" type="xs:string"/>
|
|
82
83
|
<xs:element name="NUMA_NODE" type="xs:string"/>
|
|
84
|
+
<xs:element name="PASSTHROUGH" type="xs:string" minOccurs="0"/>
|
|
85
|
+
<xs:element name="PF_ADDRESS" type="xs:string" minOccurs="0"/>
|
|
86
|
+
<xs:element name="PF_IFNAME" type="xs:string" minOccurs="0"/>
|
|
83
87
|
<xs:element name="PROFILES" type="xs:string" minOccurs="0"/>
|
|
84
88
|
<xs:element name="SHORT_ADDRESS" type="xs:string"/>
|
|
85
89
|
<xs:element name="SLOT" type="xs:string"/>
|
|
@@ -329,6 +329,8 @@
|
|
|
329
329
|
<xs:element name="DS_MIGRATE" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
330
330
|
<xs:element name="DS_LIVE_MIGRATE" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
331
331
|
<xs:element name="DS_MIGRATE_SNAP" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
332
|
+
<xs:element name="INTERACTIVE_BACKUP" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
333
|
+
<xs:element name="INTERACTIVE_BACKUP_FORMATS" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
332
334
|
<xs:element name="LN_TARGET" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
333
335
|
<xs:element name="LN_TARGET_SHARED" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
334
336
|
<xs:element name="LN_TARGET_SSH" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
data/share/schemas/xsd/vm.xsd
CHANGED
|
@@ -124,6 +124,7 @@
|
|
|
124
124
|
<xs:element name="MEMORY_MAX" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
125
125
|
<xs:element name="MEMORY_SLOTS" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
126
126
|
<xs:element name="MEMORY_RESIZE_MODE" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
127
|
+
<xs:element name="MIRROR" minOccurs="0" maxOccurs="unbounded"/>
|
|
127
128
|
<xs:element name="NIC" minOccurs="0" maxOccurs="unbounded">
|
|
128
129
|
<xs:complexType>
|
|
129
130
|
<xs:sequence>
|
|
@@ -193,6 +194,7 @@
|
|
|
193
194
|
<xs:element name="VCPU_MAX" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
194
195
|
<xs:element name="VMGROUP" minOccurs="0" maxOccurs="1"/>
|
|
195
196
|
<xs:element name="VMID" type="xs:string"/>
|
|
197
|
+
<xs:element name="VNET_UPDATE" minOccurs="0" maxOccurs="1"/>
|
|
196
198
|
<xs:element name="VROUTER_ID" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
197
199
|
<xs:element name="VROUTER_KEEPALIVED_ID" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
198
200
|
<xs:element name="VROUTER_KEEPALIVED_PASSWORD" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
data/share/schemas/xsd/vnet.xsd
CHANGED
|
@@ -2,6 +2,108 @@
|
|
|
2
2
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
|
|
3
3
|
targetNamespace="http://opennebula.org/XMLSchema" xmlns="http://opennebula.org/XMLSchema">
|
|
4
4
|
<xs:include schemaLocation="shared.xsd"/>
|
|
5
|
+
<xs:element name="MIRROR">
|
|
6
|
+
<xs:annotation>
|
|
7
|
+
<xs:documentation>
|
|
8
|
+
Canonical Virtual Network mirror definition. RSPAN requires OUTPUT_VLAN;
|
|
9
|
+
GRE and ERSPAN require
|
|
10
|
+
REMOTE_IP. ERSPAN requires ERSPAN_TYPE and ERSPAN_KEY, with ERSPAN_INDEX
|
|
11
|
+
for type II or ERSPAN_HWID for type III. These conditional requirements
|
|
12
|
+
and restrictions are enforced by the mirror API.
|
|
13
|
+
</xs:documentation>
|
|
14
|
+
</xs:annotation>
|
|
15
|
+
<xs:complexType>
|
|
16
|
+
<xs:all>
|
|
17
|
+
<xs:element name="MIRROR_ID" type="xs:nonNegativeInteger"/>
|
|
18
|
+
<xs:element name="NAME">
|
|
19
|
+
<xs:simpleType>
|
|
20
|
+
<xs:restriction base="xs:string">
|
|
21
|
+
<xs:minLength value="1"/>
|
|
22
|
+
</xs:restriction>
|
|
23
|
+
</xs:simpleType>
|
|
24
|
+
</xs:element>
|
|
25
|
+
<xs:element name="TYPE">
|
|
26
|
+
<xs:simpleType>
|
|
27
|
+
<xs:restriction base="xs:string">
|
|
28
|
+
<xs:enumeration value="RSPAN"/>
|
|
29
|
+
<xs:enumeration value="GRE"/>
|
|
30
|
+
<xs:enumeration value="ERSPAN"/>
|
|
31
|
+
</xs:restriction>
|
|
32
|
+
</xs:simpleType>
|
|
33
|
+
</xs:element>
|
|
34
|
+
<xs:element name="DIRECTION">
|
|
35
|
+
<xs:simpleType>
|
|
36
|
+
<xs:restriction base="xs:string">
|
|
37
|
+
<xs:enumeration value="IN"/>
|
|
38
|
+
<xs:enumeration value="OUT"/>
|
|
39
|
+
<xs:enumeration value="BOTH"/>
|
|
40
|
+
</xs:restriction>
|
|
41
|
+
</xs:simpleType>
|
|
42
|
+
</xs:element>
|
|
43
|
+
<xs:element name="PORTS" type="xs:string">
|
|
44
|
+
<xs:annotation>
|
|
45
|
+
<xs:documentation>Comma-separated regular VM NIC references as VM_ID:NIC_ID pairs, or empty for an inactive mirror.</xs:documentation>
|
|
46
|
+
</xs:annotation>
|
|
47
|
+
</xs:element>
|
|
48
|
+
<xs:element name="VLANS" type="xs:string">
|
|
49
|
+
<xs:annotation>
|
|
50
|
+
<xs:documentation>Optional filter on selected ports: comma-separated VLAN IDs from 0 to 4094, or empty. Does not enable VLAN-only capture.</xs:documentation>
|
|
51
|
+
</xs:annotation>
|
|
52
|
+
</xs:element>
|
|
53
|
+
<xs:element name="DESCRIPTION" type="xs:string" minOccurs="0"/>
|
|
54
|
+
<xs:element name="OUTPUT_VLAN" minOccurs="0">
|
|
55
|
+
<xs:simpleType>
|
|
56
|
+
<xs:restriction base="xs:integer">
|
|
57
|
+
<xs:minInclusive value="1"/>
|
|
58
|
+
<xs:maxInclusive value="4094"/>
|
|
59
|
+
</xs:restriction>
|
|
60
|
+
</xs:simpleType>
|
|
61
|
+
</xs:element>
|
|
62
|
+
<xs:element name="REMOTE_IP" type="xs:string" minOccurs="0">
|
|
63
|
+
<xs:annotation>
|
|
64
|
+
<xs:documentation>Collector IPv4 address for GRE or ERSPAN.</xs:documentation>
|
|
65
|
+
</xs:annotation>
|
|
66
|
+
</xs:element>
|
|
67
|
+
<xs:element name="LOCAL_IP" type="xs:string" minOccurs="0">
|
|
68
|
+
<xs:annotation>
|
|
69
|
+
<xs:documentation>Source IPv4 address or interface:name reference.</xs:documentation>
|
|
70
|
+
</xs:annotation>
|
|
71
|
+
</xs:element>
|
|
72
|
+
<xs:element name="ERSPAN_TYPE" minOccurs="0">
|
|
73
|
+
<xs:simpleType>
|
|
74
|
+
<xs:restriction base="xs:string">
|
|
75
|
+
<xs:enumeration value="II"/>
|
|
76
|
+
<xs:enumeration value="III"/>
|
|
77
|
+
</xs:restriction>
|
|
78
|
+
</xs:simpleType>
|
|
79
|
+
</xs:element>
|
|
80
|
+
<xs:element name="ERSPAN_KEY" minOccurs="0">
|
|
81
|
+
<xs:simpleType>
|
|
82
|
+
<xs:restriction base="xs:integer">
|
|
83
|
+
<xs:minInclusive value="0"/>
|
|
84
|
+
<xs:maxInclusive value="1023"/>
|
|
85
|
+
</xs:restriction>
|
|
86
|
+
</xs:simpleType>
|
|
87
|
+
</xs:element>
|
|
88
|
+
<xs:element name="ERSPAN_INDEX" minOccurs="0">
|
|
89
|
+
<xs:simpleType>
|
|
90
|
+
<xs:restriction base="xs:integer">
|
|
91
|
+
<xs:minInclusive value="0"/>
|
|
92
|
+
<xs:maxInclusive value="1048575"/>
|
|
93
|
+
</xs:restriction>
|
|
94
|
+
</xs:simpleType>
|
|
95
|
+
</xs:element>
|
|
96
|
+
<xs:element name="ERSPAN_HWID" minOccurs="0">
|
|
97
|
+
<xs:simpleType>
|
|
98
|
+
<xs:restriction base="xs:integer">
|
|
99
|
+
<xs:minInclusive value="0"/>
|
|
100
|
+
<xs:maxInclusive value="63"/>
|
|
101
|
+
</xs:restriction>
|
|
102
|
+
</xs:simpleType>
|
|
103
|
+
</xs:element>
|
|
104
|
+
</xs:all>
|
|
105
|
+
</xs:complexType>
|
|
106
|
+
</xs:element>
|
|
5
107
|
<xs:element name="VNET">
|
|
6
108
|
<xs:complexType>
|
|
7
109
|
<xs:sequence>
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: opennebula-cli
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 7.4.
|
|
4
|
+
version: 7.4.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- OpenNebula
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: opennebula
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - '='
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 7.4.
|
|
19
|
+
version: 7.4.2
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - '='
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 7.4.
|
|
26
|
+
version: 7.4.2
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: activesupport
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|