WIP - Remove six and python2.7 retro compatibility

Change-Id: I923476edaa09ae8ccaa9cd2392ff5e3cf5a0cc87
This commit is contained in:
Hervé Beraud 2019-11-08 11:51:24 +01:00
parent e0dbb3f7fa
commit 0ffcf00b5d
25 changed files with 82 additions and 110 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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()

View File

@ -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

View File

@ -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))

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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:])

View File

@ -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]

View File

@ -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')

View File

@ -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():

View File

@ -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)

View File

@ -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():

View File

@ -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)

View File

@ -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

View File

@ -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):

View File

@ -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

View File

@ -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)

View File

@ -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})

View File

@ -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 urlencode
from urllib.parse import urljoin
from urllib.parse import urlparse
from urllib.parse import unquote
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

View File

@ -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:

View File

@ -12,13 +12,13 @@
# under the License.
import uuid
from itertools import filterfalse
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,7 +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,
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.
@ -153,7 +153,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 +281,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 +332,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 +362,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))