From 657a294cba6222718196611a875a5b1633162eaa Mon Sep 17 00:00:00 2001 From: Uggla Date: Sat, 2 Jan 2016 19:58:53 +0100 Subject: [PATCH] Add exception handling. - Add first exception handling to get_manager_info. Maybe I will have to factorise that later... --- redfish-client/redfish-client.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/redfish-client/redfish-client.py b/redfish-client/redfish-client.py index 5e90f7d..deb5121 100755 --- a/redfish-client/redfish-client.py +++ b/redfish-client/redfish-client.py @@ -229,13 +229,22 @@ if __name__ == '__main__': else: simulator = False enforceSSL = True - remote_mgmt = redfish.connect(connection_parameters['url'], - connection_parameters['login'], - connection_parameters['password'], - verify_cert=check_SSL, - simulator=simulator, - enforceSSL=enforceSSL - ) + try: + print 'Gathering data from manager, please wait...' + # TODO : Add a rotating star showing program is running ? + # Could be a nice exercice for learning python + logger.info('Gathering data from manager') + remote_mgmt = redfish.connect(connection_parameters['url'], + connection_parameters['login'], + connection_parameters['password'], + verify_cert=check_SSL, + simulator=simulator, + enforceSSL=enforceSSL + ) + except redfish.exception.RedfishException as e: + sys.stderr.write(str(e.message)) + sys.stderr.write(str(e.advices)) + sys.exit(1) print ('Redfish API version : %s \n' % remote_mgmt.get_api_version())