Remove six and python 2.7 full support
Six is in use to help us to keep support for python 2.7. Since the ussuri cycle we decide to remove the python 2.7 support so we can go ahead and also remove six usage from the python code. Review process and help ----------------------- Removing six introduce a lot of changes and an huge amount of modified files To simplify reviews we decided to split changes into several patches to avoid painful reviews and avoid mistakes. To review this patch you can use the six documentation [1] to obtain help and understand choices. Additional informations ----------------------- Changes related to 'six.b(data)' [2] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ six.b [2] encode the given datas in latin-1 in python3 so I did the same things in this patch. Latin-1 is equal to iso-8859-1 [3]. This encoding is the default encoding [4] of certain descriptive HTTP headers. I suggest to keep latin-1 for the moment and to move to another encoding in a follow-up patch if needed to move to most powerful encoding (utf8). HTML4 support utf8 charset and utf8 is the default charset for HTML5 [5]. Note that this commit message is autogenerated and not necesserly contains changes related to 'six.b' [1] https://six.readthedocs.io/ [2] https://six.readthedocs.io/#six.b [3] https://docs.python.org/3/library/codecs.html#standard-encodings [4] https://www.w3schools.com/charsets/ref_html_8859.asp [5] https://www.w3schools.com/html/html_charset.asp Patch 8 of a serie of 28 patches Change-Id: If54d634abfd345c1e672d31cb11de14260b34cc0
This commit is contained in:
parent
0de03fcdd3
commit
1c318a167c
|
@ -11,8 +11,6 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.common.i18n import _
|
from heat.common.i18n import _
|
||||||
from heat.engine import properties
|
from heat.engine import properties
|
||||||
|
@ -102,7 +100,7 @@ class VPCGatewayAttachment(resource.Resource):
|
||||||
default_client_name = 'neutron'
|
default_client_name = 'neutron'
|
||||||
|
|
||||||
def _vpc_route_tables(self, ignore_errors=False):
|
def _vpc_route_tables(self, ignore_errors=False):
|
||||||
for res in six.itervalues(self.stack):
|
for res in self.stack.values():
|
||||||
if res.has_interface('AWS::EC2::RouteTable'):
|
if res.has_interface('AWS::EC2::RouteTable'):
|
||||||
try:
|
try:
|
||||||
vpc_id = self.properties[self.VPC_ID]
|
vpc_id = self.properties[self.VPC_ID]
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.common.i18n import _
|
from heat.common.i18n import _
|
||||||
from heat.engine import properties
|
from heat.engine import properties
|
||||||
|
@ -169,12 +167,12 @@ class NeutronSecurityGroup(object):
|
||||||
rule['direction'] = 'egress'
|
rule['direction'] = 'egress'
|
||||||
for rule in updated[self.sg.SECURITY_GROUP_INGRESS]:
|
for rule in updated[self.sg.SECURITY_GROUP_INGRESS]:
|
||||||
rule['direction'] = 'ingress'
|
rule['direction'] = 'ingress'
|
||||||
updated_rules = list(six.itervalues(updated))
|
updated_rules = list(updated.values())
|
||||||
updated_all = updated_rules[0] + updated_rules[1]
|
updated_all = updated_rules[0] + updated_rules[1]
|
||||||
ids_to_delete = [id for id, rule in existing.items()
|
ids_to_delete = [id for id, rule in existing.items()
|
||||||
if rule not in updated_all]
|
if rule not in updated_all]
|
||||||
rules_to_create = [rule for rule in updated_all
|
rules_to_create = [rule for rule in updated_all
|
||||||
if rule not in six.itervalues(existing)]
|
if rule not in existing.values()]
|
||||||
return ids_to_delete, rules_to_create
|
return ids_to_delete, rules_to_create
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import six
|
|
||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.common.i18n import _
|
from heat.common.i18n import _
|
||||||
|
@ -80,7 +79,7 @@ class User(stack_user.StackUser):
|
||||||
# If a non-string (e.g embedded IAM dict policy) is passed, we
|
# If a non-string (e.g embedded IAM dict policy) is passed, we
|
||||||
# ignore the policy (don't reject it because we previously ignored
|
# ignore the policy (don't reject it because we previously ignored
|
||||||
# and we don't want to break templates which previously worked
|
# and we don't want to break templates which previously worked
|
||||||
if not isinstance(policy, six.string_types):
|
if not isinstance(policy, str):
|
||||||
LOG.debug("Ignoring policy %s, must be string "
|
LOG.debug("Ignoring policy %s, must be string "
|
||||||
"resource name", policy)
|
"resource name", policy)
|
||||||
continue
|
continue
|
||||||
|
@ -118,7 +117,7 @@ class User(stack_user.StackUser):
|
||||||
def access_allowed(self, resource_name):
|
def access_allowed(self, resource_name):
|
||||||
policies = (self.properties[self.POLICIES] or [])
|
policies = (self.properties[self.POLICIES] or [])
|
||||||
for policy in policies:
|
for policy in policies:
|
||||||
if not isinstance(policy, six.string_types):
|
if not isinstance(policy, str):
|
||||||
LOG.debug("Ignoring policy %s, must be string "
|
LOG.debug("Ignoring policy %s, must be string "
|
||||||
"resource name", policy)
|
"resource name", policy)
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -14,7 +14,6 @@ import os
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import six
|
|
||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.common.i18n import _
|
from heat.common.i18n import _
|
||||||
|
@ -623,7 +622,7 @@ backend servers
|
||||||
'Interval must be larger than Timeout'}
|
'Interval must be larger than Timeout'}
|
||||||
|
|
||||||
def get_reference_id(self):
|
def get_reference_id(self):
|
||||||
return six.text_type(self.name)
|
return str(self.name)
|
||||||
|
|
||||||
def _resolve_attribute(self, name):
|
def _resolve_attribute(self, name):
|
||||||
"""We don't really support any of these yet."""
|
"""We don't really support any of these yet."""
|
||||||
|
|
|
@ -10,8 +10,7 @@
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
import six
|
from urllib import parse
|
||||||
from six.moves.urllib import parse as urlparse
|
|
||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.common.i18n import _
|
from heat.common.i18n import _
|
||||||
|
@ -165,11 +164,11 @@ class S3Bucket(resource.Resource):
|
||||||
self.client_plugin().ignore_not_found(ex)
|
self.client_plugin().ignore_not_found(ex)
|
||||||
|
|
||||||
def get_reference_id(self):
|
def get_reference_id(self):
|
||||||
return six.text_type(self.resource_id)
|
return str(self.resource_id)
|
||||||
|
|
||||||
def _resolve_attribute(self, name):
|
def _resolve_attribute(self, name):
|
||||||
url = self.client().get_auth()[0]
|
url = self.client().get_auth()[0]
|
||||||
parsed = list(urlparse.urlparse(url))
|
parsed = list(parse.urlparse(url))
|
||||||
if name == self.DOMAIN_NAME:
|
if name == self.DOMAIN_NAME:
|
||||||
return parsed[1].split(':')[0]
|
return parsed[1].split(':')[0]
|
||||||
elif name == self.WEBSITE_URL:
|
elif name == self.WEBSITE_URL:
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from heat.common.i18n import _
|
from heat.common.i18n import _
|
||||||
from heat.engine import constraints
|
from heat.engine import constraints
|
||||||
from heat.engine import properties
|
from heat.engine import properties
|
||||||
|
@ -157,7 +155,7 @@ class AodhAlarm(alarm_base.BaseAlarm):
|
||||||
|
|
||||||
# make sure the matching_metadata appears in the query like this:
|
# make sure the matching_metadata appears in the query like this:
|
||||||
# {field: metadata.$prefix.x, ...}
|
# {field: metadata.$prefix.x, ...}
|
||||||
for m_k, m_v in six.iteritems(mmd):
|
for m_k, m_v in mmd.items():
|
||||||
key = 'metadata.%s' % prefix
|
key = 'metadata.%s' % prefix
|
||||||
if m_k.startswith('metadata.'):
|
if m_k.startswith('metadata.'):
|
||||||
m_k = m_k[len('metadata.'):]
|
m_k = m_k[len('metadata.'):]
|
||||||
|
@ -168,7 +166,7 @@ class AodhAlarm(alarm_base.BaseAlarm):
|
||||||
# NOTE(prazumovsky): type of query value must be a string, but
|
# NOTE(prazumovsky): type of query value must be a string, but
|
||||||
# matching_metadata value type can not be a string, so we
|
# matching_metadata value type can not be a string, so we
|
||||||
# must convert value to a string type.
|
# must convert value to a string type.
|
||||||
query.append(dict(field=key, op='eq', value=six.text_type(m_v)))
|
query.append(dict(field=key, op='eq', value=str(m_v)))
|
||||||
if self.MATCHING_METADATA in kwargs:
|
if self.MATCHING_METADATA in kwargs:
|
||||||
del kwargs[self.MATCHING_METADATA]
|
del kwargs[self.MATCHING_METADATA]
|
||||||
if self.QUERY in kwargs:
|
if self.QUERY in kwargs:
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.common.i18n import _
|
from heat.common.i18n import _
|
||||||
from heat.engine import attributes
|
from heat.engine import attributes
|
||||||
|
@ -192,12 +190,12 @@ class CertificateContainer(GenericContainer):
|
||||||
}
|
}
|
||||||
|
|
||||||
def create_container(self):
|
def create_container(self):
|
||||||
info = dict((k, v) for k, v in six.iteritems(self.properties)
|
info = dict((k, v) for k, v in self.properties.items()
|
||||||
if v is not None)
|
if v is not None)
|
||||||
return self.client_plugin().create_certificate(**info)
|
return self.client_plugin().create_certificate(**info)
|
||||||
|
|
||||||
def get_refs(self):
|
def get_refs(self):
|
||||||
return [v for k, v in six.iteritems(self.properties)
|
return [v for k, v in self.properties.items()
|
||||||
if (k != self.NAME and v is not None)]
|
if (k != self.NAME and v is not None)]
|
||||||
|
|
||||||
|
|
||||||
|
@ -239,12 +237,12 @@ class RSAContainer(GenericContainer):
|
||||||
}
|
}
|
||||||
|
|
||||||
def create_container(self):
|
def create_container(self):
|
||||||
info = dict((k, v) for k, v in six.iteritems(self.properties)
|
info = dict((k, v) for k, v in self.properties.items()
|
||||||
if v is not None)
|
if v is not None)
|
||||||
return self.client_plugin().create_rsa(**info)
|
return self.client_plugin().create_rsa(**info)
|
||||||
|
|
||||||
def get_refs(self):
|
def get_refs(self):
|
||||||
return [v for k, v in six.iteritems(self.properties)
|
return [v for k, v in self.properties.items()
|
||||||
if (k != self.NAME and v is not None)]
|
if (k != self.NAME and v is not None)]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.common.i18n import _
|
from heat.common.i18n import _
|
||||||
from heat.engine import attributes
|
from heat.engine import attributes
|
||||||
|
@ -228,8 +226,8 @@ class Order(resource.Resource):
|
||||||
raise exception.ResourcePropertyDependency(
|
raise exception.ResourcePropertyDependency(
|
||||||
prop1=self.PROFILE, prop2=self.CA_ID
|
prop1=self.PROFILE, prop2=self.CA_ID
|
||||||
)
|
)
|
||||||
declared_props = sorted([k for k, v in six.iteritems(
|
declared_props = sorted([k for k, v in self.properties.items()
|
||||||
self.properties) if k != self.TYPE and v is not None])
|
if k != self.TYPE and v is not None])
|
||||||
allowed_props = sorted(self.ALLOWED_PROPERTIES_FOR_TYPE[
|
allowed_props = sorted(self.ALLOWED_PROPERTIES_FOR_TYPE[
|
||||||
self.properties[self.TYPE]])
|
self.properties[self.TYPE]])
|
||||||
diff = sorted(set(declared_props) - set(allowed_props))
|
diff = sorted(set(declared_props) - set(allowed_props))
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
import six
|
|
||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.common.i18n import _
|
from heat.common.i18n import _
|
||||||
|
@ -310,7 +309,7 @@ class CinderVolume(vb.BaseVolume, sh.SchedulerHintsMixin):
|
||||||
cinder = self.client()
|
cinder = self.client()
|
||||||
vol = cinder.volumes.get(self.resource_id)
|
vol = cinder.volumes.get(self.resource_id)
|
||||||
if name == self.METADATA_ATTR:
|
if name == self.METADATA_ATTR:
|
||||||
return six.text_type(jsonutils.dumps(vol.metadata))
|
return str(jsonutils.dumps(vol.metadata))
|
||||||
elif name == self.METADATA_VALUES_ATTR:
|
elif name == self.METADATA_VALUES_ATTR:
|
||||||
return vol.metadata
|
return vol.metadata
|
||||||
if name == self.DISPLAY_NAME_ATTR:
|
if name == self.DISPLAY_NAME_ATTR:
|
||||||
|
@ -319,7 +318,7 @@ class CinderVolume(vb.BaseVolume, sh.SchedulerHintsMixin):
|
||||||
return vol.description
|
return vol.description
|
||||||
elif name == self.ATTACHMENTS_LIST:
|
elif name == self.ATTACHMENTS_LIST:
|
||||||
return vol.attachments
|
return vol.attachments
|
||||||
return six.text_type(getattr(vol, name))
|
return str(getattr(vol, name))
|
||||||
|
|
||||||
def check_create_complete(self, vol_id):
|
def check_create_complete(self, vol_id):
|
||||||
complete = super(CinderVolume, self).check_create_complete(vol_id)
|
complete = super(CinderVolume, self).check_create_complete(vol_id)
|
||||||
|
@ -355,7 +354,7 @@ class CinderVolume(vb.BaseVolume, sh.SchedulerHintsMixin):
|
||||||
if self.client_plugin().is_client_exception(ex):
|
if self.client_plugin().is_client_exception(ex):
|
||||||
raise exception.Error(_(
|
raise exception.Error(_(
|
||||||
"Failed to extend volume %(vol)s - %(err)s") % {
|
"Failed to extend volume %(vol)s - %(err)s") % {
|
||||||
'vol': self.resource_id, 'err': six.text_type(ex)})
|
'vol': self.resource_id, 'err': str(ex)})
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.common.i18n import _
|
from heat.common.i18n import _
|
||||||
from heat.engine import constraints
|
from heat.engine import constraints
|
||||||
|
@ -99,7 +97,7 @@ class DesignateRecordSet(resource.Resource):
|
||||||
entity = 'recordsets'
|
entity = 'recordsets'
|
||||||
|
|
||||||
def handle_create(self):
|
def handle_create(self):
|
||||||
args = dict((k, v) for k, v in six.iteritems(self.properties) if v)
|
args = dict((k, v) for k, v in self.properties.items() if v)
|
||||||
args['type_'] = args.pop(self.TYPE)
|
args['type_'] = args.pop(self.TYPE)
|
||||||
if not args.get(self.NAME):
|
if not args.get(self.NAME):
|
||||||
args[self.NAME] = self.physical_resource_name()
|
args[self.NAME] = self.physical_resource_name()
|
||||||
|
|
Loading…
Reference in New Issue