Forum Discussion
John_Gruber_432
Jun 08, 2015Historic F5 Account
Let's try that again.. I'll stop fighting Dev Central and use an 'acceptable browser'... Here is the code example to runtime patch suds:
import urllib2
import ssl
from suds import transport
from suds.client import Client
from suds.xsd.doctor import Import, ImportDoctor
from pycontrol import pycontrol
IMP = Import('[http://schemas.xmlsoap.org/soap/encoding/](http://schemas.xmlsoap.org/soap/encoding/)')
DOCTOR = ImportDoctor(IMP)
ICONTROL_URI = '/iControl/iControlPortal.cgi'
SESSION_WSDL = 'System.Session'
class HTTPSUnVerifiedCertTransport(transport.https.HttpAuthenticated):
def __init__(self, *args, **kwargs):
transport.https.HttpAuthenticated.__init__(self, *args, **kwargs)
def u2handlers(self):
handlers = []
handlers.append(urllib2.ProxyHandler(self.proxy))
handlers.append(urllib2.HTTPBasicAuthHandler(self.pm))
python ssl Context support - PEP 0466
if hasattr(ssl, '_create_unverified_context'):
ssl_context = ssl._create_unverified_context()
handlers.append(urllib2.HTTPSHandler(context=ssl_context))
else:
handlers.append(urllib2.HTTPSHandler())
return handlers
def new_get_suds_client(self, url, **kw):
if not url.startswith("https"):
t = transport.http.HttpAuthenticated(username=self.username,
password=self.password)
c = Client(url, transport=t, username=self.username,
password=self.password, doctor=DOCTOR, **kw)
else:
t = HTTPSUnVerifiedCertTransport(username=self.username,
password=self.password)
c = Client(url, transport=t, username=self.username,
password=self.password, doctor=DOCTOR, **kw)
return c
pycontrol.BIGIP._get_suds_client = new_get_suds_client
device = pycontrol.BIGIP(hostname='192.168.245.1', username='admin', password='admin', fromurl=True, wsdls=['LocalLB.Pool'])
- tjsauter_208299Jun 30, 2015NimbostratusExcellent! Exactly what I needed, thanks for posting