Skip to content

Commit 2dd0eb6

Browse files
Merge pull request #115 from intracom-telecom-sdn/develop_fix_exceptions
Fixing issue in catching exceptions
2 parents 883c4b2 + 5b89188 commit 2dd0eb6

File tree

5 files changed

+46
-29
lines changed

5 files changed

+46
-29
lines changed

stress_test/controller.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -511,20 +511,23 @@ def __del__(self):
511511
try:
512512
logging.info('Run controller stop.')
513513
self.stop()
514-
except:
515-
pass
514+
except Exception as e:
515+
logging.info('Fail stopping Controller during cleanup. '
516+
'Exception message: {0}'.format(e))
516517

517518
try:
518519
logging.info('Run controller cleanup.')
519520
self.cleanup()
520-
except:
521-
pass
521+
except Exception as e:
522+
logging.info('Fail cleaning Controller files during cleanup. '
523+
'Exception message: {0}'.format(e))
522524

523525
try:
524526
logging.info('Close controller node ssh connection.')
525527
self._ssh_conn.close()
526-
except:
527-
pass
528+
except Exception as e:
529+
logging.info('Fail closing ssh Controller node connection during '
530+
'cleanup. Exception message: {0}'.format(e))
528531

529532

530533
class ODL(Controller):

stress_test/nbemu.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,16 @@ def run(self):
261261
def __del__(self):
262262
"""
263263
Method called when object is destroyed"""
264+
try:
265+
logging.info('Cleaning NB-Generator.')
266+
self.clean()
267+
except Exception as e:
268+
logging.info('Fail cleaning NB-Generator during '
269+
'cleanup. Exception message: {0}'.format(e))
270+
264271
try:
265272
logging.info('Closing NB-Generator ssh connection.')
266273
self._ssh_conn.close()
267-
except:
268-
pass
274+
except Exception as e:
275+
logging.info('Fail closing ssh NB-Generator node connection during '
276+
'cleanup. Exception message: {0}'.format(e))

stress_test/oftraf.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -292,17 +292,20 @@ def __del__(self):
292292
try:
293293
logging.info('Run oftraf stop.')
294294
self.stop()
295-
except:
296-
pass
295+
except Exception as e:
296+
logging.info('Fail stopping oftraf during cleanup. '
297+
'Exception message: {0}'.format(e))
297298

298299
try:
299300
logging.info('Run oftraf cleanup.')
300301
self.clean()
301-
except:
302-
pass
302+
except Exception as e:
303+
logging.info('Fail cleaning oftraf files during cleanup. '
304+
'Exception message: {0}'.format(e))
303305

304306
try:
305307
logging.info('Close oftraf node ssh connection.')
306308
self._ssh_conn.close()
307-
except:
308-
pass
309+
except Exception as e:
310+
logging.info('Fail closing ssh oftraf node connection during '
311+
'cleanup. Exception message: {0}'.format(e))

stress_test/sbemu.py

+13-11
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,17 @@ def __del__(self):
201201
Method called when object is destroyed
202202
"""
203203
try:
204-
logging.info('Run emulator clean handler.')
205-
self.cleanup()
206-
except:
207-
pass
208-
204+
logging.info('Run SB-Emulator clean handler.')
205+
self.clean()
206+
except Exception as e:
207+
logging.info('Fail cleaning SB-Emulator during '
208+
'cleanup. Exception message: {0}'.format(e))
209209
try:
210210
logging.info('Close emulator node ssh connection.')
211211
self._ssh_conn.close()
212-
except:
213-
pass
212+
except Exception as e:
213+
logging.info('Fail closing ssh SB-Emulator node connection during '
214+
'cleanup. Exception message: {0}'.format(e))
214215

215216

216217
class MTCBench(SBEmu):
@@ -628,7 +629,7 @@ def get_flows(self, new_ssh_conn=None):
628629
:rtype: str
629630
:type new_ssh_conn: paramiko.SFTPClient
630631
:raises IOError: if the handler does not exist on the remote host
631-
:raises emulator_exceptions.MultinetGetFlowsError: if handler fails to \
632+
:raises emulator_exceptions.MultinetGetFlowsError: if handler fails to
632633
run successfully
633634
"""
634635
logging.info('[Multinet] get_flows')
@@ -714,7 +715,7 @@ def start_topos(self):
714715
Wrapper to the Multinet SB-Emulator start_topos handler
715716
716717
:raises IOError: if the handler does not exist on the remote host
717-
:raises emulator_exceptions.MultinetStartToposError: if Multinet start \
718+
:raises emulator_exceptions.MultinetStartToposError: if Multinet start
718719
topology handler fails
719720
"""
720721
logging.info('[Multinet] start_topos')
@@ -873,6 +874,7 @@ def __del__(self):
873874
try:
874875
logging.info('Run Multinet cleanup.')
875876
self.cleanup()
876-
except:
877-
pass
877+
except Exception as e:
878+
logging.info('Fail cleaning Multinet during '
879+
'cleanup. Exception message: {0}'.format(e))
878880
super(self.__class__, self).__del__()

util/netutil.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ def copy_dir_local_to_remote(ip, ssh_port, username, password,
4343
try:
4444
folder_to_make = os.path.join(remote_path, walker[0])
4545
sftp.mkdir(folder_to_make)
46-
except:
47-
pass
46+
except Exception as e:
47+
logging.error('Fail to create remote directory path. {0}'.
48+
format(e))
4849
for curr_file in walker[2]:
4950
local_file = os.path.join(walker[0], curr_file)
5051
remote_file = os.path.join(remote_path, walker[0], curr_file)
@@ -272,8 +273,8 @@ def ssh_connection_close(sftp, transport_layer):
272273
try:
273274
sftp.close()
274275
transport_layer.close()
275-
except:
276-
pass
276+
except Exception as e:
277+
logging.error('Fail during closing connection. {0}'.format(e))
277278

278279

279280
def ssh_connection_open(ip, ssh_port, username, password):

0 commit comments

Comments
 (0)