mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-21 04:12:37 +09:00
(cherry picked from commit 23ebb7c2ee)
This commit is contained in:
1 parent
ace9a952a3
commit
87cc3396ef
1 file changed
+24
-2
@@ -107,7 +107,11 @@ class OpenvSwitchVLAN < VNMMAD::VNMDriver
|
||||
if range? range
|
||||
ovs_vsctl_cmd = "#{command(:ovs_vsctl)} set Port #{@nic[:tap]}"
|
||||
|
||||
cmd = "#{ovs_vsctl_cmd} trunks=#{range}"
|
||||
# Open vSwitch 2.7.0+ allows range intervals (x-y), but
|
||||
# we need to support even older versions. We expand the
|
||||
# intervals into the list of values [x,x+1,...,y-1,y],
|
||||
# which should work for all.
|
||||
cmd = "#{ovs_vsctl_cmd} trunks=#{expand_range(range)}"
|
||||
run cmd
|
||||
|
||||
cmd = "#{ovs_vsctl_cmd} vlan_mode=native-untagged"
|
||||
@@ -216,6 +220,24 @@ class OpenvSwitchVLAN < VNMMAD::VNMDriver
|
||||
end
|
||||
|
||||
def range?(range)
|
||||
!range.to_s.match(/^\d+(,\d+)*$/).nil?
|
||||
!range.to_s.match(/^\d+([,-]\d+)*$/).nil?
|
||||
end
|
||||
|
||||
def expand_range(range)
|
||||
items = []
|
||||
|
||||
range.split(',').each do |i|
|
||||
l, r = i.split('-')
|
||||
|
||||
if r.nil?
|
||||
items << i
|
||||
elsif r >= l
|
||||
items.concat((l..r).to_a)
|
||||
else
|
||||
items.concat((r..l).to_a)
|
||||
end
|
||||
end
|
||||
|
||||
items.uniq.join(',')
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user