Blob Blame History Raw
From c9c4eb476e9b9e3e00b08811aae0aba7dabc2e4a Mon Sep 17 00:00:00 2001
From: Mohammed Gamal <mgamal@redhat.com>
Date: Tue, 21 Jun 2022 15:58:49 +0200
Subject: [PATCH] redhat: Fix command sequence for restarting net interface

RH-Author: Mohamed Gamal Morsy <mmorsy@redhat.com>
RH-MergeRequest: 3: redhat: Fix command sequence for restarting net interface
RH-Commit: [1/1] 32849039225dbb0b912730a232bba21ca2a94b19
RH-Bugzilla: 2098083
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2098083

Apparently the down and up commands need to be run in the same command, so
connect them together with "&&" operator

Signed-off-by: Mohammed Gamal <mgamal@redhat.com>
---
 azurelinuxagent/common/osutil/redhat.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/azurelinuxagent/common/osutil/redhat.py b/azurelinuxagent/common/osutil/redhat.py
index a02647cd..840f7a1d 100644
--- a/azurelinuxagent/common/osutil/redhat.py
+++ b/azurelinuxagent/common/osutil/redhat.py
@@ -150,8 +150,7 @@ class RedhatOSUtil(Redhat6xOSUtil):
         retry_limit=retries+1
         for attempt in range(1, retry_limit):
             try:
-                shellutil.run_command(["ip", "link", "set", ifname, "down"])
-                shellutil.run_command(["ip", "link", "set", ifname, "up"])
+                shellutil.run_command(["ip", "link", "set", ifname, "down", "&&", "ip", "link", "set", ifname, "up"])
 
             except shellutil.CommandError as cmd_err:
                 logger.warn("failed to restart {0}: return code {1}".format(ifname, cmd_err.returncode))
-- 
2.31.1