Skip to content

Commit ee5479c

Browse files
dubmarmdmarm
andauthored
Adjustments to configib to handle Rocky9 precreated connections (#7490)
* take out useless arp_ignore/arp_filter lines * create logic to use con add if con doesn't exist, else con modify * swap the con modify vs con add logic so that it matches the test logic * add back arp_filter and arp_ignore --------- Co-authored-by: dmarm <dmarm@dmarms-MBP.lan>
1 parent 10a485d commit ee5479c

File tree

1 file changed

+40
-16
lines changed

1 file changed

+40
-16
lines changed

xCAT/postscripts/configib

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -486,13 +486,25 @@ IPADDR_$ipindex=$nicip" >> $dir/ifcfg-$nic
486486
if [ $ipindex -eq 1 ]
487487
then
488488
if [[ "$OSVER" =~ ^(rhels9|alma9|rocky9) ]]; then
489-
# ipv6
490-
if echo $nicip | grep : 2>&1 1>/dev/null
491-
then
492-
nmcli con add type infiniband con-name $nic ifname $nic ipv6.method manual ipv6.addresses $nicip
493-
else # ipv4
494-
prefix=$(convert_netmask_to_cidr $netmask)
495-
nmcli con add type infiniband con-name $nic ifname $nic ipv4.method manual ipv4.addresses $nicip/$prefix
489+
if nmcli --field connection.id con show $nic 2>&1 1>/dev/null
490+
then # modify current connection
491+
# ipv6
492+
if echo $nicip | grep : 2>&1 1>/dev/null
493+
then
494+
nmcli con modify $nic type infiniband con-name $nic ifname $nic ipv6.method manual ipv6.addresses $nicip
495+
else # ipv4
496+
prefix=$(convert_netmask_to_cidr $netmask)
497+
nmcli con modify $nic type infiniband con-name $nic ifname $nic ipv4.method manual ipv4.addresses $nicip/$prefix
498+
fi
499+
else # create new connection
500+
# ipv6
501+
if echo $nicip | grep : 2>&1 1>/dev/null
502+
then
503+
nmcli con add type infiniband con-name $nic ifname $nic ipv6.method manual ipv6.addresses $nicip
504+
else # ipv4
505+
prefix=$(convert_netmask_to_cidr $netmask)
506+
nmcli con add type infiniband con-name $nic ifname $nic ipv4.method manual ipv4.addresses $nicip/$prefix
507+
fi
496508
fi
497509
else
498510
nmcontrol=""
@@ -540,7 +552,7 @@ IPADDR=$nicip" > $dir/ifcfg-$nic
540552
value="${array_extra_param_values[$i]}"
541553
echo " $i: name=$name value=$value"
542554
if [[ "$OSVER" =~ ^(rhels9|alma9|rocky9) ]]; then
543-
nmcli con modify $con_name $name $value
555+
nmcli con modify $nic $name $value
544556
else
545557
grep -i "${name}" $dir/ifcfg-$nic
546558
if [ $? -eq 0 ];then
@@ -553,13 +565,25 @@ IPADDR=$nicip" > $dir/ifcfg-$nic
553565
done
554566
else # not the first ip address
555567
if [[ "$OSVER" =~ ^(rhels9|alma9|rocky9) ]]; then
556-
# ipv6
557-
if echo $nicip | grep : 2>&1 1>/dev/null
558-
then
559-
nmcli con add type infiniband con-name $nic ifname $nic ipv6.method manual ipv6.addresses $nicip
560-
else # ipv4
561-
prefix=$(convert_netmask_to_cidr $netmask)
562-
nmcli con add type infiniband con-name $nic ifname $nic ipv4.method manual ipv4.addresses $nicip/$prefix
568+
if nmcli --field connection.id con show $nic 2>&1 1>/dev/null
569+
then # modify current connection
570+
# ipv6
571+
if echo $nicip | grep : 2>&1 1>/dev/null
572+
then
573+
nmcli con modify $nic type infiniband con-name $nic ifname $nic ipv6.method manual ipv6.addresses $nicip
574+
else # ipv4
575+
prefix=$(convert_netmask_to_cidr $netmask)
576+
nmcli con modify $nic type infiniband con-name $nic ifname $nic ipv4.method manual ipv4.addresses $nicip/$prefix
577+
fi
578+
else # create new connection
579+
# ipv6
580+
if echo $nicip | grep : 2>&1 1>/dev/null
581+
then
582+
nmcli con add type infiniband con-name $nic ifname $nic ipv6.method manual ipv6.addresses $nicip
583+
else # ipv4
584+
prefix=$(convert_netmask_to_cidr $netmask)
585+
nmcli con add type infiniband con-name $nic ifname $nic ipv4.method manual ipv4.addresses $nicip/$prefix
586+
fi
563587
fi
564588
else
565589
# ipv6
@@ -620,7 +644,7 @@ IPADDR$ipindex=$nicip"
620644
value="${array_extra_param_values[$i]}"
621645
echo " $i: name=$name value=$value"
622646
if [[ "$OSVER" =~ ^(rhels9|alma9|rocky9) ]]; then
623-
nmcli con modify $con_name $name $value
647+
nmcli con modify $nic $name $value
624648
else
625649
grep -i "${name}" $cfgfile
626650
if [ $? -eq 0 ]; then

0 commit comments

Comments
 (0)