Skip to content

Commit 2f734f7

Browse files
author
“Shaik
committed
Fix: Safely quit remote session by checking remotehost_public attribute
Added a guard to verify `remotehost_public` exists before accessing it to prevent attribute errors during session cleanup. Updated across: tcpdump.py, perf_test.py, netperf_test.py, uperf_test.py, network_test.py and multiport_stress.py. Signed-off-by: “Shaik <“shaik.abdulla1@ibm.com”>
1 parent db6934e commit 2f734f7

File tree

6 files changed

+12
-6
lines changed

6 files changed

+12
-6
lines changed

io/net/iperf_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,5 +259,6 @@ def tearDown(self):
259259
if self.hbond:
260260
self.networkinterface.restore_slave_cfg_file()
261261
self.remotehost.remote_session.quit()
262-
self.remotehost_public.remote_session.quit()
262+
if hasattr(self, 'remotehost_public'):
263+
self.remotehost_public.remote_session.quit()
263264
self.session.quit()

io/net/multiport_stress.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,5 @@ def tearDown(self):
149149
self.log.info(
150150
"backup file not available, could not restore file.")
151151
self.remotehost.remote_session.quit()
152-
self.remotehost_public.remote_session.quit()
152+
if hasattr(self, 'remotehost_public'):
153+
self.remotehost_public.remote_session.quit()

io/net/netperf_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,5 +221,6 @@ def tearDown(self):
221221
except Exception:
222222
self.log.info("backup file not available, could not restore file.")
223223
self.remotehost.remote_session.quit()
224-
self.remotehost_public.remote_session.quit()
224+
if hasattr(self, 'remotehost_public'):
225+
self.remotehost_public.remote_session.quit()
225226
self.session.quit()

io/net/network_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ def tearDown(self):
346346
self.log.info(
347347
"backup file not available, could not restore file.")
348348
self.remotehost.remote_session.quit()
349-
self.remotehost_public.remote_session.quit()
349+
if hasattr(self, 'remotehost_public'):
350+
self.remotehost_public.remote_session.quit()
350351
if 'scp' or 'ssh' in str(self.name.name):
351352
self.session.quit()

io/net/tcpdump.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,5 @@ def tearDown(self):
192192
self.log.info(
193193
"backup file not available, could not restore file.")
194194
self.remotehost.remote_session.quit()
195-
self.remotehost_public.remote_session.quit()
195+
if hasattr(self, 'remotehost_public'):
196+
self.remotehost_public.remote_session.quit()

io/net/uperf_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,5 +221,6 @@ def tearDown(self):
221221
self.log.info(
222222
"backup file not available, could not restore file.")
223223
self.remotehost.remote_session.quit()
224-
self.remotehost_public.remote_session.quit()
224+
if hasattr(self, 'remotehost_public'):
225+
self.remotehost_public.remote_session.quit()
225226
self.session.quit()

0 commit comments

Comments
 (0)