mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-11-02 12:22:36 +00:00
enhance extra params support for confignetwork (#3404)
* add extra params support * enhanced based on comments
This commit is contained in:
@@ -255,6 +255,45 @@ function load_kmod {
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#################################################################
|
||||
#
|
||||
# query nicextraparams from nics table
|
||||
# example: nicextraparams.eth0="MTU=9000 something=yes"
|
||||
# input: nic, here is eth0
|
||||
# output: set value for globe ${array_extra_param_names}
|
||||
# and ${array_extra_param_values}
|
||||
# example:
|
||||
# array_extra_param_names[0]="MTU"
|
||||
# array_extra_param_values[0]="9000"
|
||||
# array_extra_param_names[1]="something"
|
||||
# array_extra_param_values[0]="yes"
|
||||
#
|
||||
#################################################################
|
||||
function query_extra_params {
|
||||
|
||||
nic=$1
|
||||
if [ -z "$nic" ]; then
|
||||
return
|
||||
fi
|
||||
get_nic_extra_params $nic "$NICEXTRAPARAMS"
|
||||
j=0
|
||||
while [ $j -lt ${#array_nic_params[@]} ]
|
||||
do
|
||||
#get key=value pair from nicextraparams
|
||||
#for example: MTU=9000
|
||||
exparampair="${array_nic_params[$j]}"
|
||||
j=$((j+1))
|
||||
done
|
||||
if [ ${#array_nic_params[@]} -gt 0 ]; then
|
||||
#Current confignetwork only support one ip for vlan/bond/bridge
|
||||
#So only need the first ${array_nic_params[0]} for first nicips
|
||||
str_extra_params=${array_nic_params[0]}
|
||||
parse_nic_extra_params "$str_extra_params"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
#################################################################
|
||||
#
|
||||
# query attribute from networks table
|
||||
@@ -422,6 +461,9 @@ function create_persistent_ifcfg {
|
||||
local _netmask=""
|
||||
local _mtu=""
|
||||
local inattrs=""
|
||||
unset array_nic_params
|
||||
unset array_extra_param_names
|
||||
unset array_extra_param_values
|
||||
|
||||
# parser input arguments
|
||||
while [ -n "$1" ];
|
||||
@@ -462,6 +504,9 @@ function create_persistent_ifcfg {
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
query_extra_params $ifname
|
||||
|
||||
local attrs=""
|
||||
attrs=${attrs}${attrs:+,}"DEVICE=$ifname"
|
||||
attrs=${attrs}${attrs:+,}"BOOTPROTO=static"
|
||||
@@ -495,6 +540,16 @@ function create_persistent_ifcfg {
|
||||
attrs=${attrs}${attrs:+,}"HWADDR=$mac"
|
||||
fi
|
||||
fi
|
||||
|
||||
#add extra params
|
||||
i=0
|
||||
while [ $i -lt ${#array_extra_param_names[@]} ]
|
||||
do
|
||||
name="${array_extra_param_names[$i]}"
|
||||
value="${array_extra_param_values[$i]}"
|
||||
attrs=${attrs}${attrs:+,}"${name}=${value}"
|
||||
i=$((i+1))
|
||||
done
|
||||
|
||||
# record manual and auto attributes first
|
||||
# since input attributes might overwrite them.
|
||||
|
||||
Reference in New Issue
Block a user