Skip to content

Commit

Permalink
Merge pull request #115 from intracom-telecom-sdn/develop_fix_exceptions
Browse files Browse the repository at this point in the history
Fixing issue in catching exceptions
  • Loading branch information
konstantinos-papadopoulos authored Mar 7, 2017
2 parents 883c4b2 + 5b89188 commit 2dd0eb6
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 29 deletions.
15 changes: 9 additions & 6 deletions stress_test/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,20 +511,23 @@ def __del__(self):
try:
logging.info('Run controller stop.')
self.stop()
except:
pass
except Exception as e:
logging.info('Fail stopping Controller during cleanup. '
'Exception message: {0}'.format(e))

try:
logging.info('Run controller cleanup.')
self.cleanup()
except:
pass
except Exception as e:
logging.info('Fail cleaning Controller files during cleanup. '
'Exception message: {0}'.format(e))

try:
logging.info('Close controller node ssh connection.')
self._ssh_conn.close()
except:
pass
except Exception as e:
logging.info('Fail closing ssh Controller node connection during '
'cleanup. Exception message: {0}'.format(e))


class ODL(Controller):
Expand Down
12 changes: 10 additions & 2 deletions stress_test/nbemu.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,16 @@ def run(self):
def __del__(self):
"""
Method called when object is destroyed"""
try:
logging.info('Cleaning NB-Generator.')
self.clean()
except Exception as e:
logging.info('Fail cleaning NB-Generator during '
'cleanup. Exception message: {0}'.format(e))

try:
logging.info('Closing NB-Generator ssh connection.')
self._ssh_conn.close()
except:
pass
except Exception as e:
logging.info('Fail closing ssh NB-Generator node connection during '
'cleanup. Exception message: {0}'.format(e))
15 changes: 9 additions & 6 deletions stress_test/oftraf.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,17 +292,20 @@ def __del__(self):
try:
logging.info('Run oftraf stop.')
self.stop()
except:
pass
except Exception as e:
logging.info('Fail stopping oftraf during cleanup. '
'Exception message: {0}'.format(e))

try:
logging.info('Run oftraf cleanup.')
self.clean()
except:
pass
except Exception as e:
logging.info('Fail cleaning oftraf files during cleanup. '
'Exception message: {0}'.format(e))

try:
logging.info('Close oftraf node ssh connection.')
self._ssh_conn.close()
except:
pass
except Exception as e:
logging.info('Fail closing ssh oftraf node connection during '
'cleanup. Exception message: {0}'.format(e))
24 changes: 13 additions & 11 deletions stress_test/sbemu.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,17 @@ def __del__(self):
Method called when object is destroyed
"""
try:
logging.info('Run emulator clean handler.')
self.cleanup()
except:
pass

logging.info('Run SB-Emulator clean handler.')
self.clean()
except Exception as e:
logging.info('Fail cleaning SB-Emulator during '
'cleanup. Exception message: {0}'.format(e))
try:
logging.info('Close emulator node ssh connection.')
self._ssh_conn.close()
except:
pass
except Exception as e:
logging.info('Fail closing ssh SB-Emulator node connection during '
'cleanup. Exception message: {0}'.format(e))


class MTCBench(SBEmu):
Expand Down Expand Up @@ -628,7 +629,7 @@ def get_flows(self, new_ssh_conn=None):
:rtype: str
:type new_ssh_conn: paramiko.SFTPClient
:raises IOError: if the handler does not exist on the remote host
:raises emulator_exceptions.MultinetGetFlowsError: if handler fails to \
:raises emulator_exceptions.MultinetGetFlowsError: if handler fails to
run successfully
"""
logging.info('[Multinet] get_flows')
Expand Down Expand Up @@ -714,7 +715,7 @@ def start_topos(self):
Wrapper to the Multinet SB-Emulator start_topos handler
:raises IOError: if the handler does not exist on the remote host
:raises emulator_exceptions.MultinetStartToposError: if Multinet start \
:raises emulator_exceptions.MultinetStartToposError: if Multinet start
topology handler fails
"""
logging.info('[Multinet] start_topos')
Expand Down Expand Up @@ -873,6 +874,7 @@ def __del__(self):
try:
logging.info('Run Multinet cleanup.')
self.cleanup()
except:
pass
except Exception as e:
logging.info('Fail cleaning Multinet during '
'cleanup. Exception message: {0}'.format(e))
super(self.__class__, self).__del__()
9 changes: 5 additions & 4 deletions util/netutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ def copy_dir_local_to_remote(ip, ssh_port, username, password,
try:
folder_to_make = os.path.join(remote_path, walker[0])
sftp.mkdir(folder_to_make)
except:
pass
except Exception as e:
logging.error('Fail to create remote directory path. {0}'.
format(e))
for curr_file in walker[2]:
local_file = os.path.join(walker[0], curr_file)
remote_file = os.path.join(remote_path, walker[0], curr_file)
Expand Down Expand Up @@ -272,8 +273,8 @@ def ssh_connection_close(sftp, transport_layer):
try:
sftp.close()
transport_layer.close()
except:
pass
except Exception as e:
logging.error('Fail during closing connection. {0}'.format(e))


def ssh_connection_open(ip, ssh_port, username, password):
Expand Down

0 comments on commit 2dd0eb6

Please sign in to comment.