1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-15 18:50:09 +03:00

F #4743: configurable bridge parameters

This commit is contained in:
Javi Fontan 2016-11-28 19:31:45 +01:00
parent 51f5a3885a
commit a6620629e9
3 changed files with 56 additions and 0 deletions

View File

@ -841,6 +841,7 @@ VNET_RESTRICTED_ATTR = "PHYDEV"
VNET_RESTRICTED_ATTR = "VLAN_ID"
VNET_RESTRICTED_ATTR = "BRIDGE"
VNET_RESTRICTED_ATTR = "CONF"
VNET_RESTRICTED_ATTR = "BRIDGE_CONF"
VNET_RESTRICTED_ATTR = "AR/VN_MAD"
VNET_RESTRICTED_ATTR = "AR/PHYDEV"
@ -903,6 +904,7 @@ INHERIT_VNET_ATTR = "OUTBOUND_AVG_BW"
INHERIT_VNET_ATTR = "OUTBOUND_PEAK_BW"
INHERIT_VNET_ATTR = "OUTBOUND_PEAK_KB"
INHERIT_VNET_ATTR = "CONF"
INHERIT_VNET_ATTR = "BRIDGE_CONF"
#*******************************************************************************
# Transfer Manager Driver Behavior Configuration

View File

@ -127,11 +127,30 @@ module VNMMAD
OpenNebula.exec_and_log("#{command(:brctl)} addbr #{@nic[:bridge]}")
set_bridge_options
@bridges[@nic[:bridge]] = Array.new
OpenNebula.exec_and_log("#{command(:ip)} link set #{@nic[:bridge]} up")
end
# Calls brctl to set options stored in bridge_conf
def set_bridge_options
@nic[:bridge_conf].each do |option, value|
case value
when true
value = "on"
when false
value = "off"
end
cmd = "#{command(:brctl)} #{option} " <<
"#{@nic[:bridge]} #{value}"
OpenNebula.exec_and_log(cmd)
end
end
# Get hypervisor bridges
# @return [Hash<String>] with the bridge names
def get_bridges

View File

@ -72,6 +72,7 @@ module VNMMAD
def process(&block)
blk = lambda do |nic|
add_nic_conf(nic)
add_bridge_conf(nic)
block.call(nic)
end
@ -100,6 +101,40 @@ module VNMMAD
nic[:conf] = default_conf.merge(nic_conf)
end
def add_bridge_conf(nic)
add_command_conf(nic, :bridge_conf)
end
def add_command_conf(nic, conf_name)
default_conf = CONF[conf_name] || {}
nic_conf = {}
# sanitize
default_conf.each do |key, value|
option = Shellwords.escape(key.to_s.strip.downcase)
if value.class == String
value = Shellwords.escape(value.strip)
end
nic_conf[option] = value
end
if nic[conf_name]
parse_options(nic[conf_name]).each do |option, value|
if value == '__delete__'
nic_conf.delete(option.strip.downcase)
else
option = Shellwords.escape(option.strip.downcase)
value = Shellwords.escape(value)
nic_conf[option] = value
end
end
end
nic[conf_name] = nic_conf
end
# Returns a filter object based on the contents of the template
#
# @return SGDriver object