Add exception handling.

- Add first exception handling to get_manager_info.
  Maybe I will have to factorise that later...
This commit is contained in:
Uggla
2016-01-02 19:58:53 +01:00
parent 1546517a7d
commit 657a294cba

View File

@@ -229,13 +229,22 @@ if __name__ == '__main__':
else: else:
simulator = False simulator = False
enforceSSL = True enforceSSL = True
remote_mgmt = redfish.connect(connection_parameters['url'], try:
connection_parameters['login'], print 'Gathering data from manager, please wait...'
connection_parameters['password'], # TODO : Add a rotating star showing program is running ?
verify_cert=check_SSL, # Could be a nice exercice for learning python
simulator=simulator, logger.info('Gathering data from manager')
enforceSSL=enforceSSL 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()) print ('Redfish API version : %s \n' % remote_mgmt.get_api_version())