xcat-core icon indicating copy to clipboard operation
xcat-core copied to clipboard

confignetwork / nicutils.sh ends with error if connection name contains white space

Open OliverTUBAF opened this issue 11 months ago • 0 comments
trafficstars

I was trying to setup a bridge interface on one node, but the connections did not come up as expected. Investigating the logs on the nodes I discovered that the following was logged at one point by "confignetwork" postscript:

[I]: create bridge connection xcat-bridge-brexternalnet
[I]: nmcli con add type bridge con-name xcat-bridge-brexternalnet ifname brexternalnet connection.autoconnect-priority 9 autoconnect yes connection.autoconnect-retries 0 connection.autoconnect-slaves 1
Connection 'xcat-bridge-brexternalnet' (87408de7-da96-4214-811b-9a57234cf092) successfully added.
[I]: create ethernet slaves connetcion Wired connection 2 for bridge
[I]: nmcli con mod Wired connection 2 master brexternalnet  connection.autoconnect-priority 9 autoconnect yes connection.autoconnect-slaves 1 connection.autoconnect-retries 0
Error: unknown connection 'Wired'.
[E]:Error: nmcli failed to add bridge slave ens4f0
[E]:Error: create bridge interface brexternalnet failed

The automatic generated connection name in my case was Wired connection 2, which causes problems when the actual nmcli is executed.

After a long trial and error session I decided to replace the connection name with the uuid of the connection, as this should not contain spaces:

--- nicutils.sh.orig
+++ nicutils.sh
@@ -2035,7 +2021,9 @@
         fi
         con_use_same_dev=$(wait_nic_connect_intime $_port)
         if [ "$con_use_same_dev" != "--" -a -n "$con_use_same_dev" ]; then
-            cmd="$nmcli con mod "$con_use_same_dev" master $ifname $_mtu connection.autoconnect-priority 9 autoconnect yes connection.autoconnect-slaves 1 connection.autoconnect-retries 0"
+            log_info "$con_use_same_dev may contain white spaces, therefore replacing it with the UUID"
+            con_use_same_dev=$( $nmcli --get-values connection.uuid c show "$con_use_same_dev" )
+            cmd="$nmcli con mod $con_use_same_dev master $ifname $_mtu connection.autoconnect-priority 9 autoconnect yes connection.autoconnect-slaves 1 connection.autoconnect-retries 0"
             xcat_slave_con=$con_use_same_dev
         else
             cmd="$nmcli con add type $_pretype con-name $xcat_slave_con ifname $_port master $ifname $_mtu connection.autoconnect-priority 9 autoconnect yes connection.autoconnect-slaves 1 connection.autoconnect-retries 0"

Maybe someone can implement this or find a better solution on how to deal with white spaces. (Maybe by placing cmd in single quotes?)

Version information:

$ dnf info xCAT.x86_64
Name         : xCAT
Version      : 2.16.5
Release      : snap202303030907
Architecture : x86_64

OliverTUBAF avatar Dec 06 '24 11:12 OliverTUBAF