diff options
author | llg8212 <lilinguo@huawei.com> | 2014-02-24 09:32:52 +0800 |
---|---|---|
committer | llg8212 <lilinguo@huawei.com> | 2014-03-18 10:27:55 +0800 |
commit | 9d3d26d903d269a3bbaabde4ddcc411c28fe3f01 (patch) | |
tree | c89e7c491f6c1df5a517ad659f0a84008b4a0e2f /heatclient | |
parent | 7e265ec757f26bce5038bdcc7fa81abd823e328f (diff) | |
download | python-heatclient-9d3d26d903d269a3bbaabde4ddcc411c28fe3f01.tar.gz |
Remove dependent module py3kcompat
Module py3kcompat was removed from oslo-incubator, we can use
six directly.
* Sync commit of removing py3kcompat from oslo
* use six replace usage of py3kcompat
Change-Id: If0f9397588b2180fe198e804cbbb5b5c8420fe76
Closes-Bug: #1280033
Diffstat (limited to 'heatclient')
-rw-r--r-- | heatclient/common/http.py | 4 | ||||
-rw-r--r-- | heatclient/common/template_utils.py | 22 | ||||
-rw-r--r-- | heatclient/openstack/common/apiclient/base.py | 6 | ||||
-rw-r--r-- | heatclient/openstack/common/py3kcompat/__init__.py | 17 | ||||
-rw-r--r-- | heatclient/openstack/common/py3kcompat/urlutils.py | 62 | ||||
-rw-r--r-- | heatclient/tests/test_shell.py | 35 | ||||
-rw-r--r-- | heatclient/tests/test_template_utils.py | 58 | ||||
-rw-r--r-- | heatclient/v1/events.py | 15 | ||||
-rw-r--r-- | heatclient/v1/resource_types.py | 5 | ||||
-rw-r--r-- | heatclient/v1/resources.py | 20 | ||||
-rw-r--r-- | heatclient/v1/shell.py | 7 | ||||
-rw-r--r-- | heatclient/v1/software_deployments.py | 7 | ||||
-rw-r--r-- | heatclient/v1/stacks.py | 4 |
13 files changed, 92 insertions, 170 deletions
diff --git a/heatclient/common/http.py b/heatclient/common/http.py index d744e91..7b5fb4a 100644 --- a/heatclient/common/http.py +++ b/heatclient/common/http.py @@ -20,10 +20,10 @@ import socket import requests import six +from six.moves.urllib import parse from heatclient import exc from heatclient.openstack.common import jsonutils -from heatclient.openstack.common.py3kcompat import urlutils from heatclient.openstack.common import strutils LOG = logging.getLogger(__name__) @@ -75,7 +75,7 @@ class HTTPClient(object): } self.verify_cert = None - if urlutils.urlparse(endpoint).scheme == "https": + if parse.urlparse(endpoint).scheme == "https": if kwargs.get('insecure'): self.verify_cert = False else: diff --git a/heatclient/common/template_utils.py b/heatclient/common/template_utils.py index af3c72c..119faf1 100644 --- a/heatclient/common/template_utils.py +++ b/heatclient/common/template_utils.py @@ -15,11 +15,13 @@ import os import six +from six.moves.urllib import error +from six.moves.urllib import parse +from six.moves.urllib import request from heatclient.common import environment_format from heatclient.common import template_format from heatclient import exc -from heatclient.openstack.common.py3kcompat import urlutils def get_template_contents(template_file=None, template_url=None, @@ -30,7 +32,7 @@ def get_template_contents(template_file=None, template_url=None, template_url = normalise_file_path_to_url(template_file) if template_url: - tpl = urlutils.urlopen(template_url).read() + tpl = request.urlopen(template_url).read() elif template_object: template_url = template_object @@ -93,10 +95,10 @@ def get_file_contents(from_data, files, base_url=None, if base_url and not base_url.endswith('/'): base_url = base_url + '/' - str_url = urlutils.urljoin(base_url, value) + str_url = parse.urljoin(base_url, value) try: - files[str_url] = urlutils.urlopen(str_url).read() - except urlutils.URLError: + files[str_url] = request.urlopen(str_url).read() + except error.URLError: raise exc.CommandError('Could not fetch contents for %s' % str_url) @@ -105,16 +107,16 @@ def get_file_contents(from_data, files, base_url=None, def base_url_for_url(url): - parsed = urlutils.urlparse(url) + parsed = parse.urlparse(url) parsed_dir = os.path.dirname(parsed.path) - return urlutils.urljoin(url, parsed_dir) + return parse.urljoin(url, parsed_dir) def normalise_file_path_to_url(path): - if urlutils.urlparse(path).scheme: + if parse.urlparse(path).scheme: return path path = os.path.abspath(path) - return urlutils.urljoin('file:', urlutils.pathname2url(path)) + return parse.urljoin('file:', request.pathname2url(path)) def process_environment_and_files(env_path=None, template=None, @@ -125,7 +127,7 @@ def process_environment_and_files(env_path=None, template=None, if env_path: env_url = normalise_file_path_to_url(env_path) env_base_url = base_url_for_url(env_url) - raw_env = urlutils.urlopen(env_url).read() + raw_env = request.urlopen(env_url).read() env = environment_format.parse(raw_env) resolve_environment_urls( diff --git a/heatclient/openstack/common/apiclient/base.py b/heatclient/openstack/common/apiclient/base.py index c0c71ac..5051965 100644 --- a/heatclient/openstack/common/apiclient/base.py +++ b/heatclient/openstack/common/apiclient/base.py @@ -27,9 +27,9 @@ import abc import copy import six +from six.moves.urllib import parse from heatclient.openstack.common.apiclient import exceptions -from heatclient.openstack.common.py3kcompat import urlutils from heatclient.openstack.common import strutils @@ -328,7 +328,7 @@ class CrudManager(BaseManager): return self._list( '%(base_url)s%(query)s' % { 'base_url': self.build_url(base_url=base_url, **kwargs), - 'query': '?%s' % urlutils.urlencode(kwargs) if kwargs else '', + 'query': '?%s' % parse.urlencode(kwargs) if kwargs else '', }, self.collection_key) @@ -367,7 +367,7 @@ class CrudManager(BaseManager): rl = self._list( '%(base_url)s%(query)s' % { 'base_url': self.build_url(base_url=base_url, **kwargs), - 'query': '?%s' % urlutils.urlencode(kwargs) if kwargs else '', + 'query': '?%s' % parse.urlencode(kwargs) if kwargs else '', }, self.collection_key) num = len(rl) diff --git a/heatclient/openstack/common/py3kcompat/__init__.py b/heatclient/openstack/common/py3kcompat/__init__.py deleted file mode 100644 index be894cf..0000000 --- a/heatclient/openstack/common/py3kcompat/__init__.py +++ /dev/null @@ -1,17 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# -# Copyright 2013 Canonical Ltd. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# diff --git a/heatclient/openstack/common/py3kcompat/urlutils.py b/heatclient/openstack/common/py3kcompat/urlutils.py deleted file mode 100644 index c2f0ae7..0000000 --- a/heatclient/openstack/common/py3kcompat/urlutils.py +++ /dev/null @@ -1,62 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# -# Copyright 2013 Canonical Ltd. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -""" -Python2/Python3 compatibility layer for OpenStack -""" - -import six - -if six.PY3: - # python3 - import urllib.error - import urllib.parse - import urllib.request - - urlencode = urllib.parse.urlencode - urljoin = urllib.parse.urljoin - quote = urllib.parse.quote - parse_qsl = urllib.parse.parse_qsl - unquote = urllib.parse.unquote - urlparse = urllib.parse.urlparse - urlsplit = urllib.parse.urlsplit - urlunsplit = urllib.parse.urlunsplit - - urlopen = urllib.request.urlopen - URLError = urllib.error.URLError - pathname2url = urllib.request.pathname2url -else: - # python2 - import urllib - import urllib2 - import urlparse - - urlencode = urllib.urlencode - quote = urllib.quote - unquote = urllib.unquote - - parse = urlparse - parse_qsl = parse.parse_qsl - urljoin = parse.urljoin - urlparse = parse.urlparse - urlsplit = parse.urlsplit - urlunsplit = parse.urlunsplit - - urlopen = urllib2.urlopen - URLError = urllib2.URLError - pathname2url = urllib.pathname2url diff --git a/heatclient/tests/test_shell.py b/heatclient/tests/test_shell.py index 5bc2a6e..64509b0 100644 --- a/heatclient/tests/test_shell.py +++ b/heatclient/tests/test_shell.py @@ -14,6 +14,8 @@ import os import re import six +from six.moves.urllib import parse +from six.moves.urllib import request import sys import fixtures @@ -22,7 +24,6 @@ import testscenarios import testtools from heatclient.openstack.common import jsonutils -from heatclient.openstack.common.py3kcompat import urlutils from heatclient.openstack.common import strutils from mox3 import mox @@ -392,7 +393,7 @@ class ShellTestUserPass(ShellBase): def test_stack_list_with_args(self): self._script_keystone_client() - expected_url = '/stacks?%s' % urlutils.urlencode({ + expected_url = '/stacks?%s' % parse.urlencode({ 'limit': 2, 'status': ['COMPLETE', 'FAILED'], 'marker': 'fake_id', @@ -812,8 +813,8 @@ class ShellTestUserPass(ShellBase): 'Created', {'location': 'http://no.where/v1/tenant_id/stacks/teststack2/2'}, None) - self.m.StubOutWithMock(urlutils, 'urlopen') - urlutils.urlopen('http://no.where/minimal.template').AndReturn( + self.m.StubOutWithMock(request, 'urlopen') + request.urlopen('http://no.where/minimal.template').AndReturn( six.StringIO('{"AWSTemplateFormatVersion" : "2010-09-09"}')) http.HTTPClient.json_request( @@ -1104,8 +1105,8 @@ class ShellTestEvents(ShellBase): resource_name = 'testresource/1' http.HTTPClient.json_request( 'GET', '/stacks/%s/resources/%s/events' % ( - urlutils.quote(stack_id, ''), - urlutils.quote(strutils.safe_encode( + parse.quote(stack_id, ''), + parse.quote(strutils.safe_encode( resource_name), ''))).AndReturn((resp, resp_dict)) self.m.ReplayAll() @@ -1161,10 +1162,10 @@ class ShellTestEvents(ShellBase): http.HTTPClient.json_request( 'GET', '/stacks/%s/resources/%s/events/%s' % ( - urlutils.quote(stack_id, ''), - urlutils.quote(strutils.safe_encode( + parse.quote(stack_id, ''), + parse.quote(strutils.safe_encode( resource_name), ''), - urlutils.quote(self.event_id_one, '') + parse.quote(self.event_id_one, '') )).AndReturn((resp, resp_dict)) self.m.ReplayAll() @@ -1287,8 +1288,8 @@ class ShellTestResources(ShellBase): http.HTTPClient.json_request( 'GET', '/stacks/%s/resources/%s' % ( - urlutils.quote(stack_id, ''), - urlutils.quote(strutils.safe_encode( + parse.quote(stack_id, ''), + parse.quote(strutils.safe_encode( resource_name), '') )).AndReturn((resp, resp_dict)) @@ -1332,8 +1333,8 @@ class ShellTestResources(ShellBase): http.HTTPClient.json_request( 'POST', '/stacks/%s/resources/%s/signal' % ( - urlutils.quote(stack_id, ''), - urlutils.quote(strutils.safe_encode( + parse.quote(stack_id, ''), + parse.quote(strutils.safe_encode( resource_name), '') ), data={'message': 'Content'}).AndReturn((resp, '')) @@ -1357,8 +1358,8 @@ class ShellTestResources(ShellBase): http.HTTPClient.json_request( 'POST', '/stacks/%s/resources/%s/signal' % ( - urlutils.quote(stack_id, ''), - urlutils.quote(strutils.safe_encode( + parse.quote(stack_id, ''), + parse.quote(strutils.safe_encode( resource_name), '') ), data=None).AndReturn((resp, '')) @@ -1420,8 +1421,8 @@ class ShellTestResources(ShellBase): http.HTTPClient.json_request( 'POST', '/stacks/%s/resources/%s/signal' % ( - urlutils.quote(stack_id, ''), - urlutils.quote(strutils.safe_encode( + parse.quote(stack_id, ''), + parse.quote(strutils.safe_encode( resource_name), '') ), data={'message': 'Content'}).AndReturn((resp, '')) diff --git a/heatclient/tests/test_template_utils.py b/heatclient/tests/test_template_utils.py index c38505c..ef71b2a 100644 --- a/heatclient/tests/test_template_utils.py +++ b/heatclient/tests/test_template_utils.py @@ -14,6 +14,7 @@ from mox3 import mox import os import six +from six.moves.urllib import request import tempfile import testtools from testtools.matchers import MatchesRegex @@ -21,7 +22,6 @@ import yaml from heatclient.common import template_utils from heatclient import exc -from heatclient.openstack.common.py3kcompat import urlutils class ShellEnvironmentTest(testtools.TestCase): @@ -38,8 +38,8 @@ class ShellEnvironmentTest(testtools.TestCase): jenv = yaml.safe_load(env) files = {} if url: - self.m.StubOutWithMock(urlutils, 'urlopen') - urlutils.urlopen(url).AndReturn(six.StringIO(content)) + self.m.StubOutWithMock(request, 'urlopen') + request.urlopen(url).AndReturn(six.StringIO(content)) self.m.ReplayAll() template_utils.resolve_environment_urls( @@ -49,7 +49,7 @@ class ShellEnvironmentTest(testtools.TestCase): def test_process_environment_file(self): - self.m.StubOutWithMock(urlutils, 'urlopen') + self.m.StubOutWithMock(request, 'urlopen') env_file = '/home/my/dir/env.yaml' env = ''' resource_registry: @@ -57,9 +57,9 @@ class ShellEnvironmentTest(testtools.TestCase): ''' tmpl = '{"foo": "bar"}' - urlutils.urlopen('file://%s' % env_file).AndReturn( + request.urlopen('file://%s' % env_file).AndReturn( six.StringIO(env)) - urlutils.urlopen('file:///home/b/a.yaml').AndReturn( + request.urlopen('file:///home/b/a.yaml').AndReturn( six.StringIO(tmpl)) self.m.ReplayAll() @@ -73,7 +73,7 @@ class ShellEnvironmentTest(testtools.TestCase): def test_process_environment_relative_file(self): - self.m.StubOutWithMock(urlutils, 'urlopen') + self.m.StubOutWithMock(request, 'urlopen') env_file = '/home/my/dir/env.yaml' env_url = 'file:///home/my/dir/env.yaml' env = ''' @@ -82,9 +82,9 @@ class ShellEnvironmentTest(testtools.TestCase): ''' tmpl = '{"foo": "bar"}' - urlutils.urlopen(env_url).AndReturn( + request.urlopen(env_url).AndReturn( six.StringIO(env)) - urlutils.urlopen('file:///home/my/dir/a.yaml').AndReturn( + request.urlopen('file:///home/my/dir/a.yaml').AndReturn( six.StringIO(tmpl)) self.m.ReplayAll() @@ -107,7 +107,7 @@ class ShellEnvironmentTest(testtools.TestCase): def test_process_environment_relative_file_up(self): - self.m.StubOutWithMock(urlutils, 'urlopen') + self.m.StubOutWithMock(request, 'urlopen') env_file = '/home/my/dir/env.yaml' env_url = 'file:///home/my/dir/env.yaml' env = ''' @@ -116,9 +116,9 @@ class ShellEnvironmentTest(testtools.TestCase): ''' tmpl = '{"foo": "bar"}' - urlutils.urlopen(env_url).AndReturn( + request.urlopen(env_url).AndReturn( six.StringIO(env)) - urlutils.urlopen('file:///home/my/bar/a.yaml').AndReturn( + request.urlopen('file:///home/my/bar/a.yaml').AndReturn( six.StringIO(tmpl)) self.m.ReplayAll() @@ -149,9 +149,9 @@ class ShellEnvironmentTest(testtools.TestCase): tmpl_url = 'http://no.where/some/path/to/a.yaml' tmpl = '{"foo": "bar"}' - self.m.StubOutWithMock(urlutils, 'urlopen') - urlutils.urlopen(url).AndReturn(six.StringIO(env)) - urlutils.urlopen(tmpl_url).AndReturn(six.StringIO(tmpl)) + self.m.StubOutWithMock(request, 'urlopen') + request.urlopen(url).AndReturn(six.StringIO(env)) + request.urlopen(tmpl_url).AndReturn(six.StringIO(tmpl)) self.m.ReplayAll() files, env_dict = template_utils.process_environment_and_files( @@ -163,11 +163,11 @@ class ShellEnvironmentTest(testtools.TestCase): def test_process_environment_empty_file(self): - self.m.StubOutWithMock(urlutils, 'urlopen') + self.m.StubOutWithMock(request, 'urlopen') env_file = '/home/my/dir/env.yaml' env = '' - urlutils.urlopen('file://%s' % env_file).AndReturn(six.StringIO(env)) + request.urlopen('file://%s' % env_file).AndReturn(six.StringIO(env)) self.m.ReplayAll() files, env_dict = template_utils.process_environment_and_files( @@ -330,8 +330,8 @@ class TestGetTemplateContents(testtools.TestCase): def test_get_template_contents_url(self): tmpl = '{"AWSTemplateFormatVersion" : "2010-09-09", "foo": "bar"}' url = 'http://no.where/path/to/a.yaml' - self.m.StubOutWithMock(urlutils, 'urlopen') - urlutils.urlopen(url).AndReturn(six.StringIO(tmpl)) + self.m.StubOutWithMock(request, 'urlopen') + request.urlopen(url).AndReturn(six.StringIO(tmpl)) self.m.ReplayAll() files, tmpl_parsed = template_utils.get_template_contents( @@ -394,25 +394,25 @@ resources: self.addCleanup(self.m.UnsetStubs) def test_hot_template(self): - self.m.StubOutWithMock(urlutils, 'urlopen') + self.m.StubOutWithMock(request, 'urlopen') tmpl_file = '/home/my/dir/template.yaml' url = 'file:///home/my/dir/template.yaml' - urlutils.urlopen(url).AndReturn( + request.urlopen(url).AndReturn( six.StringIO(self.hot_template)) - urlutils.urlopen( + request.urlopen( 'http://localhost/bar.yaml').InAnyOrder().AndReturn( six.StringIO('bar contents')) - urlutils.urlopen( + request.urlopen( 'file:///home/my/dir/foo.yaml').InAnyOrder().AndReturn( six.StringIO('foo contents')) - urlutils.urlopen( + request.urlopen( 'file:///home/my/dir/baz/baz1.yaml').InAnyOrder().AndReturn( six.StringIO('baz1 contents')) - urlutils.urlopen( + request.urlopen( 'file:///home/my/dir/baz/baz2.yaml').InAnyOrder().AndReturn( six.StringIO('baz2 contents')) - urlutils.urlopen( + request.urlopen( 'file:///home/my/dir/baz/baz3.yaml').InAnyOrder().AndReturn( six.StringIO('baz3 contents')) @@ -457,7 +457,7 @@ resources: self.m.VerifyAll() def test_hot_template_outputs(self): - self.m.StubOutWithMock(urlutils, 'urlopen') + self.m.StubOutWithMock(request, 'urlopen') tmpl_file = '/home/my/dir/template.yaml' url = 'file://%s' % tmpl_file contents = str('heat_template_version: 2013-05-23\n' @@ -465,8 +465,8 @@ resources: ' contents:\n' ' value:\n' ' get_file: template.yaml\n') - urlutils.urlopen(url).AndReturn(six.StringIO(contents)) - urlutils.urlopen(url).AndReturn(six.StringIO(contents)) + request.urlopen(url).AndReturn(six.StringIO(contents)) + request.urlopen(url).AndReturn(six.StringIO(contents)) self.m.ReplayAll() files, tmpl_parsed = template_utils.get_template_contents( template_file=tmpl_file) diff --git a/heatclient/v1/events.py b/heatclient/v1/events.py index cb24664..e4cbcfd 100644 --- a/heatclient/v1/events.py +++ b/heatclient/v1/events.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from six.moves.urllib import parse + from heatclient.openstack.common.apiclient import base -from heatclient.openstack.common.py3kcompat import urlutils from heatclient.openstack.common import strutils from heatclient.v1 import stacks @@ -48,10 +49,9 @@ class EventManager(stacks.StackChildManager): url = '/stacks/%s/events' % stack_id else: stack_id = self._resolve_stack_id(stack_id) - # Use urlutils for python2/python3 compatibility url = '/stacks/%s/resources/%s/events' % ( - urlutils.quote(stack_id, ''), - urlutils.quote(strutils.safe_encode(resource_name), '')) + parse.quote(stack_id, ''), + parse.quote(strutils.safe_encode(resource_name), '')) return self._list(url, "events") def get(self, stack_id, resource_name, event_id): @@ -62,10 +62,9 @@ class EventManager(stacks.StackChildManager): :param event_id: ID of event to get the details for """ stack_id = self._resolve_stack_id(stack_id) - # Use urlutils for python2/python3 compatibility url_str = '/stacks/%s/resources/%s/events/%s' % ( - urlutils.quote(stack_id, ''), - urlutils.quote(strutils.safe_encode(resource_name), ''), - urlutils.quote(event_id, '')) + parse.quote(stack_id, ''), + parse.quote(strutils.safe_encode(resource_name), ''), + parse.quote(event_id, '')) resp, body = self.client.json_request('GET', url_str) return Event(self, body['event']) diff --git a/heatclient/v1/resource_types.py b/heatclient/v1/resource_types.py index c3dd3b7..ec2b599 100644 --- a/heatclient/v1/resource_types.py +++ b/heatclient/v1/resource_types.py @@ -11,8 +11,9 @@ # License for the specific language governing permissions and limitations # under the License. +from six.moves.urllib import parse + from heatclient.openstack.common.apiclient import base -from heatclient.openstack.common.py3kcompat import urlutils from heatclient.openstack.common import strutils @@ -42,6 +43,6 @@ class ResourceTypeManager(base.BaseManager): :param resource_type: name of the resource type to get the details for """ url_str = '/resource_types/%s' % ( - urlutils.quote(strutils.safe_encode(resource_type), '')) + parse.quote(strutils.safe_encode(resource_type), '')) resp, body = self.client.json_request('GET', url_str) return body diff --git a/heatclient/v1/resources.py b/heatclient/v1/resources.py index 10dd5f4..a51fb0f 100644 --- a/heatclient/v1/resources.py +++ b/heatclient/v1/resources.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from six.moves.urllib import parse + from heatclient.openstack.common.apiclient import base -from heatclient.openstack.common.py3kcompat import urlutils from heatclient.openstack.common import strutils from heatclient.v1 import stacks @@ -52,10 +53,9 @@ class ResourceManager(stacks.StackChildManager): :param resource_name: ID of resource to get the details for """ stack_id = self._resolve_stack_id(stack_id) - # Use urlutils for python2/python3 compatibility url_str = '/stacks/%s/resources/%s' % ( - urlutils.quote(stack_id, ''), - urlutils.quote(strutils.safe_encode(resource_name), '')) + parse.quote(stack_id, ''), + parse.quote(strutils.safe_encode(resource_name), '')) resp, body = self.client.json_request('GET', url_str) return Resource(self, body['resource']) @@ -66,10 +66,9 @@ class ResourceManager(stacks.StackChildManager): :param resource_name: ID of resource to get metadata for """ stack_id = self._resolve_stack_id(stack_id) - # Use urlutils for python2/python3 compatibility url_str = '/stacks/%s/resources/%s/metadata' % ( - urlutils.quote(stack_id, ''), - urlutils.quote(strutils.safe_encode(resource_name), '')) + parse.quote(stack_id, ''), + parse.quote(strutils.safe_encode(resource_name), '')) resp, body = self.client.json_request('GET', url_str) return body['metadata'] @@ -81,14 +80,13 @@ class ResourceManager(stacks.StackChildManager): """ stack_id = self._resolve_stack_id(stack_id) url_str = '/stacks/%s/resources/%s/signal' % ( - urlutils.quote(stack_id, ''), - urlutils.quote(strutils.safe_encode(resource_name), '')) + parse.quote(stack_id, ''), + parse.quote(strutils.safe_encode(resource_name), '')) resp, body = self.client.json_request('POST', url_str, data=data) return body def generate_template(self, resource_name): - # Use urlutils for python2/python3 compatibility url_str = '/resource_types/%s/template' % ( - urlutils.quote(strutils.safe_encode(resource_name), '')) + parse.quote(strutils.safe_encode(resource_name), '')) resp, body = self.client.json_request('GET', url_str) return body diff --git a/heatclient/v1/shell.py b/heatclient/v1/shell.py index eeb4ca0..0bf33a0 100644 --- a/heatclient/v1/shell.py +++ b/heatclient/v1/shell.py @@ -14,13 +14,12 @@ # under the License. import logging - +from six.moves.urllib import request import yaml from heatclient.common import template_utils from heatclient.common import utils from heatclient.openstack.common import jsonutils -from heatclient.openstack.common.py3kcompat import urlutils import heatclient.exc as exc @@ -148,7 +147,7 @@ def do_stack_adopt(hc, args): raise exc.CommandError('Need to specify --adopt-file') adopt_url = template_utils.normalise_file_path_to_url(args.adopt_file) - adopt_data = urlutils.urlopen(adopt_url).read() + adopt_data = request.urlopen(adopt_url).read() if args.create_timeout: logger.warning('-c/--create-timeout is deprecated, ' @@ -593,7 +592,7 @@ def do_resource_signal(hc, args): raise exc.CommandError('Can only specify one of data and data-file') if data_file: data_url = template_utils.normalise_file_path_to_url(data_file) - data = urlutils.urlopen(data_url).read() + data = request.urlopen(data_url).read() if data: try: data = jsonutils.loads(data) diff --git a/heatclient/v1/software_deployments.py b/heatclient/v1/software_deployments.py index 4bbdf3d..0f685f2 100644 --- a/heatclient/v1/software_deployments.py +++ b/heatclient/v1/software_deployments.py @@ -10,8 +10,9 @@ # License for the specific language governing permissions and limitations # under the License. +from six.moves.urllib import parse + from heatclient.openstack.common.apiclient import base -from heatclient.openstack.common.py3kcompat import urlutils class SoftwareDeployment(base.Resource): @@ -32,7 +33,7 @@ class SoftwareDeploymentManager(base.BaseManager): """Get a list of software deployments. :rtype: list of :class:`SoftwareDeployment` """ - url = '/software_deployments?%s' % urlutils.urlencode(kwargs) + url = '/software_deployments?%s' % parse.urlencode(kwargs) return self._list(url, "software_deployments") def metadata(self, server_id): @@ -40,7 +41,7 @@ class SoftwareDeploymentManager(base.BaseManager): given server. :rtype: list of :class:`SoftwareDeployment` """ - url = '/software_deployments/metadata/%s' % urlutils.quote( + url = '/software_deployments/metadata/%s' % parse.quote( server_id, '') resp, body = self.client.json_request('GET', url) return body['metadata'] diff --git a/heatclient/v1/stacks.py b/heatclient/v1/stacks.py index 2d1ba6d..d918ba5 100644 --- a/heatclient/v1/stacks.py +++ b/heatclient/v1/stacks.py @@ -14,9 +14,9 @@ # under the License. import six +from six.moves.urllib import parse from heatclient.openstack.common.apiclient import base -from heatclient.openstack.common.py3kcompat import urlutils class Stack(base.Resource): @@ -78,7 +78,7 @@ class StackManager(base.BaseManager): def paginate(params): '''Paginate stacks, even if more than API limit.''' current_limit = int(params.get('limit') or 0) - url = '/stacks?%s' % urlutils.urlencode(params, True) + url = '/stacks?%s' % parse.urlencode(params, True) stacks = self._list(url, 'stacks') for stack in stacks: yield stack |