Fix conditional reboot when max num vfs changes
Added fixes to check reboot_required condition Change-Id: I988d8def24f096223d7a9a0f816de7f4596edaf6
This commit is contained in:
parent
f1a549dac6
commit
d684dc16f8
|
@ -94,3 +94,4 @@ readonly ROLES=`get_param roles`
|
|||
readonly ROLE=`get_param role`
|
||||
readonly DEBUG=`get_param debug`
|
||||
readonly QOS=`get_mlnx_param mlnx_qos`
|
||||
readonly REBOOT_REQUIRED=`get_mlnx_param reboot_required`
|
||||
|
|
|
@ -300,13 +300,25 @@ class MellanoxSettings(object):
|
|||
burned_num_vfs_list = list()
|
||||
devices = os.popen('mst status -v| grep pciconf | grep {0} | awk \'{{print $2}}\' '.format(
|
||||
mlnx['cx_card'].replace("-",""))).readlines()
|
||||
for dev in devices:
|
||||
num = os.popen('mlxconfig -d {0} q | grep NUM_OF_VFS | awk \'{{print $2}}\' \
|
||||
'.format(dev.rsplit()[0])).readlines()
|
||||
burned_num_vfs_list.append(num[0].rsplit()[0])
|
||||
burned_num_vfs = list(set(burned_num_vfs_list))[0]
|
||||
if burned_num_vfs > MAX_NUM_VFS or mlnx['num_of_vfs'] > MAX_NUM_VFS :
|
||||
mlnx['reboot_required'] = True
|
||||
if len(devices) > 0:
|
||||
for dev in devices:
|
||||
num = os.popen('mlxconfig -d {0} q | grep NUM_OF_VFS | awk \'{{print $2}}\' \
|
||||
'.format(dev.rsplit()[0])).readlines()
|
||||
if len(num) > 0:
|
||||
burned_num_vfs_list.append(num[0].rsplit()[0])
|
||||
else:
|
||||
logging.error("Failed to grep NUM_OF_VFS from Mellanox card")
|
||||
sys.exit(1)
|
||||
burned_num_vfs_set_list = list(set(burned_num_vfs_list))
|
||||
for burned_num_vfs in burned_num_vfs_set_list :
|
||||
if int(burned_num_vfs) < int(mlnx['num_of_vfs']) :
|
||||
mlnx['reboot_required'] = True
|
||||
logging.info('reboot_required is true as {0} is < {1}'.format(burned_num_vfs,
|
||||
mlnx['num_of_vfs']))
|
||||
break;
|
||||
else:
|
||||
logging.error("There are no Mellanox devices with {0} card".format(mlnx['cx_card']))
|
||||
sys.exit(1)
|
||||
|
||||
@classmethod
|
||||
def update_role_settings(cls):
|
||||
|
|
|
@ -153,7 +153,7 @@ function burn_vfs_in_fw () {
|
|||
# required for mlxconfig to discover mlnx devices
|
||||
service openibd start &>/dev/null
|
||||
service mst start &>/dev/null
|
||||
devices=$(mst status -v | grep $CX| grep pciconf | awk '{print $2}')
|
||||
devices=$(mst status -v | grep $(echo $CX | tr -d '-')| grep pciconf | awk '{print $2}')
|
||||
for dev in $devices; do
|
||||
logger_print debug "device=$dev"
|
||||
mlxconfig -d $dev q | grep SRIOV | awk '{print $2}' | grep $SRIOV_ENABLED_FLAG &>/dev/null
|
||||
|
@ -181,7 +181,7 @@ function burn_vfs_in_fw () {
|
|||
# required for mlxconfig to discover mlnx devices
|
||||
service openibd start &>/dev/null
|
||||
service mst start &>/dev/null
|
||||
devices=$(mst status -v | grep $CX| grep pciconf | awk '{print $2}')
|
||||
devices=$(mst status -v | grep $(echo $CX | tr -d '-') | grep pciconf | awk '{print $2}')
|
||||
for dev in $devices; do
|
||||
current_fw_vfs=`mlxconfig -d $dev q | grep NUM_OF_VFS | awk '{print $2}'`
|
||||
if [ "$total_vfs" -gt "$current_fw_vfs" ]; then
|
||||
|
@ -269,7 +269,7 @@ function validate_sriov () {
|
|||
if [ $CX == 'ConnectX-4' ]; then
|
||||
set_sriov $FALLBACK_NUM_VFS
|
||||
fi
|
||||
|
||||
|
||||
current_num_vfs=`lspci | grep -i mellanox | grep -i virtual | wc -l`
|
||||
if [ $current_num_vfs -eq $FALLBACK_NUM_VFS ]; then
|
||||
logger_print info "Fallback to ${FALLBACK_NUM_VFS} succeeded"
|
||||
|
@ -290,30 +290,38 @@ function set_sriov () {
|
|||
exit 1
|
||||
else
|
||||
if [ "$(lspci | grep -i mellanox | grep -i virtual | wc -l)" -ne "$TOTAL_VFS" ]; then
|
||||
res=`echo 0 > /sys/class/net/${device_up}/device/mlx5_num_vfs`
|
||||
res=`echo ${TOTAL_VFS} > /sys/class/net/${device_up}/device/mlx5_num_vfs`
|
||||
if [ ! $? -eq 0 ]; then
|
||||
logger_print error "Failed to write $TOTAL_VFS > /sys/class/net/${device_up}/device/mlx5_num_vfs"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Give MACs to created VFs
|
||||
python ./configure_mellanox_vfs.py ${TOTAL_VFS}
|
||||
if [ ! $REBOOT_REQUIRED == true ] || [ $SCRIPT_MODE == "validate" ] ; then
|
||||
res=`echo 0 > /sys/class/net/${device_up}/device/mlx5_num_vfs`
|
||||
res=`echo ${TOTAL_VFS} > /sys/class/net/${device_up}/device/mlx5_num_vfs`
|
||||
if [ ! $? -eq 0 ]; then
|
||||
logger_print error "Failed to write $TOTAL_VFS > /sys/class/net/${device_up}/device/mlx5_num_vfs"
|
||||
exit 1
|
||||
else
|
||||
logger_print debug "Configured total vfs ${TOTAL_VFS} on ${device_up}"
|
||||
fi
|
||||
|
||||
# Give MACs to created VFs
|
||||
python ./configure_mellanox_vfs.py ${TOTAL_VFS}
|
||||
fi
|
||||
|
||||
# Make number of VFs and their MACs persistent
|
||||
persistent_ifup_script=/etc/network/if-up.d/persistent_mlnx_params
|
||||
echo "#!/bin/bash" > $persistent_ifup_script
|
||||
chmod +x $persistent_ifup_script
|
||||
echo "if ! lspci | grep -i mellanox | grep -i virtual; then" >> $persistent_ifup_script
|
||||
echo "echo 0 > /sys/class/net/${device_up}/device/mlx5_num_vfs" >> $persistent_ifup_script
|
||||
echo "echo ${TOTAL_VFS} > /sys/class/net/${device_up}/device/mlx5_num_vfs" >> $persistent_ifup_script
|
||||
echo "python /etc/fuel/plugins/mellanox-plugin-*/configure_mellanox_vfs.py ${TOTAL_VFS}" >> $persistent_ifup_script
|
||||
echo "fi" >> $persistent_ifup_script
|
||||
echo "if [ -f /etc/init.d/tgt ]; then /etc/init.d/tgt force-reload; else exit 0; fi" >> $persistent_ifup_script
|
||||
|
||||
if [ ! $? -eq 0 ]; then
|
||||
logger_print error "Failed to write $TOTAL_VFS > /sys/class/net/${device_up}/device/mlx5_num_vfs"
|
||||
exit 1
|
||||
else
|
||||
if [ $REBOOT_REQUIRED == true ] && [ $SCRIPT_MODE == "configure" ] ; then
|
||||
logger_print debug "Configured total vfs ${TOTAL_VFS} on ${device_up} will apply \
|
||||
on next reboot as reboot is required"
|
||||
fi
|
||||
|
||||
if [ $SCRIPT_MODE == "validate" ] ; then
|
||||
logger_print debug "Configured total vfs ${TOTAL_VFS} on ${device_up}"
|
||||
fi
|
||||
fi
|
||||
|
|
|
@ -5,7 +5,7 @@ name: mellanox-plugin
|
|||
title: Mellanox ConnectX-4 Openstack Features
|
||||
|
||||
# Plugin version
|
||||
version: 3.1.16
|
||||
version: 3.1.17
|
||||
|
||||
# Description
|
||||
description: Enable features over Mellanox ConnectX-4 Adapters
|
||||
|
|
Loading…
Reference in New Issue