From 970b2bf6a441e847729734322b8d086614d48081 Mon Sep 17 00:00:00 2001 From: Alex O'Rourke Date: Mon, 26 Oct 2015 15:09:39 -0700 Subject: [PATCH] Allow suppressing of SSL log warnings Currently there is no way to suppress this warning, making the log file bogged down with these messages. There should be an override flag that allows you to willingly disabled these log messages. Change-Id: Ie8a65feb2e9c3cfb666861157e2236e90e25ee29 --- docs/api/hpelefthandclient/http.rst | 3 ++- docs/changelog.rst | 5 +++++ docs/tutorial.rst | 4 ++-- hpelefthandclient/__init__.py | 2 +- hpelefthandclient/http.py | 8 +++++++- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/docs/api/hpelefthandclient/http.rst b/docs/api/hpelefthandclient/http.rst index 71754f5..7bbb0d4 100644 --- a/docs/api/hpelefthandclient/http.rst +++ b/docs/api/hpelefthandclient/http.rst @@ -4,7 +4,8 @@ .. automodule:: hpelefthandclient.http :synopsis: HTTP REST Base Class - .. autoclass:: hpelefthandclient.http.HTTPJSONRESTClient(api_url, [secure=True[,http_log_debug=False]]) + .. autoclass:: hpelefthandclient.http.HTTPJSONRESTClient(api_url, secure=True, http_log_debug=False, + suppress_ssl_warnings=False) .. automethod:: authenticate .. automethod:: unauthenticate diff --git a/docs/changelog.rst b/docs/changelog.rst index 3bba548..cdede51 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -87,3 +87,8 @@ Changes in Version 2.0.0 * Rebranded the HPLeftHandClient to HPELeftHandClient. * Updating the documentation to use the new PyPi project name for the client, 'python-lefthandclient'. + +Changes in Version 2.0.1 +------------------------ + +* Allows suppressing of InsecureRequestWarning messages diff --git a/docs/tutorial.rst b/docs/tutorial.rst index d50dbb1..5427bd9 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -34,12 +34,12 @@ Doing so is easy: # SSL certification verification is defaulted to False. In order to # override this, set secure=True. or secure='/path/to/cert.crt' # cl = client.HPELeftHandClient("https://10.10.10.10:8081/lhos", - # secure=True) + # secure=True) # Or, to use ca certificates as documented by Python Requests, # pass in the ca-certificates.crt file # http://docs.python-requests.org/en/v1.0.4/user/advanced # cl = client.HPELeftHandClient("https://10.10.10.10:8081/lhos", - # secure='/etc/ssl/certs/ca-certificates.crt') + # secure='/etc/ssl/certs/ca-certificates.crt') try: cl.login(username, password) diff --git a/hpelefthandclient/__init__.py b/hpelefthandclient/__init__.py index fda3601..bdf8a40 100644 --- a/hpelefthandclient/__init__.py +++ b/hpelefthandclient/__init__.py @@ -24,7 +24,7 @@ HPE LeftHand REST Client """ -version_tuple = (2, 0, 0) +version_tuple = (2, 0, 1) def get_version_string(): diff --git a/hpelefthandclient/http.py b/hpelefthandclient/http.py index e52a76b..402cb2e 100644 --- a/hpelefthandclient/http.py +++ b/hpelefthandclient/http.py @@ -50,6 +50,9 @@ class HTTPJSONRESTClient(object): :type secure: bool :param http_log_debug: Turns on http log debugging. Default will not log :type http_log_debug: bool + :param suppress_ssl_warnings: Suppresses log warning messages if True. + Default will not suppress warnings. + :type suppress_ssl_warnings: bool """ @@ -60,7 +63,10 @@ class HTTPJSONRESTClient(object): http_log_debug = False _logger = logging.getLogger(__name__) - def __init__(self, api_url, secure=False, http_log_debug=False): + def __init__(self, api_url, secure=False, http_log_debug=False, + suppress_ssl_warnings=False): + if suppress_ssl_warnings: + requests.packages.urllib3.disable_warnings() self.session_key = None #should be http:///lhos