From 5f1da7dbdc17b567b2104ae930944ef16e57ac80 Mon Sep 17 00:00:00 2001 From: Michel Thebeau Date: Mon, 14 Aug 2023 14:46:37 -0400 Subject: [PATCH] libvirt: standardize sed replacement strings The original code inconsistently uses replacement strings either limited to capital letters or with additional percentage symbols. The use of percentage symbols is preferred to mitigate the possibility of accidental replacements. Standardize the sed replacement strings to use percentage symbols. Test plan: PASS: Regression for default and mad examples PASS: unit test the replacement values for all configurations Story: 2010816 Task: 48611 Change-Id: I35959d7ae8cd46e613a1d0b3a1fcb44fc3f0b1d6 Signed-off-by: Michel Thebeau --- libvirt/controller.xml | 8 ++++---- libvirt/controller_allinone.xml | 10 +++++----- libvirt/functions.sh | 18 +++++++++--------- libvirt/storage.xml | 6 +++--- libvirt/worker.xml | 6 +++--- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/libvirt/controller.xml b/libvirt/controller.xml index 0352bcd..b2b79eb 100644 --- a/libvirt/controller.xml +++ b/libvirt/controller.xml @@ -1,5 +1,5 @@ - NAME + %NAME% %MEM% %MEM% %CPU% @@ -28,20 +28,20 @@ /usr/bin/qemu-system-x86_64 - + - + - + diff --git a/libvirt/controller_allinone.xml b/libvirt/controller_allinone.xml index 6a1cc25..56054b1 100644 --- a/libvirt/controller_allinone.xml +++ b/libvirt/controller_allinone.xml @@ -1,5 +1,5 @@ - NAME + %NAME% %MEM% %MEM% %CPU% @@ -28,26 +28,26 @@ /usr/bin/qemu-system-x86_64 - + - + - + - + diff --git a/libvirt/functions.sh b/libvirt/functions.sh index fa38806..ef9ccc5 100644 --- a/libvirt/functions.sh +++ b/libvirt/functions.sh @@ -173,11 +173,11 @@ create_controller() { cp controller.xml ${DOMAIN_FILE} fi sed -i -e " - s,NAME,${CONTROLLER_NODE}, + s,%NAME%,${CONTROLLER_NODE}, s,%CPU%,${CPU}, s,%MEM%,${MEM}, - s,DISK0,${DISK_LOCATION}/${CONTROLLER_NODE}-0.img, - s,DISK1,${DISK_LOCATION}/${CONTROLLER_NODE}-1.img, + s,%DISK0%,${DISK_LOCATION}/${CONTROLLER_NODE}-0.img, + s,%DISK1%,${DISK_LOCATION}/${CONTROLLER_NODE}-1.img, s,%BR1%,${BRIDGE_INTERFACE}1, s,%BR2%,${BRIDGE_INTERFACE}2, s,%BR3%,${BRIDGE_INTERFACE}3, @@ -187,14 +187,14 @@ create_controller() { sudo qemu-img create -f qcow2 ${DISK_LOCATION}/${CONTROLLER_NODE}-1.img 200G if ([ "$CONFIGURATION" == "simplex" ] || [ "$CONFIGURATION" == "duplex" ]); then sed -i -e " - s,DISK2,${DISK_LOCATION}/${CONTROLLER_NODE}-2.img, + s,%DISK2%,${DISK_LOCATION}/${CONTROLLER_NODE}-2.img, " ${DOMAIN_FILE} sudo qemu-img create -f qcow2 ${DISK_LOCATION}/${CONTROLLER_NODE}-2.img 200G fi if [ $i -eq 0 ]; then - sed -i -e "s,ISO,${ISOIMAGE}," ${DOMAIN_FILE} + sed -i -e "s,%ISO%,${ISOIMAGE}," ${DOMAIN_FILE} else - sed -i -e "s,ISO,," ${DOMAIN_FILE} + sed -i -e "s,%ISO%,," ${DOMAIN_FILE} fi sudo virsh define ${DOMAIN_FILE} if [ $i -eq 0 ]; then @@ -267,11 +267,11 @@ create_node() { sudo qemu-img create -f qcow2 ${DISK_LOCATION}/${NODE}-1.img 200G cp ${IDENTITY}.xml ${DOMAIN_FILE} sed -i -e " - s,NAME,${NODE}, + s,%NAME%,${NODE}, s,%CPU%,${CPU}, s,%MEM%,${MEM}, - s,DISK0,${DISK_LOCATION}/${NODE}-0.img,; - s,DISK1,${DISK_LOCATION}/${NODE}-1.img, + s,%DISK0%,${DISK_LOCATION}/${NODE}-0.img,; + s,%DISK1%,${DISK_LOCATION}/${NODE}-1.img, s,%BR1%,${BRIDGE_INTERFACE}1, s,%BR2%,${BRIDGE_INTERFACE}2, s,%BR3%,${BRIDGE_INTERFACE}3, diff --git a/libvirt/storage.xml b/libvirt/storage.xml index b4bd1e1..76247e6 100644 --- a/libvirt/storage.xml +++ b/libvirt/storage.xml @@ -1,5 +1,5 @@ - NAME + %NAME% %MEM% %MEM% %CPU% @@ -28,14 +28,14 @@ /usr/bin/qemu-system-x86_64 - + - + diff --git a/libvirt/worker.xml b/libvirt/worker.xml index 0f45f50..d50f8fd 100644 --- a/libvirt/worker.xml +++ b/libvirt/worker.xml @@ -1,5 +1,5 @@ - NAME + %NAME% %MEM% %MEM% %CPU% @@ -28,14 +28,14 @@ /usr/bin/qemu-system-x86_64 - + - +