From: dliu5 Date: Tue, 8 Nov 2022 05:41:38 +0000 (+0800) Subject: Improve the ssl connection handle log message. X-Git-Tag: 2.0.0-rc2~35^2 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=242185955154b1d709c2fdbce5445e4aae8058ac;p=pti%2Fo2.git Improve the ssl connection handle log message. Fix auth header exception handling to avoid 500. Signed-off-by: dliu5 Change-Id: I7fb0d11584f6e575ba891a51bebd7631faef7505 --- diff --git a/o2common/authmw/authmiddleware.py b/o2common/authmw/authmiddleware.py index 13be910..032e735 100644 --- a/o2common/authmw/authmiddleware.py +++ b/o2common/authmw/authmiddleware.py @@ -61,8 +61,7 @@ class authmiddleware(): logger.info(__name__ + 'authentication middleware') req = Request(environ, populate_request=True, shallow=True) try: - auth_header = req.headers['Authorization'] - + auth_header = req.headers.get('Authorization', None) if auth_header: auth_token = auth_header.split(" ")[1] diff --git a/o2ims/service/command/notify_alarm_handler.py b/o2ims/service/command/notify_alarm_handler.py index 11729a4..b4e22a1 100644 --- a/o2ims/service/command/notify_alarm_handler.py +++ b/o2ims/service/command/notify_alarm_handler.py @@ -69,8 +69,9 @@ def callback_smo(sub: AlarmSubscription, msg: AlarmEvent2SMO): return logger.error('Notify alarm Response code is: {}'.format(status)) except ssl.SSLCertVerificationError as e: - logger.info( - 'Notify alarm post data with trusted ca failed: {}'.format(e)) + logger.debug( + 'Notify alarm try to post data with trusted ca \ + failed: {}'.format(e)) if 'self signed' in str(e): conn = get_https_conn_selfsigned(o.netloc) try: diff --git a/o2ims/service/command/notify_handler.py b/o2ims/service/command/notify_handler.py index fe22f2a..8f134af 100644 --- a/o2ims/service/command/notify_handler.py +++ b/o2ims/service/command/notify_handler.py @@ -102,7 +102,8 @@ def callback_smo(sub: Subscription, msg: Message2SMO): return logger.error('Notify Response code is: {}'.format(status)) except ssl.SSLCertVerificationError as e: - logger.info('Notify post data with trusted ca failed: {}'.format(e)) + logger.debug( + 'Notify try to post data with trusted ca failed: {}'.format(e)) if 'self signed' in str(e): conn = get_https_conn_selfsigned(o.netloc) try: diff --git a/o2ims/service/command/registration_handler.py b/o2ims/service/command/registration_handler.py index aead4cc..c144405 100644 --- a/o2ims/service/command/registration_handler.py +++ b/o2ims/service/command/registration_handler.py @@ -108,7 +108,8 @@ def call_smo(reg_data: dict): try: return post_data(conn, o.path, callback_data) except ssl.SSLCertVerificationError as e: - logger.info('Register to smo with trusted ca failed: {}'.format(e)) + logger.debug('Try to register to smo with \ + trusted ca failed: {}'.format(e)) if 'self signed' in str(e): conn = get_https_conn_selfsigned(o.netloc) try: