mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-20 03:42:52 +09:00
1 parent
389d1bbf07
commit
23ebb7c2ee
1 file changed
+25
-2
@@ -179,7 +179,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"
|
||||
@@ -336,9 +340,28 @@ 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
|
||||
|
||||
|
||||
private
|
||||
# Generate the name of the vlan device which will be added to the bridge.
|
||||
def get_vlan_dev_name
|
||||
|
||||
Reference in new issue
Block a user