F #3613: brctl/ip-route2 backward compatible (#3654)

This commit is contained in:
Jan Orel authored and Ruben S. Montero committed 2019-09-06 13:19:30 +02:00
1 parent 9e7c10278a
commit 07a44ec3f0
2 files changed
+36 -8

No files matched your search

+1 -2
View File
@@ -94,10 +94,9 @@
#
# ip link add name <bridge name> type bridge stp_state 1
#
# :bridge_conf:
# :ip_bridge_conf:
# :stp_state: on
# These options are set on the OvS bridge. For example,
# this command will be trigged for the following option:
#
+35 -6
View File
@@ -155,10 +155,39 @@ module VNMMAD
"link set #{@nic[:bridge]} up")
end
# reads bridge_conf and return str with switches
# Reads config and return str with switches
# It reads both
# * brctl options from :bridge_conf section
# * ip-route2 bridge options from ip_bridge_conf section
#
# It tries to translate the options from brctl to ip-route2 format
# for the backward compatibility
def list_bridge_options
bridge_options = ''
@nic[:bridge_conf].each do |option, value|
bridge_options = @nic[:conf][:bridge_conf] || Hash.new
ip_bridge_options = Hash.new
# options transform table from brctl to ip-route2
brctl_to_ipbridge = {
:setageing => :ageing_time,
:sethello => :hello_time,
:setmaxage => :max_age,
:stp => :stp_state,
:setbridgeprio => :priority,
:setfd => :forward_delay
}
# translate bridge_options to ip_bridge_options
bridge_options.each do |brctl_opt, brctl_val|
next if ! brctl_to_ipbridge.include? brctl_opt
ip_bridge_options[brctl_to_ipbridge[brctl_opt]] = brctl_val
end
# merge, conf section `:ip_bridge_conf` has higher priority
ip_bridge_options.merge!(@nic[:conf][:ip_bridge_conf]) \
if @nic[:conf][:ip_bridge_conf]
bridge_options_str = ""
ip_bridge_options.each do |option, value|
case value
when true
value = '1'
@@ -166,10 +195,10 @@ module VNMMAD
value = '0'
end
bridge_options << "#{option} #{value} "
bridge_options_str << "#{option} #{value} "
end
bridge_options.strip
bridge_options_str.strip
end
# Get hypervisor bridges