From c7498d13ab86079e384b8095265d75a9c9673dba Mon Sep 17 00:00:00 2001 From: Sander Grendelman Date: Fri, 19 Dec 2025 09:48:49 +0100 Subject: [PATCH] Replace deprecated 'egrep' commands with 'grep -E'. --- .../java/org/apache/cloudstack/utils/linux/KVMHostInfo.java | 2 +- .../ovm3/src/test/resources/scripts/clean_primary.sh | 2 +- .../ovm3/src/test/resources/scripts/clean_secondary.sh | 2 +- scripts/storage/multipath/connectVolume.sh | 2 +- scripts/storage/multipath/resizeVolume.sh | 2 +- scripts/util/keystore-setup | 2 +- scripts/vm/network/ovs-pvlan-kvm-vm.sh | 2 +- scripts/vm/network/ovs-pvlan-vm.sh | 2 +- server/src/main/java/com/cloud/server/StatsCollector.java | 2 +- systemvm/agent/scripts/ssvm-check.sh | 2 +- systemvm/debian/opt/cloud/bin/update_interface_config.sh | 2 +- .../component/test_multiple_subnets_in_isolated_network.py | 4 ++-- .../test_multiple_subnets_in_isolated_network_rvr.py | 4 ++-- test/integration/component/test_multiple_subnets_in_vpc.py | 4 ++-- .../integration/component/test_multiple_subnets_in_vpc_rvr.py | 4 ++-- 15 files changed, 19 insertions(+), 19 deletions(-) diff --git a/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java b/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java index db665c75cc13..e88981f5b209 100644 --- a/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java +++ b/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java @@ -140,7 +140,7 @@ private static long getCpuSpeedFromCommandLscpu() { long speed = 0L; LOGGER.info("Fetching CPU speed from command \"lscpu\"."); try { - String command = "lscpu | grep -i 'Model name' | head -n 1 | egrep -o '[[:digit:]].[[:digit:]]+GHz' | sed 's/GHz//g'"; + String command = "lscpu | grep -i 'Model name' | head -n 1 | grep -E -o '[[:digit:]].[[:digit:]]+GHz' | sed 's/GHz//g'"; if(isHostS390x()) { command = "lscpu | grep 'CPU dynamic MHz' | cut -d ':' -f 2 | tr -d ' ' | awk '{printf \"%.1f\\n\", $1 / 1000}'"; } diff --git a/plugins/hypervisors/ovm3/src/test/resources/scripts/clean_primary.sh b/plugins/hypervisors/ovm3/src/test/resources/scripts/clean_primary.sh index bbf1cd0f5189..5086a16fa79f 100755 --- a/plugins/hypervisors/ovm3/src/test/resources/scripts/clean_primary.sh +++ b/plugins/hypervisors/ovm3/src/test/resources/scripts/clean_primary.sh @@ -17,7 +17,7 @@ # specific language governing permissions and limitations # under the License. # -for i in `xm list | awk '{ print $1 }' | egrep -v "Name|Domain-0"` +for i in `xm list | awk '{ print $1 }' | grep -E -v "Name|Domain-0"` do xm destroy $i done diff --git a/plugins/hypervisors/ovm3/src/test/resources/scripts/clean_secondary.sh b/plugins/hypervisors/ovm3/src/test/resources/scripts/clean_secondary.sh index 4275ee89b33a..3d5133971526 100755 --- a/plugins/hypervisors/ovm3/src/test/resources/scripts/clean_secondary.sh +++ b/plugins/hypervisors/ovm3/src/test/resources/scripts/clean_secondary.sh @@ -17,7 +17,7 @@ # specific language governing permissions and limitations # under the License. # -for i in `xm list | awk '{ print $1 }' | egrep -v "Name|Domain-0"` +for i in `xm list | awk '{ print $1 }' | grep -E -v "Name|Domain-0"` do xm destroy $i done diff --git a/scripts/storage/multipath/connectVolume.sh b/scripts/storage/multipath/connectVolume.sh index fb8387ece473..1e2052694cbf 100755 --- a/scripts/storage/multipath/connectVolume.sh +++ b/scripts/storage/multipath/connectVolume.sh @@ -100,7 +100,7 @@ while true; do done echo "$(date): Doing a recan to make sure we have proper current size locally" -for device in $(multipath -ll 3${WWID} | egrep '^ ' | awk '{print $2}'); do +for device in $(multipath -ll 3${WWID} | grep -E '^ ' | awk '{print $2}'); do echo "1" > /sys/bus/scsi/drivers/sd/${device}/rescan; done diff --git a/scripts/storage/multipath/resizeVolume.sh b/scripts/storage/multipath/resizeVolume.sh index 1b44a71b46ae..491c1bd93a1c 100755 --- a/scripts/storage/multipath/resizeVolume.sh +++ b/scripts/storage/multipath/resizeVolume.sh @@ -51,7 +51,7 @@ systemctl is-active multipathd || systemctl restart multipathd || { logger -t "CS_SCSI_VOL_RESIZE" "${WWID} resizing disk path at /dev/mapper/3${WWID} STARTING" -for device in $(multipath -ll 3${WWID} | egrep '^ ' | awk '{print $2}'); do +for device in $(multipath -ll 3${WWID} | grep -E '^ ' | awk '{print $2}'); do echo "1" > /sys/bus/scsi/drivers/sd/${device}/rescan; done diff --git a/scripts/util/keystore-setup b/scripts/util/keystore-setup index 1e1237cde04c..88f5a87d6095 100755 --- a/scripts/util/keystore-setup +++ b/scripts/util/keystore-setup @@ -75,7 +75,7 @@ keytool -genkey -storepass "$KS_PASS" -keypass "$KS_PASS" -alias "$ALIAS" -keyal # Generate CSR $LOGGER_CMD "Generating CSR" [ -f "$CSR_FILE" ] && rm -f "$CSR_FILE" -addresses=$(ip address | grep inet | awk '{print $2}' | sed 's/\/.*//g' | grep -v '^169.254.' | grep -v '^127.0.0.1' | egrep -v '^::1|^fe80' | grep -v '^::1' | sed 's/^/ip:/g' | tr '\r\n' ',') +addresses=$(ip address | grep inet | awk '{print $2}' | sed 's/\/.*//g' | grep -v '^169.254.' | grep -v '^127.0.0.1' | grep -E -v '^::1|^fe80' | grep -v '^::1' | sed 's/^/ip:/g' | tr '\r\n' ',') $LOGGER_CMD "Found following SAN addresses to add to CSR: ${addresses}" keytool -certreq -storepass "$KS_PASS" -alias "$ALIAS" -file "$CSR_FILE" -keystore "$KS_FILE" -ext san="$addresses" 2>&1 | $LOGGER_CMD if [ $? -ne 0 ];then diff --git a/scripts/vm/network/ovs-pvlan-kvm-vm.sh b/scripts/vm/network/ovs-pvlan-kvm-vm.sh index c8da75f64fbe..b28dbda065e4 100755 --- a/scripts/vm/network/ovs-pvlan-kvm-vm.sh +++ b/scripts/vm/network/ovs-pvlan-kvm-vm.sh @@ -112,7 +112,7 @@ find_port_group() { } # try to find the physical link to outside, only supports eth and em prefix now -trunk_port=`ovs-ofctl show $br | egrep "\((eth|em)[0-9]" | cut -d '(' -f 1|tr -d ' '` +trunk_port=`ovs-ofctl show $br | grep -E "\((eth|em)[0-9]" | cut -d '(' -f 1|tr -d ' '` vm_port=$(find_port $vm_mac) # craft the vlan headers. Adding 4096 as in hex, it must be of the form 0x1XXX diff --git a/scripts/vm/network/ovs-pvlan-vm.sh b/scripts/vm/network/ovs-pvlan-vm.sh index 95054c8a3ab3..b55377f24910 100755 --- a/scripts/vm/network/ovs-pvlan-vm.sh +++ b/scripts/vm/network/ovs-pvlan-vm.sh @@ -87,7 +87,7 @@ then fi # try to find the physical link to outside, only supports eth and em prefix now -trunk_port=`ovs-ofctl show $br | egrep "\((eth|em)[0-9]" | cut -d '(' -f 1|tr -d ' '` +trunk_port=`ovs-ofctl show $br | grep -E "\((eth|em)[0-9]" | cut -d '(' -f 1|tr -d ' '` if [ "$op" == "add" ] then diff --git a/server/src/main/java/com/cloud/server/StatsCollector.java b/server/src/main/java/com/cloud/server/StatsCollector.java index a0d9c09c3061..abc2257b00aa 100644 --- a/server/src/main/java/com/cloud/server/StatsCollector.java +++ b/server/src/main/java/com/cloud/server/StatsCollector.java @@ -986,7 +986,7 @@ private double getSystemCpuCyclesTotal() { double totalcpucap = 0; if (StringUtils.isEmpty(cpucaps)) { String totalCpus = Script.runSimpleBashScript("nproc --all| tr '\\n' \" \""); - String maxCpuSpeed = Script.runSimpleBashScript("lscpu | egrep 'CPU max MHz' | head -1 | cut -f 2 -d : | tr -d ' '| tr '\\n' \" \""); + String maxCpuSpeed = Script.runSimpleBashScript("lscpu | grep -E 'CPU max MHz' | head -1 | cut -f 2 -d : | tr -d ' '| tr '\\n' \" \""); if (StringUtils.isNotEmpty(totalCpus) && StringUtils.isNotEmpty(maxCpuSpeed)) { totalcpucap = Double.parseDouble(totalCpus) * Double.parseDouble(maxCpuSpeed); } diff --git a/systemvm/agent/scripts/ssvm-check.sh b/systemvm/agent/scripts/ssvm-check.sh index f5d69cb45488..86cecb75719c 100755 --- a/systemvm/agent/scripts/ssvm-check.sh +++ b/systemvm/agent/scripts/ssvm-check.sh @@ -41,7 +41,7 @@ isCifs() { # ping dns server echo ================================================ -DNSSERVER=`egrep '^nameserver' /etc/resolv.conf | awk '{print $2}'| head -1` +DNSSERVER=`grep -E '^nameserver' /etc/resolv.conf | awk '{print $2}'| head -1` echo "First DNS server is " $DNSSERVER ping -c 2 $DNSSERVER if [ $? -eq 0 ] diff --git a/systemvm/debian/opt/cloud/bin/update_interface_config.sh b/systemvm/debian/opt/cloud/bin/update_interface_config.sh index 53d81f7602f4..427d5d9abd58 100755 --- a/systemvm/debian/opt/cloud/bin/update_interface_config.sh +++ b/systemvm/debian/opt/cloud/bin/update_interface_config.sh @@ -31,7 +31,7 @@ get_interface() { for i in `seq 1 $(($timeout))` do #inf=$(ip route list ${1}/${2} | awk '{print $3}') - inf=$(ip addr show|egrep '^ *inet'|grep ${1}/${2} |grep brd|awk -- '{ print $NF; }') + inf=$(ip addr show|grep -E '^ *inet'|grep ${1}/${2} |grep brd|awk -- '{ print $NF; }') if [ ! -z $inf ]; then echo $inf break diff --git a/test/integration/component/test_multiple_subnets_in_isolated_network.py b/test/integration/component/test_multiple_subnets_in_isolated_network.py index 278728b2adbb..f5efd9ac893d 100644 --- a/test/integration/component/test_multiple_subnets_in_isolated_network.py +++ b/test/integration/component/test_multiple_subnets_in_isolated_network.py @@ -210,9 +210,9 @@ def verify_router_publicnic_state(self, router, host, publicNics): self.logger.debug("Skip as redundant_state is %s" % redundant_state) return elif redundant_state == "PRIMARY": - command = 'ip link show |grep BROADCAST | egrep "%s" |grep "state DOWN" |wc -l' % publicNics + command = 'ip link show |grep BROADCAST | grep -E "%s" |grep "state DOWN" |wc -l' % publicNics elif redundant_state == "BACKUP": - command = 'ip link show |grep BROADCAST | egrep "%s" |grep "state UP" |wc -l' % publicNics + command = 'ip link show |grep BROADCAST | grep -E "%s" |grep "state UP" |wc -l' % publicNics result = get_process_status( host.ipaddress, host.port, diff --git a/test/integration/component/test_multiple_subnets_in_isolated_network_rvr.py b/test/integration/component/test_multiple_subnets_in_isolated_network_rvr.py index d83571f9210e..b6c6434f29b5 100644 --- a/test/integration/component/test_multiple_subnets_in_isolated_network_rvr.py +++ b/test/integration/component/test_multiple_subnets_in_isolated_network_rvr.py @@ -210,9 +210,9 @@ def verify_router_publicnic_state(self, router, host, publicNics): self.logger.debug("Skip as redundant_state is %s" % redundant_state) return elif redundant_state == "PRIMARY": - command = 'ip link show |grep BROADCAST | egrep "%s" |grep "state DOWN" |wc -l' % publicNics + command = 'ip link show |grep BROADCAST | grep -E "%s" |grep "state DOWN" |wc -l' % publicNics elif redundant_state == "BACKUP": - command = 'ip link show |grep BROADCAST | egrep "%s" |grep "state UP" |wc -l' % publicNics + command = 'ip link show |grep BROADCAST | grep -E "%s" |grep "state UP" |wc -l' % publicNics result = get_process_status( host.ipaddress, host.port, diff --git a/test/integration/component/test_multiple_subnets_in_vpc.py b/test/integration/component/test_multiple_subnets_in_vpc.py index 9167f156e19f..020665969959 100644 --- a/test/integration/component/test_multiple_subnets_in_vpc.py +++ b/test/integration/component/test_multiple_subnets_in_vpc.py @@ -214,9 +214,9 @@ def verify_router_publicnic_state(self, router, host, publicNics): self.logger.debug("Skip as redundant_state is %s" % redundant_state) return elif redundant_state == "PRIMARY": - command = 'ip link show |grep BROADCAST | egrep "%s" |grep "state DOWN" |wc -l' % publicNics + command = 'ip link show |grep BROADCAST | grep -E "%s" |grep "state DOWN" |wc -l' % publicNics elif redundant_state == "BACKUP": - command = 'ip link show |grep BROADCAST | egrep "%s" |grep "state UP" |wc -l' % publicNics + command = 'ip link show |grep BROADCAST | grep -E "%s" |grep "state UP" |wc -l' % publicNics result = get_process_status( host.ipaddress, host.port, diff --git a/test/integration/component/test_multiple_subnets_in_vpc_rvr.py b/test/integration/component/test_multiple_subnets_in_vpc_rvr.py index 7c7127307b5c..e8963f187554 100644 --- a/test/integration/component/test_multiple_subnets_in_vpc_rvr.py +++ b/test/integration/component/test_multiple_subnets_in_vpc_rvr.py @@ -214,9 +214,9 @@ def verify_router_publicnic_state(self, router, host, publicNics): self.logger.debug("Skip as redundant_state is %s" % redundant_state) return elif redundant_state == "PRIMARY": - command = 'ip link show |grep BROADCAST | egrep "%s" |grep "state DOWN" |wc -l' % publicNics + command = 'ip link show |grep BROADCAST | grep -E "%s" |grep "state DOWN" |wc -l' % publicNics elif redundant_state == "BACKUP": - command = 'ip link show |grep BROADCAST | egrep "%s" |grep "state UP" |wc -l' % publicNics + command = 'ip link show |grep BROADCAST | grep -E "%s" |grep "state UP" |wc -l' % publicNics result = get_process_status( host.ipaddress, host.port,