bigsuds
Advanced tools
@@ -1,1 +0,1 @@ | ||
| {"is_release": false, "git_version": "5ad4a9f"} | ||
| {"is_release": false, "git_version": "e5c56a0"} |
| Metadata-Version: 1.1 | ||
| Name: bigsuds | ||
| Version: 1.0.2 | ||
| Version: 1.0.3 | ||
| Summary: Library for F5 Networks iControl API | ||
@@ -5,0 +5,0 @@ Home-page: http://devcentral.f5.com |
+53
-15
@@ -10,2 +10,3 @@ #!/usr/bin/env python | ||
| import re | ||
| import ssl | ||
| import urllib2 | ||
@@ -20,5 +21,6 @@ from xml.sax import SAXParseException | ||
| from suds.transport import TransportError | ||
| from suds.transport.https import HttpAuthenticated | ||
| from suds import WebFault, TypeNotFound, MethodNotFound as _MethodNotFound | ||
| __version__ = '1.0.2' | ||
| __version__ = '1.0.3' | ||
@@ -31,7 +33,19 @@ | ||
| # We need to add support for SSL Contexts for Python 2.7.9+ | ||
| from sys import hexversion as python_version | ||
| if python_version >= 34015728: | ||
| import ssl | ||
| ssl._create_default_https_context = ssl._create_unverified_context | ||
| class HTTPSHandlerNoVerify(urllib2.HTTPSHandler): | ||
| def __init__(self, *args, **kwargs): | ||
| try: | ||
| kwargs['context'] = ssl._create_unverified_context() | ||
| except AttributeError: | ||
| # Python prior to 2.7.9 doesn't have default-enabled certificate | ||
| # verification | ||
| pass | ||
| urllib2.HTTPSHandler.__init__(self, *args, **kwargs) | ||
| class HTTPSTransportNoVerify(HttpAuthenticated): | ||
| def u2handlers(self): | ||
| handlers = HttpAuthenticated.u2handlers(self) | ||
| handlers.append(HTTPSHandlerNoVerify()) | ||
| return handlers | ||
| log = logging.getLogger('bigsuds') | ||
@@ -89,3 +103,3 @@ | ||
| def __init__(self, hostname, username='admin', password='admin', | ||
| debug=False, cachedir=None): | ||
| debug=False, cachedir=None, verify=False, timeout=90): | ||
| """init | ||
@@ -101,2 +115,6 @@ | ||
| that caching should be disabled. | ||
| @param verify: When True, performs SSL certificate validation in | ||
| Python / urllib2 versions that support it (v2.7.9 and newer) | ||
| @param timeout: The time (in seconds) to wait before timing out | ||
| the connection to the URL | ||
| """ | ||
@@ -108,2 +126,4 @@ self._hostname = hostname | ||
| self._cachedir = cachedir | ||
| self._verify = verify | ||
| self._timeout = timeout | ||
| if debug: | ||
@@ -147,3 +167,3 @@ self._instantiate_namespaces() | ||
| client = get_client(self._hostname, wsdl_name, self._username, | ||
| self._password, self._cachedir) | ||
| self._password, self._cachedir, self._verify, self._timeout) | ||
| except SAXParseException, e: | ||
@@ -169,3 +189,4 @@ raise ParseError('%s\nFailed to parse wsdl. Is "%s" a valid ' | ||
| wsdl_hierarchy = get_wsdls(self._hostname, self._username, | ||
| self._password) | ||
| self._password, self._verify, | ||
| self._timeout) | ||
| for namespace, attr_list in wsdl_hierarchy.iteritems(): | ||
@@ -214,3 +235,3 @@ ns = getattr(self, namespace) | ||
| def get_client(hostname, wsdl_name, username='admin', password='admin', | ||
| cachedir=None): | ||
| cachedir=None, verify=False, timeout=90): | ||
| """Returns and instance of suds.client.Client. | ||
@@ -229,2 +250,6 @@ | ||
| that caching should be disabled. | ||
| @param verify: When True, performs SSL certificate validation in | ||
| Python / urllib2 versions that support it (v2.7.9 and newer) | ||
| @param timeout: The time to wait (in seconds) before timing out | ||
| the connection to the URL | ||
| """ | ||
@@ -240,4 +265,10 @@ url = 'https://%s/iControl/iControlPortal.cgi?WSDL=%s' % ( | ||
| doctor = ImportDoctor(imp) | ||
| client = Client(url, doctor=doctor, username=username, password=password, | ||
| cache=cachedir) | ||
| if verify: | ||
| client = Client(url, doctor=doctor, username=username, password=password, | ||
| cache=cachedir, timeout=timeout) | ||
| else: | ||
| transport = HTTPSTransportNoVerify(username=username, | ||
| password=password, timeout=timeout) | ||
| client = Client(url, doctor=doctor, username=username, password=password, | ||
| cache=cachedir, transport=transport, timeout=timeout) | ||
@@ -251,3 +282,3 @@ # Without this, subsequent requests will use the actual hostname of the | ||
| def get_wsdls(hostname, username='admin', password='admin'): | ||
| def get_wsdls(hostname, username='admin', password='admin', verify=False, timeout=90): | ||
| """Returns the set of all available WSDLs on this server | ||
@@ -261,2 +292,6 @@ | ||
| @param password: The admin password on the BIGIP. | ||
| @param verify: When True, performs SSL certificate validation in | ||
| Python / urllib2 versions that support it (v2.7.9 and newer) | ||
| @param timeout: The time to wait (in seconds) before timing out the connection | ||
| to the URL | ||
| """ | ||
@@ -273,5 +308,8 @@ url = 'https://%s/iControl/iControlPortal.cgi' % (hostname) | ||
| realm="BIG\-IP") | ||
| opener = urllib2.build_opener(auth_handler) | ||
| if verify: | ||
| opener = urllib2.build_opener(auth_handler) | ||
| else: | ||
| opener = urllib2.build_opener(auth_handler, HTTPSHandlerNoVerify) | ||
| try: | ||
| result = opener.open(url) | ||
| result = opener.open(url, timeout=timeout) | ||
| except urllib2.URLError, e: | ||
@@ -437,3 +475,3 @@ raise ConnectionError(str(e)) | ||
| except AttributeError: | ||
| # Oddly, his seems to happen when the wrong password is used. | ||
| # Oddly, this seems to happen when the wrong password is used. | ||
| raise ConnectionError('iControl call failed, possibly invalid ' | ||
@@ -440,0 +478,0 @@ 'credentials.') |
+1
-1
| Metadata-Version: 1.1 | ||
| Name: bigsuds | ||
| Version: 1.0.2 | ||
| Version: 1.0.3 | ||
| Summary: Library for F5 Networks iControl API | ||
@@ -5,0 +5,0 @@ Home-page: http://devcentral.f5.com |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
29096
7.09%584
6.57%