Merge pull request #11 from osu-sig/fix-ssl-behind-proxy
Fix SSL error when connecting from behind a proxy
This commit is contained in:
@@ -41,7 +41,7 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
from elementtree.ElementTree import ElementTree
|
from elementtree.ElementTree import ElementTree
|
||||||
from xml.parsers.expat import ExpatError
|
from xml.parsers.expat import ExpatError
|
||||||
import urllib
|
import urllib2
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -429,7 +429,7 @@ def __GetServiceVersionDescription(protocol, server, port, path):
|
|||||||
|
|
||||||
url = "%s://%s:%s/%s/vimServiceVersions.xml" % (protocol, server, port, path)
|
url = "%s://%s:%s/%s/vimServiceVersions.xml" % (protocol, server, port, path)
|
||||||
try:
|
try:
|
||||||
with closing(urllib.urlopen(url)) as sock:
|
with closing(urllib2.urlopen(url)) as sock:
|
||||||
if sock.getcode() == 200:
|
if sock.getcode() == 200:
|
||||||
tree.parse(sock)
|
tree.parse(sock)
|
||||||
return tree
|
return tree
|
||||||
@@ -438,7 +438,7 @@ def __GetServiceVersionDescription(protocol, server, port, path):
|
|||||||
|
|
||||||
url = "%s://%s:%s/%s/vimService.wsdl" % (protocol, server, port, path)
|
url = "%s://%s:%s/%s/vimService.wsdl" % (protocol, server, port, path)
|
||||||
try:
|
try:
|
||||||
with closing(urllib.urlopen(url)) as sock:
|
with closing(urllib2.urlopen(url)) as sock:
|
||||||
if sock.getcode() == 200:
|
if sock.getcode() == 200:
|
||||||
tree.parse(sock)
|
tree.parse(sock)
|
||||||
return tree
|
return tree
|
||||||
@@ -593,7 +593,6 @@ def OpenUrlWithBasicAuth(url, user='root', pwd=''):
|
|||||||
the specified credentials to the server as part of the request.
|
the specified credentials to the server as part of the request.
|
||||||
Returns the response as a file-like object.
|
Returns the response as a file-like object.
|
||||||
"""
|
"""
|
||||||
import urllib2
|
|
||||||
pwMgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
|
pwMgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
|
||||||
pwMgr.add_password(None, url, user, pwd)
|
pwMgr.add_password(None, url, user, pwd)
|
||||||
handler = urllib2.HTTPBasicAuthHandler(pwMgr)
|
handler = urllib2.HTTPBasicAuthHandler(pwMgr)
|
||||||
@@ -608,7 +607,6 @@ def OpenPathWithStub(path, stub):
|
|||||||
file-like object.
|
file-like object.
|
||||||
"""
|
"""
|
||||||
import httplib
|
import httplib
|
||||||
import urllib2
|
|
||||||
if not hasattr(stub, 'scheme'):
|
if not hasattr(stub, 'scheme'):
|
||||||
raise vmodl.fault.NotSupported()
|
raise vmodl.fault.NotSupported()
|
||||||
elif stub.scheme == httplib.HTTPConnection:
|
elif stub.scheme == httplib.HTTPConnection:
|
||||||
|
Reference in New Issue
Block a user