Fix python3 Compatibility for urllib2

The urllib2 module has been split across several modules
in Python 3 named urllib.request and urllib.error [1].

This patch makes code compatible for both python2 and
python3 by using six.moves.urllib [2].

[1] https://docs.python.org/2/library/urllib2.html
[2] https://pythonhosted.org/six/

Change-Id: Ie9ebe0d1e39ddb4704df067d42915204e49821cf
Closes-Bug: #1809801
This commit is contained in:
yatin 2018-12-26 17:58:00 +05:30
parent ae006e683b
commit 42bce570ca
1 changed files with 2 additions and 2 deletions

View File

@ -15,9 +15,9 @@
import os
import six
from six.moves.urllib.request import urlopen
import sys
import time
import urllib2
from lxml import etree
from oslo_log import log
@ -83,7 +83,7 @@ class VpnTest(scenario_base.BaseScenarioTest):
def test_vpn_connectivity(self):
is_amazon = 'amazon' in CONF.aws.ec2_url
response = urllib2.urlopen(self.OPENSWAN_LINK, timeout=30)
response = urlopen(self.OPENSWAN_LINK, timeout=30)
content = response.read()
if not is_amazon:
# NOTE(andrey-mp): gating in openstack doesn't have internet access