From b809e8951dbb062b72a7e27e25de7e267b393823 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Tue, 29 Jul 2025 10:09:24 +0530 Subject: [PATCH 1/3] cloudutils: fix warning, error during kvm agent installation Fixes #10379 Signed-off-by: Abhishek Kumar --- python/lib/cloudutils/configFileOps.py | 8 ++++---- python/lib/cloudutils/networkConfig.py | 7 +++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/python/lib/cloudutils/configFileOps.py b/python/lib/cloudutils/configFileOps.py index c061071b96ee..f4d704af783f 100644 --- a/python/lib/cloudutils/configFileOps.py +++ b/python/lib/cloudutils/configFileOps.py @@ -68,14 +68,14 @@ def save(self): for entry in self.entries: if entry.op == "add": if entry.separator == "=": - matchString = "^\ *" + entry.name + ".*" + matchString = r"^\ *" + entry.name + ".*" elif entry.separator == " ": - matchString = "^\ *" + entry.name + "\ *" + entry.value + matchString = r"^\ *" + entry.name + r"\ *" + entry.value else: if entry.separator == "=": - matchString = "^\ *" + entry.name + "\ *=\ *" + entry.value + matchString = r"^\ *" + entry.name + r"\ *=\ *" + entry.value else: - matchString = "^\ *" + entry.name + "\ *" + entry.value + matchString = r"^\ *" + entry.name + r"\ *" + entry.value match = re.match(matchString, line) if match is not None: diff --git a/python/lib/cloudutils/networkConfig.py b/python/lib/cloudutils/networkConfig.py index ac51f92aa582..ca2033680ca3 100644 --- a/python/lib/cloudutils/networkConfig.py +++ b/python/lib/cloudutils/networkConfig.py @@ -45,8 +45,11 @@ def getDefaultNetwork(): if not cmd.isSuccess(): logging.debug("Failed to get default route") raise CloudRuntimeException("Failed to get default route") - - result = cmd.getStdout().split(" ") + output = cmd.getStdout().strip() + result = output.split(" ") + if len(result) < 2: + logging.debug("Output for the default route incomplete: %s. It should have been ' '" % output) + raise CloudRuntimeException("Output for the default route incomplete") gateway = result[0] dev = result[1] From 034160a7eb308cced6a13f4b1bcb1850b66b6b43 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 13 Oct 2025 11:16:15 +0530 Subject: [PATCH 2/3] fix Signed-off-by: Abhishek Kumar --- python/lib/cloudutils/networkConfig.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/lib/cloudutils/networkConfig.py b/python/lib/cloudutils/networkConfig.py index ca2033680ca3..827664bbc738 100644 --- a/python/lib/cloudutils/networkConfig.py +++ b/python/lib/cloudutils/networkConfig.py @@ -153,10 +153,10 @@ def getDevInfo(dev): if line.find("HWaddr") != -1: macAddr = line.split("HWaddr ")[1].strip(" ") elif line.find("inet ") != -1: - m = re.search("addr:(.*)\ *Bcast:(.*)\ *Mask:(.*)", line) + m = re.search(r"addr:([^\s]+)\s*Bcast:([^\s]+)\s*Mask:([^\s]+)", line) if m is not None: - ipAddr = m.group(1).rstrip(" ") - netmask = m.group(3).rstrip(" ") + ipAddr = m.group(1).strip() + netmask = m.group(3).strip() if networkConfig.isBridgePort(dev): type = "brport" From da0dc45c9124f2b62ed0dd1af591f768e4e4f6bd Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Wed, 15 Oct 2025 22:16:02 +0530 Subject: [PATCH 3/3] Update utilities.py --- python/lib/cloudutils/utilities.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/lib/cloudutils/utilities.py b/python/lib/cloudutils/utilities.py index ce50516193e6..95044de55586 100755 --- a/python/lib/cloudutils/utilities.py +++ b/python/lib/cloudutils/utilities.py @@ -63,7 +63,7 @@ def getStdout(self): return self.stdout.decode('utf-8').strip('\n') def getLines(self): - return self.stdout.decode('utf-8').strip('\n') + return self.stdout.decode('utf-8').strip('\n').split('\n') def getStderr(self): return self.stderr.decode('utf-8').strip('\n')