diff options
Diffstat (limited to 'heat/api')
-rw-r--r-- | heat/api/openstack/v1/stacks.py | 26 | ||||
-rw-r--r-- | heat/api/openstack/v1/util.py | 9 | ||||
-rw-r--r-- | heat/api/openstack/v1/views/views_common.py | 2 | ||||
-rw-r--r-- | heat/api/versions.py | 8 |
4 files changed, 21 insertions, 24 deletions
diff --git a/heat/api/openstack/v1/stacks.py b/heat/api/openstack/v1/stacks.py index d144ea197..8830c22b3 100644 --- a/heat/api/openstack/v1/stacks.py +++ b/heat/api/openstack/v1/stacks.py @@ -15,8 +15,7 @@ import contextlib from oslo_log import log as logging -import six -from six.moves.urllib import parse +from urllib import parse from webob import exc from heat.api.openstack.v1 import util @@ -79,7 +78,7 @@ class InstantiationData(object): try: yield except ValueError as parse_ex: - mdict = {'type': data_type, 'error': six.text_type(parse_ex)} + mdict = {'type': data_type, 'error': str(parse_ex)} msg = _("%(type)s not in valid format: %(error)s") % mdict raise exc.HTTPBadRequest(msg) @@ -101,7 +100,7 @@ class InstantiationData(object): try: adopt_data = template_format.simple_parse(adopt_data) template_format.validate_template_limit( - six.text_type(adopt_data['template'])) + str(adopt_data['template'])) return adopt_data['template'] except (ValueError, KeyError) as ex: err_reason = _('Invalid adopt data: %s') % ex @@ -109,7 +108,7 @@ class InstantiationData(object): elif self.PARAM_TEMPLATE in self.data: template_data = self.data[self.PARAM_TEMPLATE] if isinstance(template_data, dict): - template_format.validate_template_limit(six.text_type( + template_format.validate_template_limit(str( template_data)) return template_data @@ -188,7 +187,7 @@ class StackController(object): try: return param_utils.extract_bool(name, value) except ValueError as e: - raise exc.HTTPBadRequest(six.text_type(e)) + raise exc.HTTPBadRequest(str(e)) def _extract_int_param(self, name, value, allow_zero=True, allow_negative=False): @@ -196,13 +195,13 @@ class StackController(object): return param_utils.extract_int(name, value, allow_zero, allow_negative) except ValueError as e: - raise exc.HTTPBadRequest(six.text_type(e)) + raise exc.HTTPBadRequest(str(e)) def _extract_tags_param(self, tags): try: return param_utils.extract_tags(tags) except ValueError as e: - raise exc.HTTPBadRequest(six.text_type(e)) + raise exc.HTTPBadRequest(str(e)) def _index(self, req, use_admin_cnxt=False): filter_whitelist = { @@ -392,7 +391,7 @@ class StackController(object): if not is_update and key in args: msg = _("%s flag only supported in stack update (or update " "preview) request.") % key - raise exc.HTTPBadRequest(six.text_type(msg)) + raise exc.HTTPBadRequest(str(msg)) return args @util.registered_policy_enforce @@ -700,7 +699,7 @@ class StackController(object): req.params.get(rpc_api.TEMPLATE_TYPE)) except ValueError as ex: msg = _("Template type is not supported: %s") % ex - raise exc.HTTPBadRequest(six.text_type(msg)) + raise exc.HTTPBadRequest(str(msg)) return self.rpc_client.generate_template(req.context, type_name, @@ -753,10 +752,7 @@ class StackSerializer(serializers.JSONResponseSerializer): def _populate_response_header(self, response, location, status): response.status = status - if six.PY2: - response.headers['Location'] = location.encode('utf-8') - else: - response.headers['Location'] = location + response.headers['Location'] = location response.headers['Content-Type'] = 'application/json' return response @@ -764,7 +760,7 @@ class StackSerializer(serializers.JSONResponseSerializer): self._populate_response_header(response, result['stack']['links'][0]['href'], 201) - response.body = six.b(self.to_json(result)) + response.body = self.to_json(result).encode('latin-1') return response diff --git a/heat/api/openstack/v1/util.py b/heat/api/openstack/v1/util.py index 3bf6dab13..a9f8b5cf7 100644 --- a/heat/api/openstack/v1/util.py +++ b/heat/api/openstack/v1/util.py @@ -11,7 +11,8 @@ # License for the specific language governing permissions and limitations # under the License. -import six +import functools + from webob import exc from heat.common.i18n import _ @@ -41,7 +42,7 @@ def registered_policy_enforce(handler): def _policy_enforce(handler, is_registered_policy=False): - @six.wraps(handler) + @functools.wraps(handler) def handle_stack_method(controller, req, tenant_id, **kwargs): if req.context.tenant_id != tenant_id and not req.context.is_admin: raise exc.HTTPForbidden() @@ -77,7 +78,7 @@ def registered_identified_stack(handler): def _identified_stack(handler, is_registered_policy=False): - @six.wraps(handler) + @functools.wraps(handler) def handle_stack_method(controller, req, stack_name, stack_id, **kwargs): stack_identity = identifier.HeatIdentifier(req.context.tenant_id, stack_name, @@ -126,7 +127,7 @@ def get_allowed_params(params, whitelist): """ allowed_params = {} - for key, get_type in six.iteritems(whitelist): + for key, get_type in whitelist.items(): assert get_type in PARAM_TYPES value = None diff --git a/heat/api/openstack/v1/views/views_common.py b/heat/api/openstack/v1/views/views_common.py index 030980066..c5514e4ba 100644 --- a/heat/api/openstack/v1/views/views_common.py +++ b/heat/api/openstack/v1/views/views_common.py @@ -11,7 +11,7 @@ # License for the specific language governing permissions and limitations # under the License. -from six.moves.urllib import parse as urlparse +from urllib import parse as urlparse def get_collection_links(request, items): diff --git a/heat/api/versions.py b/heat/api/versions.py index 41cbf2699..c49b0ec76 100644 --- a/heat/api/versions.py +++ b/heat/api/versions.py @@ -13,9 +13,9 @@ """Controller that returns information on the heat API versions.""" +import http.client + from oslo_serialization import jsonutils -import six -from six.moves import http_client import webob.dec @@ -43,11 +43,11 @@ class Controller(object): body = jsonutils.dumps(dict(versions=version_objs)) response = webob.Response(request=req, - status=http_client.MULTIPLE_CHOICES, + status=http.client.MULTIPLE_CHOICES, content_type='application/json') # NOTE(pas-ha) in WebOb, Response.body accepts only bytes, # and Response.text accepts only unicode. - response.text = six.text_type(body) + response.text = str(body) return response |