From 06319be69a24889a2d0247872f715a318957f443 Mon Sep 17 00:00:00 2001 From: yaacov Date: Mon, 2 Sep 2024 16:15:07 +0300 Subject: [PATCH] Remove double quates from network config files Signed-off-by: yaacov --- virt-v2v/cold/scripts/rhel/run/network_config_util.sh | 9 +++++++-- virt-v2v/cold/scripts/rhel/run/network_config_util_test | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/virt-v2v/cold/scripts/rhel/run/network_config_util.sh b/virt-v2v/cold/scripts/rhel/run/network_config_util.sh index f795c72c3..4d424590c 100644 --- a/virt-v2v/cold/scripts/rhel/run/network_config_util.sh +++ b/virt-v2v/cold/scripts/rhel/run/network_config_util.sh @@ -18,6 +18,11 @@ if [ -f "$UDEV_RULES_FILE" ]; then exit 0 fi +# Clean strigs in case they have quates +remove_quotes() { + echo "$1" | tr -d '"' +} + # Validate MAC address and IPv4 address and extract them extract_mac_ip() { S_HW="" @@ -58,7 +63,7 @@ udev_from_ifcfg() { continue fi - echo "SUBSYSTEM==\"net\",ACTION==\"add\",ATTR{address}==\"$S_HW\",NAME=\"$DEVICE\"" + echo "SUBSYSTEM==\"net\",ACTION==\"add\",ATTR{address}==\"$(remove_quotes "$S_HW")\",NAME=\"$(remove_quotes "$DEVICE")\"" done < "$V2V_MAP_FILE" } @@ -92,7 +97,7 @@ udev_from_nm() { continue fi - echo "SUBSYSTEM==\"net\",ACTION==\"add\",ATTR{address}==\"$S_HW\",NAME=\"$DEVICE\"" + echo "SUBSYSTEM==\"net\",ACTION==\"add\",ATTR{address}==\"$(remove_quotes "$S_HW")\",NAME=\"$(remove_quotes "$DEVICE")\"" done < "$V2V_MAP_FILE" } diff --git a/virt-v2v/cold/scripts/rhel/run/network_config_util_test b/virt-v2v/cold/scripts/rhel/run/network_config_util_test index 163fa0067..2bd5de99d 100644 --- a/virt-v2v/cold/scripts/rhel/run/network_config_util_test +++ b/virt-v2v/cold/scripts/rhel/run/network_config_util_test @@ -18,7 +18,7 @@ mkdir -p "$NETWORK_SCRIPTS_DIR" "$NETWORK_CONNECTIONS_DIR" # Create mock data printf "aa:bb:cc:dd:ee:ff:ip:192.168.1.10,things,more\naa:bb:cc:dd:ee:fe:ip:192.168.1.11,hello,world\naa:bb:cc:dd:ee:fd:ip:2001:0db8:85a3:0000:0000:8a2e:0370:7334\n" > "$V2V_MAP_FILE" -printf "DEVICE=eth0\nIPADDR=192.168.1.10\n" > "$NETWORK_SCRIPTS_DIR/ifcfg-eth0" +printf "DEVICE=\"eth0\"\nIPADDR=192.168.1.10\n" > "$NETWORK_SCRIPTS_DIR/ifcfg-eth0" printf "[connection]\ninterface-name=eth3\naddress1=192.168.1.11/24\n" > "$NETWORK_CONNECTIONS_DIR/eth1 but with spaces.nmconnection" # Source the script under test