Merge "Remove use of py3kcompat"
This commit is contained in:
commit
5b57317e98
@ -12,7 +12,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from heat.openstack.common.py3kcompat import urlutils
|
||||
from six.moves.urllib import parse as urlparse
|
||||
|
||||
|
||||
def get_collection_links(request, items):
|
||||
@ -38,4 +38,4 @@ def _get_next_link(request, marker):
|
||||
params = request.params.copy()
|
||||
params['marker'] = marker
|
||||
|
||||
return "%s?%s" % (request.path_url, urlutils.urlencode(params))
|
||||
return "%s?%s" % (request.path_url, urlparse.urlencode(params))
|
||||
|
@ -19,9 +19,10 @@
|
||||
import functools
|
||||
import sys
|
||||
|
||||
from six.moves.urllib import parse as urlparse
|
||||
|
||||
from heat.openstack.common.gettextutils import _
|
||||
from heat.openstack.common import log as logging
|
||||
from heat.openstack.common.py3kcompat import urlutils
|
||||
|
||||
|
||||
_FATAL_EXCEPTION_FORMAT_ERRORS = False
|
||||
@ -32,7 +33,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
class RedirectException(Exception):
|
||||
def __init__(self, url):
|
||||
self.url = urlutils.urlparse(url)
|
||||
self.url = urlparse.urlparse(url)
|
||||
|
||||
|
||||
class KeystoneError(Exception):
|
||||
|
@ -14,7 +14,8 @@
|
||||
import collections
|
||||
import re
|
||||
|
||||
from heat.openstack.common.py3kcompat import urlutils
|
||||
from six.moves.urllib import parse as urlparse
|
||||
|
||||
from heat.openstack.common import strutils
|
||||
|
||||
|
||||
@ -61,10 +62,10 @@ class HeatIdentifier(collections.Mapping):
|
||||
if fields[1] != 'openstack' or fields[2] != 'heat' or not path:
|
||||
raise ValueError(_('"%s" is not a valid Heat ARN') % arn)
|
||||
|
||||
return cls(urlutils.unquote(fields[4]),
|
||||
urlutils.unquote(path.group(1)),
|
||||
urlutils.unquote(path.group(2)),
|
||||
urlutils.unquote(path.group(3)))
|
||||
return cls(urlparse.unquote(fields[4]),
|
||||
urlparse.unquote(path.group(1)),
|
||||
urlparse.unquote(path.group(2)),
|
||||
urlparse.unquote(path.group(3)))
|
||||
|
||||
@classmethod
|
||||
def from_arn_url(cls, url):
|
||||
@ -73,7 +74,7 @@ class HeatIdentifier(collections.Mapping):
|
||||
The URL is expected to contain a valid arn as part of the path
|
||||
'''
|
||||
# Sanity check the URL
|
||||
urlp = urlutils.urlparse(url)
|
||||
urlp = urlparse.urlparse(url)
|
||||
if (urlp.scheme not in ('http', 'https') or
|
||||
not urlp.netloc or not urlp.path):
|
||||
raise ValueError(_('"%s" is not a valid URL') % url)
|
||||
@ -85,7 +86,7 @@ class HeatIdentifier(collections.Mapping):
|
||||
raise ValueError(_('"%s" is not a valid ARN URL') % url)
|
||||
# the +1 is to skip the leading /
|
||||
url_arn = urlp.path[match.start() + 1:]
|
||||
arn = urlutils.unquote(url_arn)
|
||||
arn = urlparse.unquote(url_arn)
|
||||
return cls.from_arn(arn)
|
||||
|
||||
def arn(self):
|
||||
@ -93,21 +94,21 @@ class HeatIdentifier(collections.Mapping):
|
||||
Return an ARN of the form:
|
||||
arn:openstack:heat::<tenant>:stacks/<stack_name>/<stack_id><path>
|
||||
'''
|
||||
return 'arn:openstack:heat::%s:%s' % (urlutils.quote(self.tenant, ''),
|
||||
return 'arn:openstack:heat::%s:%s' % (urlparse.quote(self.tenant, ''),
|
||||
self._tenant_path())
|
||||
|
||||
def arn_url_path(self):
|
||||
'''
|
||||
Return an ARN quoted correctly for use in a URL
|
||||
'''
|
||||
return '/' + urlutils.quote(self.arn(), '')
|
||||
return '/' + urlparse.quote(self.arn(), '')
|
||||
|
||||
def url_path(self):
|
||||
'''
|
||||
Return a URL-encoded path segment of a URL in the form:
|
||||
<tenant>/stacks/<stack_name>/<stack_id><path>
|
||||
'''
|
||||
return '/'.join((urlutils.quote(self.tenant, ''), self._tenant_path()))
|
||||
return '/'.join((urlparse.quote(self.tenant, ''), self._tenant_path()))
|
||||
|
||||
def _tenant_path(self):
|
||||
'''
|
||||
@ -116,7 +117,7 @@ class HeatIdentifier(collections.Mapping):
|
||||
stacks/<stack_name>/<stack_id><path>
|
||||
'''
|
||||
return 'stacks/%s%s' % (self.stack_path(),
|
||||
urlutils.quote(strutils.safe_encode(
|
||||
urlparse.quote(strutils.safe_encode(
|
||||
self.path)))
|
||||
|
||||
def stack_path(self):
|
||||
@ -125,8 +126,8 @@ class HeatIdentifier(collections.Mapping):
|
||||
in the form:
|
||||
<stack_name>/<stack_id>
|
||||
'''
|
||||
return '%s/%s' % (urlutils.quote(self.stack_name, ''),
|
||||
urlutils.quote(self.stack_id, ''))
|
||||
return '%s/%s' % (urlparse.quote(self.stack_name, ''),
|
||||
urlparse.quote(self.stack_id, ''))
|
||||
|
||||
def _path_components(self):
|
||||
'''Return a list of the path components.'''
|
||||
|
@ -20,9 +20,10 @@ from oslo.config import cfg
|
||||
import requests
|
||||
from requests import exceptions
|
||||
|
||||
from six.moves import urllib
|
||||
|
||||
from heat.openstack.common.gettextutils import _
|
||||
from heat.openstack.common import log as logging
|
||||
from heat.openstack.common.py3kcompat import urlutils
|
||||
|
||||
cfg.CONF.import_opt('max_template_size', 'heat.common.config')
|
||||
|
||||
@ -40,15 +41,15 @@ def get(url, allowed_schemes=('http', 'https')):
|
||||
'''
|
||||
logger.info(_('Fetching data from %s') % url)
|
||||
|
||||
components = urlutils.urlparse(url)
|
||||
components = urllib.parse.urlparse(url)
|
||||
|
||||
if components.scheme not in allowed_schemes:
|
||||
raise IOError(_('Invalid URL scheme %s') % components.scheme)
|
||||
|
||||
if components.scheme == 'file':
|
||||
try:
|
||||
return urlutils.urlopen(url).read()
|
||||
except urlutils.URLError as uex:
|
||||
return urllib.request.urlopen(url).read()
|
||||
except urllib.error.URLError as uex:
|
||||
raise IOError(_('Failed to retrieve template: %s') % str(uex))
|
||||
|
||||
try:
|
||||
|
@ -23,13 +23,13 @@ import string
|
||||
|
||||
from oslo.config import cfg
|
||||
import six
|
||||
from six.moves.urllib import parse as urlparse
|
||||
|
||||
from heat.common import exception
|
||||
from heat.engine import clients
|
||||
from heat.engine import scheduler
|
||||
from heat.openstack.common.gettextutils import _
|
||||
from heat.openstack.common import log as logging
|
||||
from heat.openstack.common.py3kcompat import urlutils
|
||||
from heat.openstack.common import uuidutils
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -252,8 +252,8 @@ echo -e '%s\tALL=(ALL)\tNOPASSWD: ALL' >> /etc/sudoers
|
||||
|
||||
# Create a boto config which the cfntools on the host use to know
|
||||
# where the cfn and cw API's are to be accessed
|
||||
cfn_url = urlutils.urlparse(cfg.CONF.heat_metadata_server_url)
|
||||
cw_url = urlutils.urlparse(cfg.CONF.heat_watch_server_url)
|
||||
cfn_url = urlparse.urlparse(cfg.CONF.heat_metadata_server_url)
|
||||
cw_url = urlparse.urlparse(cfg.CONF.heat_watch_server_url)
|
||||
is_secure = cfg.CONF.instance_connection_is_secure
|
||||
vcerts = cfg.CONF.instance_connection_https_validate_certificates
|
||||
boto_cfg = "\n".join(["[Boto]",
|
||||
|
@ -12,12 +12,13 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from six.moves.urllib import parse as urlparse
|
||||
|
||||
from heat.engine import clients
|
||||
from heat.engine import constraints
|
||||
from heat.engine import properties
|
||||
from heat.engine import resource
|
||||
from heat.openstack.common import log as logging
|
||||
from heat.openstack.common.py3kcompat import urlutils
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -152,7 +153,7 @@ class S3Bucket(resource.Resource):
|
||||
|
||||
def _resolve_attribute(self, name):
|
||||
url = self.swift().get_auth()[0]
|
||||
parsed = list(urlutils.urlparse(url))
|
||||
parsed = list(urlparse.urlparse(url))
|
||||
if name == 'DomainName':
|
||||
return parsed[1].split(':')[0]
|
||||
elif name == 'WebsiteURL':
|
||||
|
@ -12,12 +12,13 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from six.moves.urllib import parse as urlparse
|
||||
|
||||
from heat.common import exception
|
||||
from heat.engine import clients
|
||||
from heat.engine import properties
|
||||
from heat.engine import resource
|
||||
from heat.openstack.common import log as logging
|
||||
from heat.openstack.common.py3kcompat import urlutils
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -133,7 +134,7 @@ class SwiftContainer(resource.Resource):
|
||||
return unicode(self.resource_id)
|
||||
|
||||
def FnGetAtt(self, key):
|
||||
parsed = list(urlutils.urlparse(self.swift().url))
|
||||
parsed = list(urlparse.urlparse(self.swift().url))
|
||||
if key == 'DomainName':
|
||||
return parsed[1].split(':')[0]
|
||||
elif key == 'WebsiteURL':
|
||||
|
@ -12,6 +12,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from six.moves.urllib import parse as urlparse
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from keystoneclient.contrib.ec2 import utils as ec2_utils
|
||||
@ -22,7 +24,6 @@ from heat.engine import stack_user
|
||||
|
||||
from heat.openstack.common import log as logging
|
||||
from heat.openstack.common.gettextutils import _
|
||||
from heat.openstack.common.py3kcompat import urlutils
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -82,7 +83,7 @@ class SignalResponder(stack_user.StackUser):
|
||||
|
||||
waitcond_url = cfg.CONF.heat_waitcondition_server_url
|
||||
signal_url = waitcond_url.replace('/waitcondition', signal_type)
|
||||
host_url = urlutils.urlparse(signal_url)
|
||||
host_url = urlparse.urlparse(signal_url)
|
||||
|
||||
path = self.identifier().arn_url_path()
|
||||
|
||||
@ -90,7 +91,7 @@ class SignalResponder(stack_user.StackUser):
|
||||
# prcessing in the CFN API (ec2token.py) has an unquoted path, so we
|
||||
# need to calculate the signature with the path component unquoted, but
|
||||
# ensure the actual URL contains the quoted version...
|
||||
unquoted_path = urlutils.unquote(host_url.path + path)
|
||||
unquoted_path = urlparse.unquote(host_url.path + path)
|
||||
request = {'host': host_url.netloc.lower(),
|
||||
'verb': SIGNAL_VERB[signal_type],
|
||||
'path': unquoted_path,
|
||||
@ -104,7 +105,7 @@ class SignalResponder(stack_user.StackUser):
|
||||
signer = ec2_utils.Ec2Signer(secret_key)
|
||||
request['params']['Signature'] = signer.generate(request)
|
||||
|
||||
qs = urlutils.urlencode(request['params'])
|
||||
qs = urlparse.urlencode(request['params'])
|
||||
url = "%s%s?%s" % (signal_url.lower(),
|
||||
path, qs)
|
||||
|
||||
|
@ -30,11 +30,12 @@ import uuid
|
||||
from migrate.versioning import repository
|
||||
import sqlalchemy
|
||||
|
||||
from six.moves.urllib import parse as urlparse
|
||||
|
||||
from heat.db.sqlalchemy import migrate_repo
|
||||
from heat.db.sqlalchemy import migration
|
||||
from heat.openstack.common.db.sqlalchemy import test_migrations
|
||||
from heat.openstack.common import log as logging
|
||||
from heat.openstack.common.py3kcompat import urlutils
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -125,7 +126,7 @@ class TestHeatMigrations(test_migrations.BaseMigrationTestCase,
|
||||
for key, eng in self.engines.items():
|
||||
if eng is engine:
|
||||
conn_string = self.test_databases[key]
|
||||
conn_pieces = urlutils.urlparse(conn_string)
|
||||
conn_pieces = urlparse.urlparse(conn_string)
|
||||
if conn_string.startswith('mysql'):
|
||||
break
|
||||
else:
|
||||
|
@ -13,8 +13,9 @@
|
||||
|
||||
import mock
|
||||
|
||||
from six.moves.urllib import parse as urlparse
|
||||
|
||||
from heat.api.openstack.v1.views import views_common
|
||||
from heat.openstack.common.py3kcompat import urlutils
|
||||
from heat.tests.common import HeatTestCase
|
||||
|
||||
|
||||
@ -73,9 +74,9 @@ class TestViewsCommon(HeatTestCase):
|
||||
|
||||
next_link = filter(lambda link: link['rel'] == 'next', links).pop()
|
||||
url = next_link['href']
|
||||
query_string = urlutils.urlparse(url).query
|
||||
query_string = urlparse.urlparse(url).query
|
||||
params = {}
|
||||
params.update(urlutils.parse_qsl(query_string))
|
||||
params.update(urlparse.parse_qsl(query_string))
|
||||
self.assertEqual('2', params['limit'])
|
||||
self.assertEqual('bar', params['foo'])
|
||||
|
||||
|
@ -16,9 +16,9 @@ from oslo.config import cfg
|
||||
import requests
|
||||
from requests import exceptions
|
||||
from six.moves import cStringIO
|
||||
from six.moves import urllib
|
||||
|
||||
from heat.common import urlfetch
|
||||
from heat.openstack.common.py3kcompat import urlutils
|
||||
from heat.tests.common import HeatTestCase
|
||||
|
||||
|
||||
@ -49,8 +49,8 @@ class UrlFetchTest(HeatTestCase):
|
||||
data = '{ "foo": "bar" }'
|
||||
url = 'file:///etc/profile'
|
||||
|
||||
self.m.StubOutWithMock(urlutils, 'urlopen')
|
||||
urlutils.urlopen(url).AndReturn(cStringIO(data))
|
||||
self.m.StubOutWithMock(urllib.request, 'urlopen')
|
||||
urllib.request.urlopen(url).AndReturn(cStringIO(data))
|
||||
self.m.ReplayAll()
|
||||
|
||||
self.assertEqual(data, urlfetch.get(url, allowed_schemes=['file']))
|
||||
@ -59,8 +59,8 @@ class UrlFetchTest(HeatTestCase):
|
||||
def test_file_scheme_failure(self):
|
||||
url = 'file:///etc/profile'
|
||||
|
||||
self.m.StubOutWithMock(urlutils, 'urlopen')
|
||||
urlutils.urlopen(url).AndRaise(urlutils.URLError('oops'))
|
||||
self.m.StubOutWithMock(urllib.request, 'urlopen')
|
||||
urllib.request.urlopen(url).AndRaise(urllib.error.URLError('oops'))
|
||||
self.m.ReplayAll()
|
||||
|
||||
self.assertRaises(IOError, urlfetch.get, url, allowed_schemes=['file'])
|
||||
|
@ -15,10 +15,11 @@
|
||||
|
||||
import httplib2
|
||||
|
||||
from six.moves.urllib import parse as urlparse
|
||||
|
||||
from novaclient import client as base_client
|
||||
from novaclient.v1_1 import client
|
||||
|
||||
from heat.openstack.common.py3kcompat import urlutils
|
||||
from heat.tests import fakes
|
||||
|
||||
|
||||
@ -46,7 +47,7 @@ class FakeHTTPClient(base_client.HTTPClient):
|
||||
assert 'body' in kwargs
|
||||
|
||||
# Call the method
|
||||
args = urlutils.parse_qsl(urlutils.urlparse(url)[4])
|
||||
args = urlparse.parse_qsl(urlparse.urlparse(url)[4])
|
||||
kwargs.update(args)
|
||||
munged_url = url.rsplit('?', 1)[0]
|
||||
munged_url = munged_url.strip('/').replace('/', '_').replace('.', '_')
|
||||
|
Loading…
Reference in New Issue
Block a user