WIP - Remove six and python2.7 backward compatibility
Change-Id: I923476edaa09ae8ccaa9cd2392ff5e3cf5a0cc87
This commit is contained in:
parent
e0dbb3f7fa
commit
faa4af97ad
|
@ -24,7 +24,6 @@ from oslo_config import cfg
|
|||
import oslo_i18n as i18n
|
||||
from oslo_log import log as logging
|
||||
from oslo_service import systemd
|
||||
import six
|
||||
|
||||
from heat.cmd import api
|
||||
from heat.cmd import api_cfn
|
||||
|
@ -83,5 +82,5 @@ def main():
|
|||
systemd.notify_once()
|
||||
[service.wait() for service in services]
|
||||
except RuntimeError as e:
|
||||
msg = six.text_type(e)
|
||||
msg = str(e)
|
||||
sys.exit("ERROR: %s" % msg)
|
||||
|
|
|
@ -26,7 +26,6 @@ import oslo_i18n as i18n
|
|||
from oslo_log import log as logging
|
||||
from oslo_reports import guru_meditation_report as gmr
|
||||
from oslo_service import systemd
|
||||
import six
|
||||
|
||||
from heat.common import config
|
||||
from heat.common import messaging
|
||||
|
@ -70,5 +69,5 @@ def main():
|
|||
systemd.notify_once()
|
||||
server.wait()
|
||||
except RuntimeError as e:
|
||||
msg = six.text_type(e)
|
||||
msg = str(e)
|
||||
sys.exit("ERROR: %s" % msg)
|
||||
|
|
|
@ -28,7 +28,6 @@ import oslo_i18n as i18n
|
|||
from oslo_log import log as logging
|
||||
from oslo_reports import guru_meditation_report as gmr
|
||||
from oslo_service import systemd
|
||||
import six
|
||||
|
||||
from heat.common import config
|
||||
from heat.common import messaging
|
||||
|
@ -74,5 +73,5 @@ def main():
|
|||
systemd.notify_once()
|
||||
server.wait()
|
||||
except RuntimeError as e:
|
||||
msg = six.text_type(e)
|
||||
msg = str(e)
|
||||
sys.exit("ERROR: %s" % msg)
|
||||
|
|
|
@ -19,7 +19,6 @@ import sys
|
|||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
from six import moves
|
||||
|
||||
from heat.common import context
|
||||
from heat.common import exception
|
||||
|
@ -106,7 +105,7 @@ def do_reset_stack_status():
|
|||
"intended to recover from specific crashes."))
|
||||
print(_("It is advised to shutdown all Heat engines beforehand."))
|
||||
print(_("Continue ? [y/N]"))
|
||||
data = moves.input()
|
||||
data = input()
|
||||
if not data.lower().startswith('y'):
|
||||
return
|
||||
ctxt = context.get_admin_context()
|
||||
|
|
|
@ -26,7 +26,6 @@ from oslo_log import log as logging
|
|||
from oslo_utils import encodeutils
|
||||
from oslo_utils import timeutils
|
||||
import osprofiler.sqlalchemy
|
||||
import six
|
||||
import sqlalchemy
|
||||
from sqlalchemy import and_
|
||||
from sqlalchemy import func
|
||||
|
@ -90,7 +89,7 @@ def get_session():
|
|||
|
||||
def update_and_save(context, obj, values):
|
||||
with context.session.begin(subtransactions=True):
|
||||
for k, v in six.iteritems(values):
|
||||
for k, v in values.items():
|
||||
setattr(obj, k, v)
|
||||
|
||||
|
||||
|
@ -640,7 +639,7 @@ def _get_sort_keys(sort_keys, mapping):
|
|||
:param mapping: a mapping from keys to DB column names
|
||||
:returns: filtered list of sort keys
|
||||
"""
|
||||
if isinstance(sort_keys, six.string_types):
|
||||
if isinstance(sort_keys, str):
|
||||
sort_keys = [sort_keys]
|
||||
return [mapping[key] for key in sort_keys or [] if key in mapping]
|
||||
|
||||
|
@ -929,7 +928,7 @@ def user_creds_create(context):
|
|||
else:
|
||||
user_creds_ref.update(values)
|
||||
method, password = crypt.encrypt(values['password'])
|
||||
if len(six.text_type(password)) > 255:
|
||||
if len(str(password)) > 255:
|
||||
raise exception.Error(_("Length of OS_PASSWORD after encryption"
|
||||
" exceeds Heat limit (255 chars)"))
|
||||
user_creds_ref.password = password
|
||||
|
@ -1156,7 +1155,7 @@ def event_create(context, values):
|
|||
_delete_event_rows(context, values['stack_id'],
|
||||
cfg.CONF.event_purge_batch_size)
|
||||
except db_exception.DBError as exc:
|
||||
LOG.error('Failed to purge events: %s', six.text_type(exc))
|
||||
LOG.error('Failed to purge events: %s', str(exc))
|
||||
event_ref = models.Event()
|
||||
event_ref.update(values)
|
||||
event_ref.save(context.session)
|
||||
|
@ -1647,7 +1646,7 @@ def _db_encrypt_or_decrypt_template_params(
|
|||
not param_schemata[param_name].hidden):
|
||||
continue
|
||||
encrypted_val = crypt.encrypt(
|
||||
six.text_type(param_val), encryption_key)
|
||||
str(param_val), encryption_key)
|
||||
env['parameters'][param_name] = encrypted_val
|
||||
encrypted_params.append(param_name)
|
||||
needs_update = True
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
|
||||
|
||||
def exact_filter(query, model, filters):
|
||||
"""Applies exact match filtering to a query.
|
||||
|
@ -33,7 +31,7 @@ def exact_filter(query, model, filters):
|
|||
if filters is None:
|
||||
filters = {}
|
||||
|
||||
for key, value in six.iteritems(filters):
|
||||
for key, value in filters.items():
|
||||
if isinstance(value, (list, tuple, set, frozenset)):
|
||||
column_attr = getattr(model, key)
|
||||
query = query.filter(column_attr.in_(value))
|
||||
|
|
|
@ -13,8 +13,6 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import six
|
||||
|
||||
import eventlet.queue
|
||||
import functools
|
||||
|
||||
|
@ -83,7 +81,7 @@ class CheckResource(object):
|
|||
'during resource %s' % rsrc.action)
|
||||
rsrc.state_set(rsrc.action,
|
||||
rsrc.FAILED,
|
||||
six.text_type(status_reason))
|
||||
str(status_reason))
|
||||
return True
|
||||
elif (rs_obj.engine_id is None and
|
||||
rs_obj.current_template_id == prev_template_id):
|
||||
|
@ -173,7 +171,7 @@ class CheckResource(object):
|
|||
except exception.ResourceFailure as ex:
|
||||
action = ex.action or rsrc.action
|
||||
reason = 'Resource %s failed: %s' % (action,
|
||||
six.text_type(ex))
|
||||
str(ex))
|
||||
self._handle_resource_failure(cnxt, is_update, rsrc.id,
|
||||
stack, reason)
|
||||
except scheduler.Timeout:
|
||||
|
@ -319,7 +317,7 @@ class CheckResource(object):
|
|||
rsrc, stack)
|
||||
except BaseException as exc:
|
||||
with excutils.save_and_reraise_exception():
|
||||
msg = six.text_type(exc)
|
||||
msg = str(exc)
|
||||
LOG.exception("Unexpected exception in resource check.")
|
||||
self._handle_resource_failure(cnxt, is_update, rsrc.id,
|
||||
stack, msg)
|
||||
|
|
|
@ -16,14 +16,11 @@ import collections
|
|||
import itertools
|
||||
import weakref
|
||||
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class Function(object):
|
||||
class Function(metaclass=abc.ABCMeta):
|
||||
"""Abstract base class for template functions."""
|
||||
|
||||
def __init__(self, stack, fn_name, args):
|
||||
|
@ -98,13 +95,13 @@ class Function(object):
|
|||
return all_dep_attrs(self.args)
|
||||
|
||||
def res_dep_attrs(resource_name):
|
||||
return six.moves.zip(itertools.repeat(resource_name),
|
||||
self.dep_attrs(resource_name))
|
||||
return zip(itertools.repeat(resource_name),
|
||||
self.dep_attrs(resource_name))
|
||||
|
||||
resource_names = self.stack.enabled_rsrc_names()
|
||||
|
||||
return itertools.chain.from_iterable(six.moves.map(res_dep_attrs,
|
||||
resource_names))
|
||||
return itertools.chain.from_iterable(map(res_dep_attrs,
|
||||
resource_names))
|
||||
|
||||
def __reduce__(self):
|
||||
"""Return a representation of the function suitable for pickling.
|
||||
|
@ -160,8 +157,7 @@ class Function(object):
|
|||
__hash__ = None
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class Macro(Function):
|
||||
class Macro(Function, metaclass=abc.ABCMeta):
|
||||
"""Abstract base class for template macros.
|
||||
|
||||
A macro differs from a function in that it controls how the template is
|
||||
|
@ -260,7 +256,7 @@ def resolve(snippet):
|
|||
|
||||
if isinstance(snippet, collections.Mapping):
|
||||
return dict((k, resolve(v)) for k, v in snippet.items())
|
||||
elif (not isinstance(snippet, six.string_types) and
|
||||
elif (not isinstance(snippet, str) and
|
||||
isinstance(snippet, collections.Iterable)):
|
||||
return [resolve(v) for v in snippet]
|
||||
|
||||
|
@ -270,7 +266,7 @@ def resolve(snippet):
|
|||
def validate(snippet, path=None):
|
||||
if path is None:
|
||||
path = []
|
||||
elif isinstance(path, six.string_types):
|
||||
elif isinstance(path, str):
|
||||
path = [path]
|
||||
|
||||
if isinstance(snippet, Function):
|
||||
|
@ -281,11 +277,11 @@ def validate(snippet, path=None):
|
|||
except Exception as e:
|
||||
raise exception.StackValidationFailed(
|
||||
path=path + [snippet.fn_name],
|
||||
message=six.text_type(e))
|
||||
message=str(e))
|
||||
elif isinstance(snippet, collections.Mapping):
|
||||
for k, v in six.iteritems(snippet):
|
||||
for k, v in snippet.items():
|
||||
validate(v, path + [k])
|
||||
elif (not isinstance(snippet, six.string_types) and
|
||||
elif (not isinstance(snippet, str) and
|
||||
isinstance(snippet, collections.Iterable)):
|
||||
basepath = list(path)
|
||||
parent = basepath.pop() if basepath else ''
|
||||
|
@ -305,13 +301,13 @@ def dependencies(snippet, path=''):
|
|||
|
||||
elif isinstance(snippet, collections.Mapping):
|
||||
def mkpath(key):
|
||||
return '.'.join([path, six.text_type(key)])
|
||||
return '.'.join([path, str(key)])
|
||||
|
||||
deps = (dependencies(value,
|
||||
mkpath(key)) for key, value in snippet.items())
|
||||
return itertools.chain.from_iterable(deps)
|
||||
|
||||
elif (not isinstance(snippet, six.string_types) and
|
||||
elif (not isinstance(snippet, str) and
|
||||
isinstance(snippet, collections.Iterable)):
|
||||
def mkpath(idx):
|
||||
return ''.join([path, '[%d]' % idx])
|
||||
|
@ -340,7 +336,7 @@ def dep_attrs(snippet, resource_name):
|
|||
elif isinstance(snippet, collections.Mapping):
|
||||
attrs = (dep_attrs(val, resource_name) for val in snippet.values())
|
||||
return itertools.chain.from_iterable(attrs)
|
||||
elif (not isinstance(snippet, six.string_types) and
|
||||
elif (not isinstance(snippet, str) and
|
||||
isinstance(snippet, collections.Iterable)):
|
||||
attrs = (dep_attrs(value, resource_name) for value in snippet)
|
||||
return itertools.chain.from_iterable(attrs)
|
||||
|
@ -363,7 +359,7 @@ def all_dep_attrs(snippet):
|
|||
elif isinstance(snippet, collections.Mapping):
|
||||
res_attrs = (all_dep_attrs(value) for value in snippet.values())
|
||||
return itertools.chain.from_iterable(res_attrs)
|
||||
elif (not isinstance(snippet, six.string_types) and
|
||||
elif (not isinstance(snippet, str) and
|
||||
isinstance(snippet, collections.Iterable)):
|
||||
res_attrs = (all_dep_attrs(value) for value in snippet)
|
||||
return itertools.chain.from_iterable(res_attrs)
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
|
||||
|
||||
class NodeData(object):
|
||||
"""Data about a node in the graph, to be passed along to other nodes."""
|
||||
|
@ -53,8 +51,8 @@ class NodeData(object):
|
|||
"""Return a dict of all available top-level attribute values."""
|
||||
attrs = {k: v
|
||||
for k, v in self._attributes.items()
|
||||
if isinstance(k, six.string_types)}
|
||||
for v in six.itervalues(attrs):
|
||||
if isinstance(k, str)}
|
||||
for v in attrs.items():
|
||||
if isinstance(v, Exception):
|
||||
raise v
|
||||
return attrs
|
||||
|
@ -69,7 +67,7 @@ class NodeData(object):
|
|||
def attribute_names(self):
|
||||
"""Iterate over valid top-level attribute names."""
|
||||
for key in self._attributes:
|
||||
if isinstance(key, six.string_types):
|
||||
if isinstance(key, str):
|
||||
yield key
|
||||
else:
|
||||
yield key[0]
|
||||
|
@ -80,7 +78,7 @@ class NodeData(object):
|
|||
This is the format that is serialised and stored in the database's
|
||||
SyncPoints.
|
||||
"""
|
||||
for v in six.itervalues(self._attributes):
|
||||
for v in self._attributes.values():
|
||||
if isinstance(v, Exception):
|
||||
raise v
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
import collections
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
|
@ -274,9 +273,9 @@ class Property(object):
|
|||
def _get_string(self, value):
|
||||
if value is None:
|
||||
value = self.has_default() and self.default() or ''
|
||||
if not isinstance(value, six.string_types):
|
||||
if not isinstance(value, str):
|
||||
if isinstance(value, (bool, int)):
|
||||
value = six.text_type(value)
|
||||
value = str(value)
|
||||
else:
|
||||
raise ValueError(_('Value must be a string; got %r') % value)
|
||||
return value
|
||||
|
@ -306,24 +305,23 @@ class Property(object):
|
|||
# via a provider resource, in particular lists-of-dicts which
|
||||
# cannot be handled correctly via comma_delimited_list
|
||||
if self.schema.allow_conversion:
|
||||
if isinstance(value, six.string_types):
|
||||
if isinstance(value, str):
|
||||
return value
|
||||
elif isinstance(value, collections.Sequence):
|
||||
return jsonutils.dumps(value)
|
||||
raise TypeError(_('"%s" is not a map') % value)
|
||||
|
||||
return dict(self._get_children(six.iteritems(value),
|
||||
return dict(self._get_children(value.items(),
|
||||
validate=validate,
|
||||
translation=translation))
|
||||
|
||||
def _get_list(self, value, validate=False, translation=None):
|
||||
if value is None:
|
||||
value = self.has_default() and self.default() or []
|
||||
if self.schema.allow_conversion and isinstance(value,
|
||||
six.string_types):
|
||||
if self.schema.allow_conversion and isinstance(value, str):
|
||||
value = param_utils.delim_string_to_list(value)
|
||||
if (not isinstance(value, collections.Sequence) or
|
||||
isinstance(value, six.string_types)):
|
||||
isinstance(value, str)):
|
||||
raise TypeError(_('"%s" is not a list') % repr(value))
|
||||
|
||||
return [v[1] for v in self._get_children(enumerate(value),
|
||||
|
@ -341,7 +339,7 @@ class Property(object):
|
|||
value = self.has_default() and self.default() or False
|
||||
if isinstance(value, bool):
|
||||
return value
|
||||
if isinstance(value, six.string_types):
|
||||
if isinstance(value, str):
|
||||
normalised = value.lower()
|
||||
if normalised not in ['true', 'false']:
|
||||
raise ValueError(_('"%s" is not a valid boolean') % normalised)
|
||||
|
@ -430,7 +428,7 @@ class Properties(collections.Mapping):
|
|||
else:
|
||||
path = [key]
|
||||
raise exception.StackValidationFailed(
|
||||
path=path, message=six.text_type(e))
|
||||
path=path, message=str(e))
|
||||
|
||||
# are there unimplemented Properties
|
||||
if not prop.implemented() and key in self.data:
|
||||
|
@ -486,7 +484,7 @@ class Properties(collections.Mapping):
|
|||
# the resolver function could raise any number of exceptions,
|
||||
# so handle this generically
|
||||
except Exception as e:
|
||||
raise ValueError(six.text_type(e))
|
||||
raise ValueError(str(e))
|
||||
|
||||
def _get_property_value(self, key, validate=False):
|
||||
if key not in self:
|
||||
|
@ -652,7 +650,7 @@ class Properties(collections.Mapping):
|
|||
return {}, {}
|
||||
|
||||
param_prop_defs = [param_prop_def_items(n, s, template_type)
|
||||
for n, s in six.iteritems(schemata(schema))
|
||||
for n, s in schemata(schema).items()
|
||||
if s.implemented]
|
||||
param_items, prop_items = zip(*param_prop_defs)
|
||||
return dict(param_items), dict(prop_items)
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
from heat.engine import attributes
|
||||
|
@ -192,12 +190,12 @@ class CertificateContainer(GenericContainer):
|
|||
}
|
||||
|
||||
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)
|
||||
return self.client_plugin().create_certificate(**info)
|
||||
|
||||
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)]
|
||||
|
||||
|
||||
|
@ -239,12 +237,12 @@ class RSAContainer(GenericContainer):
|
|||
}
|
||||
|
||||
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)
|
||||
return self.client_plugin().create_rsa(**info)
|
||||
|
||||
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)]
|
||||
|
||||
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
from heat.engine import constraints
|
||||
|
@ -103,7 +101,7 @@ class DesignateRecordSet(resource.Resource):
|
|||
self).client(version=self.client_plugin().V2)
|
||||
|
||||
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)
|
||||
if not args.get(self.NAME):
|
||||
args[self.NAME] = self.physical_resource_name()
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
|
@ -126,7 +125,7 @@ class DesignateZone(resource.Resource):
|
|||
raise_invalid_exception(self.SECONDARY, self.MASTERS)
|
||||
|
||||
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)
|
||||
|
||||
zone = self.client().zones.create(**args)
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
|
||||
from oslo_log import log as logging
|
||||
|
||||
from heat.common import exception
|
||||
|
@ -208,7 +206,7 @@ class AutoScalingResourceGroup(aws_asg.AutoScalingGroup):
|
|||
template_version=template_version)
|
||||
|
||||
def _attribute_output_name(self, *attr_path):
|
||||
return ', '.join(six.text_type(a) for a in attr_path)
|
||||
return ', '.join(str(a) for a in attr_path)
|
||||
|
||||
def get_attribute(self, key, *path):
|
||||
if key == self.CURRENT_SIZE:
|
||||
|
@ -280,7 +278,7 @@ class AutoScalingResourceGroup(aws_asg.AutoScalingGroup):
|
|||
|
||||
def _nested_output_defns(self, resource_names, get_attr_fn, get_res_fn):
|
||||
for attr in self.referenced_attrs():
|
||||
if isinstance(attr, six.string_types):
|
||||
if isinstance(attr, str):
|
||||
key, path = attr, []
|
||||
else:
|
||||
key, path = attr[0], list(attr[1:])
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
# under the License.
|
||||
|
||||
import functools
|
||||
import six
|
||||
|
||||
from oslo_log import log as logging
|
||||
|
||||
|
@ -460,7 +459,7 @@ class InstanceGroup(stack_resource.StackResource):
|
|||
|
||||
def _nested_output_defns(self, resource_names, get_attr_fn, get_res_fn):
|
||||
for attr in self.referenced_attrs():
|
||||
if isinstance(attr, six.string_types):
|
||||
if isinstance(attr, str):
|
||||
key = attr
|
||||
else:
|
||||
key = attr[0]
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
import uuid
|
||||
|
||||
from heat.engine import properties
|
||||
|
@ -47,7 +46,7 @@ class NoneResource(resource.Resource):
|
|||
self.translate_properties(self.properties, client_resolve)
|
||||
|
||||
def handle_create(self):
|
||||
self.resource_id_set(six.text_type(uuid.uuid4()))
|
||||
self.resource_id_set(str(uuid.uuid4()))
|
||||
# set is_placeholder flag when resource trying to replace original
|
||||
# resource with a placeholder resource.
|
||||
self.data_set(self.IS_PLACEHOLDER, 'True')
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
from heat.common import password_gen
|
||||
|
@ -235,7 +233,7 @@ class RandomString(resource.Resource):
|
|||
if self.resource_id is not None:
|
||||
return self.data().get('value')
|
||||
else:
|
||||
return six.text_type(self.name)
|
||||
return str(self.name)
|
||||
|
||||
|
||||
def resource_mapping():
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
import six
|
||||
import tempfile
|
||||
|
||||
from heat.common import auth_plugin
|
||||
|
@ -49,7 +48,7 @@ class TempCACertFile(object):
|
|||
try:
|
||||
self._cacert_temp_file = tempfile.NamedTemporaryFile()
|
||||
self._cacert_temp_file.write(
|
||||
six.text_type(self._cacert).encode('utf-8'))
|
||||
str(self._cacert).encode('utf-8'))
|
||||
# Add seek func to make sure the writen context will flush to
|
||||
# tempfile with python 2.7. we can use flush() for python 2.7
|
||||
# but not 3.5.
|
||||
|
@ -264,7 +263,7 @@ class RemoteStack(resource.Resource):
|
|||
location = "remote cloud"
|
||||
else:
|
||||
location = 'region "%s"' % self._region_name
|
||||
exc_info = dict(location=location, exc=six.text_type(ex))
|
||||
exc_info = dict(location=location, exc=str(ex))
|
||||
msg = _('Cannot establish connection to Heat endpoint at '
|
||||
'%(location)s due to "%(exc)s"') % exc_info
|
||||
raise exception.StackValidationFailed(message=msg)
|
||||
|
@ -285,7 +284,7 @@ class RemoteStack(resource.Resource):
|
|||
location = "remote cloud"
|
||||
else:
|
||||
location = 'region "%s"' % self._region_name
|
||||
exc_info = dict(location=location, exc=six.text_type(ex))
|
||||
exc_info = dict(location=location, exc=str(ex))
|
||||
msg = _('Failed validating stack template using Heat endpoint at '
|
||||
'%(location)s due to "%(exc)s"') % exc_info
|
||||
raise exception.StackValidationFailed(message=msg)
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
# under the License.
|
||||
|
||||
import functools
|
||||
import six
|
||||
|
||||
from oslo_log import log as logging
|
||||
|
||||
|
@ -155,7 +154,7 @@ class ResourceChain(stack_resource.StackResource):
|
|||
return {}
|
||||
|
||||
def _attribute_output_name(self, *attr_path):
|
||||
return ', '.join(six.text_type(a) for a in attr_path)
|
||||
return ', '.join(str(a) for a in attr_path)
|
||||
|
||||
def get_attribute(self, key, *path):
|
||||
if key == self.ATTR_ATTRIBUTES and not path:
|
||||
|
@ -198,7 +197,7 @@ class ResourceChain(stack_resource.StackResource):
|
|||
|
||||
def _nested_output_defns(self, resource_names, get_attr_fn, get_res_fn):
|
||||
for attr in self.referenced_attrs():
|
||||
if isinstance(attr, six.string_types):
|
||||
if isinstance(attr, str):
|
||||
key, path = attr, []
|
||||
else:
|
||||
key, path = attr[0], list(attr[1:])
|
||||
|
@ -227,7 +226,7 @@ class ResourceChain(stack_resource.StackResource):
|
|||
@staticmethod
|
||||
def _resource_names(resource_types):
|
||||
"""Returns a list of unique resource names to create."""
|
||||
return [six.text_type(i) for i, t in enumerate(resource_types)]
|
||||
return [str(i) for i, t in enumerate(resource_types)]
|
||||
|
||||
def _build_resource_definition(self, resource_name, resource_type,
|
||||
depends_on=None):
|
||||
|
|
|
@ -15,7 +15,6 @@ import collections
|
|||
import copy
|
||||
import functools
|
||||
import itertools
|
||||
import six
|
||||
|
||||
from oslo_log import log as logging
|
||||
|
||||
|
@ -306,7 +305,8 @@ class ResourceGroup(stack_resource.StackResource):
|
|||
first_name = next(self._resource_names())
|
||||
test_tmpl = self._assemble_nested([first_name],
|
||||
include_all=True)
|
||||
res_def = next(six.itervalues(test_tmpl.resource_definitions(None)))
|
||||
res_def = next(iter(list(test_tmpl.resource_definitions(None).values())
|
||||
))
|
||||
# make sure we can resolve the nested resource type
|
||||
self.stack.env.get_class_to_instantiate(res_def.resource_type)
|
||||
|
||||
|
@ -339,12 +339,12 @@ class ResourceGroup(stack_resource.StackResource):
|
|||
if self.REMOVAL_RSRC_LIST in r:
|
||||
# Tolerate string or int list values
|
||||
for n in r[self.REMOVAL_RSRC_LIST]:
|
||||
str_n = six.text_type(n)
|
||||
str_n = str(n)
|
||||
if (str_n in current_blacklist or
|
||||
self.resource_id is None or
|
||||
str_n in insp.member_names(include_failed=True)):
|
||||
yield str_n
|
||||
elif isinstance(n, six.string_types):
|
||||
elif isinstance(n, str):
|
||||
try:
|
||||
refids = self.get_output(self.REFS_MAP)
|
||||
except (exception.NotFound,
|
||||
|
@ -399,9 +399,9 @@ class ResourceGroup(stack_resource.StackResource):
|
|||
def is_blacklisted(name):
|
||||
return name in name_blacklist
|
||||
|
||||
candidates = six.moves.map(six.text_type, itertools.count())
|
||||
candidates = map(str, itertools.count())
|
||||
|
||||
return itertools.islice(six.moves.filterfalse(is_blacklisted,
|
||||
return itertools.islice(itertools.filterfalse(is_blacklisted,
|
||||
candidates),
|
||||
size)
|
||||
|
||||
|
@ -488,7 +488,7 @@ class ResourceGroup(stack_resource.StackResource):
|
|||
def _attribute_output_name(self, *attr_path):
|
||||
if attr_path[0] == self.REFS:
|
||||
return self.REFS
|
||||
return ', '.join(six.text_type(a) for a in attr_path)
|
||||
return ', '.join(str(a) for a in attr_path)
|
||||
|
||||
def get_attribute(self, key, *path):
|
||||
if key == self.REMOVED_RSRC_LIST:
|
||||
|
@ -546,7 +546,7 @@ class ResourceGroup(stack_resource.StackResource):
|
|||
|
||||
def _nested_output_defns(self, resource_names, get_attr_fn, get_res_fn):
|
||||
for attr in self.referenced_attrs():
|
||||
if isinstance(attr, six.string_types):
|
||||
if isinstance(attr, str):
|
||||
key, path = attr, []
|
||||
else:
|
||||
key, path = attr[0], list(attr[1:])
|
||||
|
@ -611,7 +611,7 @@ class ResourceGroup(stack_resource.StackResource):
|
|||
if isinstance(snippet, collections.Mapping):
|
||||
return dict((k, ignore_param_resolve(v))
|
||||
for k, v in snippet.items())
|
||||
elif (not isinstance(snippet, six.string_types) and
|
||||
elif (not isinstance(snippet, str) and
|
||||
isinstance(snippet, collections.Iterable)):
|
||||
return [ignore_param_resolve(v) for v in snippet]
|
||||
|
||||
|
@ -639,7 +639,7 @@ class ResourceGroup(stack_resource.StackResource):
|
|||
def recurse(x):
|
||||
return self._handle_repl_val(res_name, x)
|
||||
|
||||
if isinstance(val, six.string_types):
|
||||
if isinstance(val, str):
|
||||
return val.replace(repl_var, res_name)
|
||||
elif isinstance(val, collections.Mapping):
|
||||
return {k: recurse(v) for k, v in val.items()}
|
||||
|
@ -706,7 +706,7 @@ class ResourceGroup(stack_resource.StackResource):
|
|||
|
||||
old_resources = sorted(valid_resources, key=replace_priority)
|
||||
existing_names = set(n for n, d in valid_resources)
|
||||
new_names = six.moves.filterfalse(lambda n: n in existing_names,
|
||||
new_names = itertools.filterfalse(lambda n: n in existing_names,
|
||||
names)
|
||||
res_def = self.get_resource_def(include_all)
|
||||
definitions = scl_template.member_definitions(
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
# under the License.
|
||||
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
|
@ -186,9 +185,9 @@ class AutoScalingPolicy(signal_responder.SignalResponder):
|
|||
if self.resource_id is None:
|
||||
return
|
||||
if name == self.ALARM_URL:
|
||||
return six.text_type(self._get_ec2_signed_url())
|
||||
return str(self._get_ec2_signed_url())
|
||||
elif name == self.SIGNAL_URL:
|
||||
return six.text_type(self._get_heat_signal_url())
|
||||
return str(self._get_heat_signal_url())
|
||||
|
||||
|
||||
def resource_mapping():
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
# under the License.
|
||||
|
||||
import copy
|
||||
import six
|
||||
from six import itertools
|
||||
import itertools
|
||||
import uuid
|
||||
|
||||
from oslo_config import cfg
|
||||
|
@ -745,7 +744,7 @@ class SoftwareDeploymentGroup(resource_group.ResourceGroup):
|
|||
|
||||
def _nested_output_defns(self, resource_names, get_attr_fn, get_res_fn):
|
||||
for attr in self.referenced_attrs():
|
||||
key = attr if isinstance(attr, six.string_types) else attr[0]
|
||||
key = attr if isinstance(attr, str) else attr[0]
|
||||
n_attr = self._member_attribute_name(key)
|
||||
output_name = self._attribute_output_name(self.ATTR_ATTRIBUTES,
|
||||
n_attr)
|
||||
|
|
|
@ -15,8 +15,6 @@ import collections
|
|||
import copy
|
||||
import functools
|
||||
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
from heat.engine import constraints
|
||||
|
@ -150,8 +148,8 @@ class StructuredDeployment(sd.SoftwareDeployment):
|
|||
def get_input_key_arg(snippet, input_key):
|
||||
if len(snippet) != 1:
|
||||
return None
|
||||
fn_name, fn_arg = next(six.iteritems(snippet))
|
||||
if (fn_name == input_key and isinstance(fn_arg, six.string_types)):
|
||||
fn_name, fn_arg = next(iter(snippet.items()))
|
||||
if (fn_name == input_key and isinstance(fn_arg, str)):
|
||||
return fn_arg
|
||||
|
||||
@staticmethod
|
||||
|
@ -175,8 +173,8 @@ class StructuredDeployment(sd.SoftwareDeployment):
|
|||
check_input_val
|
||||
)
|
||||
|
||||
return dict((k, parse(v)) for k, v in six.iteritems(snippet))
|
||||
elif (not isinstance(snippet, six.string_types) and
|
||||
return dict((k, parse(v)) for k, v in snippet.items())
|
||||
elif (not isinstance(snippet, str) and
|
||||
isinstance(snippet, collections.Iterable)):
|
||||
return [parse(v) for v in snippet]
|
||||
else:
|
||||
|
|
|
@ -14,8 +14,7 @@
|
|||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
from six.moves.urllib import parse
|
||||
import urllib.parse as parse
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
|
@ -344,7 +343,7 @@ class SwiftSignal(resource.Resource):
|
|||
|
||||
def _resolve_attribute(self, key):
|
||||
if key == self.DATA:
|
||||
return six.text_type(jsonutils.dumps(self.get_data()))
|
||||
return str(jsonutils.dumps(self.get_data()))
|
||||
|
||||
|
||||
def resource_mapping():
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
import datetime
|
||||
import eventlet
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
|
||||
from heat.common.i18n import _
|
||||
from heat.engine import attributes
|
||||
|
@ -218,12 +217,12 @@ class TestResource(resource.Resource):
|
|||
obj.get(entity_id)
|
||||
except Exception as exc:
|
||||
LOG.debug('%s.%s(%s) %s' % (client_name, self.entity,
|
||||
entity_id, six.text_type(exc)))
|
||||
entity_id, str(exc)))
|
||||
else:
|
||||
# just sleep some more
|
||||
eventlet.sleep(1)
|
||||
|
||||
if isinstance(started_at, six.string_types):
|
||||
if isinstance(started_at, str):
|
||||
started_at = timeutils.parse_isotime(started_at)
|
||||
|
||||
started_at = timeutils.normalize_time(started_at)
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
|
||||
from heat.common.i18n import _
|
||||
from heat.engine import attributes
|
||||
|
@ -158,7 +157,7 @@ class HeatWaitCondition(resource.Resource):
|
|||
'key': key,
|
||||
'res': res})
|
||||
|
||||
return six.text_type(jsonutils.dumps(res))
|
||||
return str(jsonutils.dumps(res))
|
||||
|
||||
|
||||
def resource_mapping():
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import encodeutils
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
|
@ -197,7 +196,7 @@ class ManilaShare(resource.Resource):
|
|||
if self.resource_id is None:
|
||||
return
|
||||
share = self._request_share()
|
||||
return six.text_type(getattr(share, name))
|
||||
return str(getattr(share, name))
|
||||
|
||||
def handle_create(self):
|
||||
# Request IDs of entities from manila
|
||||
|
@ -345,7 +344,7 @@ class ManilaShare(resource.Resource):
|
|||
result[self.ACCESS_RULES] = []
|
||||
for rule in rules:
|
||||
result[self.ACCESS_RULES].append(
|
||||
{(k, v) for (k, v) in six.iteritems(rule)
|
||||
{(k, v) for (k, v) in rule.items()
|
||||
if k in self._ACCESS_RULE_PROPERTIES})
|
||||
return result
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
# under the License.
|
||||
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
|
@ -125,7 +124,7 @@ class NovaFloatingIp(resource.Resource):
|
|||
self.POOL_ATTR: floating_ip['floatingip']['floating_network_id'],
|
||||
self.IP: floating_ip['floatingip']['floating_ip_address']
|
||||
}
|
||||
return six.text_type(attributes[key])
|
||||
return str(attributes[key])
|
||||
|
||||
|
||||
class NovaFloatingIpAssociation(resource.Resource):
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
|
@ -194,7 +193,7 @@ class KeyPair(resource.Resource):
|
|||
def _resolve_attribute(self, key):
|
||||
attr_fn = {self.PRIVATE_KEY_ATTR: self.private_key,
|
||||
self.PUBLIC_KEY_ATTR: self.public_key}
|
||||
return six.text_type(attr_fn[key])
|
||||
return str(attr_fn[key])
|
||||
|
||||
def get_reference_id(self):
|
||||
return self.resource_id
|
||||
|
|
|
@ -16,7 +16,6 @@ import copy
|
|||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
|
@ -936,8 +935,8 @@ class Server(server_base.BaseServer, sh.SchedulerHintsMixin,
|
|||
server, server_data = resource_data
|
||||
result = {
|
||||
# there's a risk that flavor id will be int type, so cast to str
|
||||
self.FLAVOR: six.text_type(server_data.get(self.FLAVOR)['id']),
|
||||
self.IMAGE: six.text_type(server_data.get(self.IMAGE)['id']),
|
||||
self.FLAVOR: str(server_data.get(self.FLAVOR)['id']),
|
||||
self.IMAGE: str(server_data.get(self.IMAGE)['id']),
|
||||
self.NAME: server_data.get(self.NAME),
|
||||
self.METADATA: server_data.get(self.METADATA),
|
||||
self.NETWORKS: self._get_live_networks(server, resource_properties)
|
||||
|
@ -977,7 +976,7 @@ class Server(server_base.BaseServer, sh.SchedulerHintsMixin,
|
|||
reality_net_ids.get(net_id).pop(idx)
|
||||
break
|
||||
|
||||
for key, value in six.iteritems(reality_nets):
|
||||
for key, value in reality_nets.items():
|
||||
for address in reality_nets[key]:
|
||||
new_net = {self.NETWORK_ID: key,
|
||||
self.NETWORK_FIXED_IP: address['addr']}
|
||||
|
@ -1224,7 +1223,7 @@ class Server(server_base.BaseServer, sh.SchedulerHintsMixin,
|
|||
return
|
||||
if not nets:
|
||||
return
|
||||
for res in six.itervalues(self.stack):
|
||||
for res in self.stack.values():
|
||||
if res.has_interface('OS::Neutron::Subnet'):
|
||||
try:
|
||||
subnet_net = res.properties.get(subnet.Subnet.NETWORK)
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
from heat.engine import attributes
|
||||
|
@ -298,7 +296,7 @@ class SaharaJob(signal_responder.SignalResponder, resource.Resource):
|
|||
|
||||
def _resolve_attribute(self, name):
|
||||
if name == self.DEFAULT_EXECUTION_URL:
|
||||
return six.text_type(self._get_ec2_signed_url())
|
||||
return str(self._get_ec2_signed_url())
|
||||
elif name == self.EXECUTIONS:
|
||||
try:
|
||||
job_execs = self.client().job_executions.find(
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
# limitations under the License.
|
||||
|
||||
import re
|
||||
import six
|
||||
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import encodeutils
|
||||
|
@ -284,7 +283,7 @@ class SaharaNodeGroupTemplate(resource.Resource):
|
|||
return props
|
||||
|
||||
def handle_create(self):
|
||||
props = dict((k, v) for k, v in six.iteritems(self.properties))
|
||||
props = dict((k, v) for k, v in self.properties.items())
|
||||
args = self._prepare_properties(props)
|
||||
node_group_template = self.client().node_group_templates.create(**args)
|
||||
LOG.info("Node Group Template '%s' has been created",
|
||||
|
@ -335,7 +334,7 @@ class SaharaNodeGroupTemplate(resource.Resource):
|
|||
self.properties[self.PLUGIN_NAME],
|
||||
self.properties[self.HADOOP_VERSION])
|
||||
allowed_processes = [item for sublist in
|
||||
list(six.itervalues(plugin.node_processes))
|
||||
list(plugin.node_processes.values())
|
||||
for item in sublist]
|
||||
unsupported_processes = []
|
||||
for process in self.properties[self.NODE_PROCESSES]:
|
||||
|
@ -564,7 +563,7 @@ class SaharaClusterTemplate(resource.Resource):
|
|||
return props
|
||||
|
||||
def handle_create(self):
|
||||
props = dict((k, v) for k, v in six.iteritems(self.properties))
|
||||
props = dict((k, v) for k, v in self.properties.items())
|
||||
args = self._prepare_properties(props)
|
||||
cluster_template = self.client().cluster_templates.create(**args)
|
||||
LOG.info("Cluster Template '%s' has been created",
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
from heat.engine import attributes
|
||||
|
@ -322,7 +320,7 @@ class Cluster(res_base.BaseSenlinResource):
|
|||
actions.append(action)
|
||||
# Update cluster
|
||||
if any(p in prop_diff for p in UPDATE_PROPS):
|
||||
params = dict((k, v) for k, v in six.iteritems(prop_diff)
|
||||
params = dict((k, v) for k, v in prop_diff.items()
|
||||
if k in UPDATE_PROPS)
|
||||
params['cluster'] = cluster_obj
|
||||
if self.PROFILE in params:
|
||||
|
@ -336,7 +334,7 @@ class Cluster(res_base.BaseSenlinResource):
|
|||
actions.append(action)
|
||||
# Resize Cluster
|
||||
if any(p in prop_diff for p in RESIZE_PROPS):
|
||||
params = dict((k, v) for k, v in six.iteritems(prop_diff)
|
||||
params = dict((k, v) for k, v in prop_diff.items()
|
||||
if k in RESIZE_PROPS)
|
||||
if self.DESIRED_CAPACITY in params:
|
||||
params['adjustment_type'] = 'EXACT_CAPACITY'
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
# under the License.
|
||||
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
|
@ -501,9 +500,9 @@ class Instance(resource.Resource):
|
|||
# we retrieve it and try to update it so check again
|
||||
if self.client_plugin().is_over_limit(exc):
|
||||
LOG.debug("API rate limit: %(ex)s. Retrying.",
|
||||
{'ex': six.text_type(exc)})
|
||||
{'ex': str(exc)})
|
||||
return False
|
||||
if "No change was requested" in six.text_type(exc):
|
||||
if "No change was requested" in str(exc):
|
||||
LOG.warning("Unexpected instance state change "
|
||||
"during update. Retrying.")
|
||||
return False
|
||||
|
@ -518,8 +517,8 @@ class Instance(resource.Resource):
|
|||
|
||||
def _update_flavor(self, instance, new_flavor):
|
||||
if new_flavor:
|
||||
current_flav = six.text_type(instance.flavor['id'])
|
||||
new_flav = six.text_type(new_flavor)
|
||||
current_flav = str(instance.flavor['id'])
|
||||
new_flav = str(new_flavor)
|
||||
if new_flav != current_flav:
|
||||
dmsg = "Resizing instance flavor from %(old)s to %(new)s"
|
||||
LOG.debug(dmsg % {"old": current_flav, "new": new_flav})
|
||||
|
|
|
@ -20,7 +20,8 @@ from heat.engine import properties
|
|||
from heat.engine import resource
|
||||
from heat.engine import support
|
||||
|
||||
from six.moves.urllib import parse as urlparse
|
||||
from urllib.parse import quote
|
||||
from urllib.parse import urlencode
|
||||
|
||||
|
||||
class ZaqarQueue(resource.Resource):
|
||||
|
@ -120,7 +121,7 @@ class ZaqarQueue(resource.Resource):
|
|||
queue_name = self.physical_resource_name()
|
||||
return '%s/v%s/queues/%s' % (client.api_url.rstrip('/'),
|
||||
client.api_version,
|
||||
urlparse.quote(queue_name))
|
||||
quote(queue_name))
|
||||
|
||||
def _resolve_attribute(self, name):
|
||||
if name == self.QUEUE_ID:
|
||||
|
@ -243,7 +244,7 @@ class ZaqarSignedQueueURL(resource.Resource):
|
|||
'project_id': data[self.PROJECT],
|
||||
'queue_name': self.properties[self.QUEUE],
|
||||
}
|
||||
return urlparse.urlencode(query)
|
||||
return urlencode(query)
|
||||
|
||||
def handle_delete(self):
|
||||
# We can't delete a signed URL
|
||||
|
|
|
@ -10,12 +10,15 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from urllib.parse import unquote
|
||||
from urllib.parse import urlencode
|
||||
from urllib.parse import urljoin
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from keystoneclient.contrib.ec2 import utils as ec2_utils
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
from six.moves.urllib import parse as urlparse
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
|
@ -152,7 +155,7 @@ class SignalResponder(stack_user.StackUser):
|
|||
endpoint = heat_client_plugin.get_heat_cfn_url()
|
||||
signal_url = ''.join([endpoint, signal_type])
|
||||
|
||||
host_url = urlparse.urlparse(signal_url)
|
||||
host_url = urlparse(signal_url)
|
||||
|
||||
path = self.identifier().arn_url_path()
|
||||
|
||||
|
@ -160,7 +163,7 @@ class SignalResponder(stack_user.StackUser):
|
|||
# processing 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 = urlparse.unquote(host_url.path + path)
|
||||
unquoted_path = unquote(host_url.path + path)
|
||||
request = {'host': host_url.netloc.lower(),
|
||||
'verb': SIGNAL_VERB[signal_type],
|
||||
'path': unquoted_path,
|
||||
|
@ -174,7 +177,7 @@ class SignalResponder(stack_user.StackUser):
|
|||
signer = ec2_utils.Ec2Signer(secret_key)
|
||||
request['params']['Signature'] = signer.generate(request)
|
||||
|
||||
qs = urlparse.urlencode(request['params'])
|
||||
qs = urlencode(request['params'])
|
||||
url = "%s%s?%s" % (signal_url.lower(),
|
||||
path, qs)
|
||||
|
||||
|
@ -206,7 +209,7 @@ class SignalResponder(stack_user.StackUser):
|
|||
if project_id is not None:
|
||||
path = project_id + path[path.find('/'):]
|
||||
|
||||
url = urlparse.urljoin(url, '%s/signal' % path)
|
||||
url = urljoin(url, '%s/signal' % path)
|
||||
|
||||
self.data_set('heat_signal_url', url)
|
||||
return url
|
||||
|
|
|
@ -18,7 +18,6 @@ from oslo_config import cfg
|
|||
from oslo_log import log as logging
|
||||
from oslo_utils import excutils
|
||||
from oslo_utils import reflection
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
|
@ -397,7 +396,7 @@ class StackResource(resource.Resource):
|
|||
if not class_name.endswith('_Remote'):
|
||||
return False
|
||||
|
||||
full_message = six.text_type(ex)
|
||||
full_message = str(ex)
|
||||
if full_message.find('\n') > -1:
|
||||
message, msg_trace = full_message.split('\n', 1)
|
||||
else:
|
||||
|
|
|
@ -11,14 +11,14 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from itertools import filterfalse
|
||||
import uuid
|
||||
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import timeutils
|
||||
import requests
|
||||
import six
|
||||
from six.moves.urllib import parse as urlparse
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from heat.common import crypt
|
||||
from heat.common import exception
|
||||
|
@ -88,8 +88,7 @@ class SoftwareConfigService(object):
|
|||
cnxt, server_id)
|
||||
|
||||
# filter out the sds with None config
|
||||
flt_sd = six.moves.filterfalse(lambda sd: sd.config is None,
|
||||
all_sd)
|
||||
flt_sd = filterfalse(lambda sd: sd.config is None, all_sd)
|
||||
# sort the configs by config name, to give the list of metadata a
|
||||
# deterministic and controllable order.
|
||||
flt_sd_s = sorted(flt_sd, key=lambda sd: sd.config.name)
|
||||
|
@ -153,7 +152,7 @@ class SoftwareConfigService(object):
|
|||
raise exception.ConcurrentTransaction(action=action)
|
||||
|
||||
def _refresh_swift_software_deployment(self, cnxt, sd, deploy_signal_id):
|
||||
container, object_name = urlparse.urlparse(
|
||||
container, object_name = urlparse(
|
||||
deploy_signal_id).path.split('/')[-2:]
|
||||
swift_plugin = cnxt.clients.client_plugin('swift')
|
||||
swift = swift_plugin.client()
|
||||
|
@ -281,7 +280,7 @@ class SoftwareConfigService(object):
|
|||
'stack_user_project_id': stack_user_project_id,
|
||||
'action': action,
|
||||
'status': status,
|
||||
'status_reason': six.text_type(status_reason)})
|
||||
'status_reason': str(status_reason)})
|
||||
self._push_metadata_software_deployments(
|
||||
cnxt, server_id, stack_user_project_id)
|
||||
return api.format_software_deployment(sd)
|
||||
|
@ -332,7 +331,7 @@ class SoftwareConfigService(object):
|
|||
if status == rpc_api.SOFTWARE_DEPLOYMENT_FAILED:
|
||||
# build a status reason out of all of the values of outputs
|
||||
# flagged as error_output
|
||||
status_reasons = [' : '.join((k, six.text_type(status_reasons[k])))
|
||||
status_reasons = [' : '.join((k, str(status_reasons[k])))
|
||||
for k in status_reasons]
|
||||
status_reason = ', '.join(status_reasons)
|
||||
else:
|
||||
|
@ -362,7 +361,7 @@ class SoftwareConfigService(object):
|
|||
if status:
|
||||
update_data['status'] = status
|
||||
if status_reason:
|
||||
update_data['status_reason'] = six.text_type(status_reason)
|
||||
update_data['status_reason'] = str(status_reason)
|
||||
if updated_at:
|
||||
update_data['updated_at'] = timeutils.normalize_time(
|
||||
timeutils.parse_isotime(updated_at))
|
||||
|
|
3
tox.ini
3
tox.ini
|
@ -29,13 +29,14 @@ commands =
|
|||
# B110: Try, Except, Pass detected.
|
||||
# B310: Audit url open for permitted schemes
|
||||
# B311: Standard pseudo-random generators are not suitable for security/cryptographic purposes
|
||||
# B322: The input method is safe in Python 3.
|
||||
# B404: Import of subprocess module
|
||||
# B410: Import of lxml module
|
||||
# B504: Test for SSL use with no version specified
|
||||
# B506: Test for use of yaml load
|
||||
# B603: Test for use of subprocess with shell equals true
|
||||
# B607: Test for starting a process with a partial path
|
||||
bandit -r heat -x tests --skip B101,B104,B107,B110,B310,B311,B404,B410,B504,B506,B603,B607
|
||||
bandit -r heat -x tests --skip B101,B104,B107,B110,B310,B311,B322,B404,B410,B504,B506,B603,B607
|
||||
doc8 {posargs}
|
||||
|
||||
[testenv:venv]
|
||||
|
|
Loading…
Reference in New Issue