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 13 of a serie of 28 patches Change-Id: I09aa3b7ddd93087c3f92c76c893c609cb9473842
This commit is contained in:
parent
f5d6c01cad
commit
5fa48d67a2
@ -12,11 +12,10 @@
|
|||||||
|
|
||||||
import collections
|
import collections
|
||||||
import copy
|
import copy
|
||||||
|
import functools
|
||||||
import itertools
|
import itertools
|
||||||
import operator
|
import operator
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.engine import function
|
from heat.engine import function
|
||||||
from heat.engine import properties
|
from heat.engine import properties
|
||||||
@ -111,7 +110,7 @@ class ResourceDefinition(object):
|
|||||||
self._dep_names = None
|
self._dep_names = None
|
||||||
self._all_dep_attrs = None
|
self._all_dep_attrs = None
|
||||||
|
|
||||||
assert isinstance(self.description, six.string_types)
|
assert isinstance(self.description, str)
|
||||||
|
|
||||||
if properties is not None:
|
if properties is not None:
|
||||||
assert isinstance(properties, (collections.Mapping,
|
assert isinstance(properties, (collections.Mapping,
|
||||||
@ -126,7 +125,7 @@ class ResourceDefinition(object):
|
|||||||
if depends is not None:
|
if depends is not None:
|
||||||
assert isinstance(depends, (collections.Sequence,
|
assert isinstance(depends, (collections.Sequence,
|
||||||
function.Function))
|
function.Function))
|
||||||
assert not isinstance(depends, six.string_types)
|
assert not isinstance(depends, str)
|
||||||
self._hash ^= _hash_data(depends)
|
self._hash ^= _hash_data(depends)
|
||||||
|
|
||||||
if deletion_policy is not None:
|
if deletion_policy is not None:
|
||||||
@ -139,13 +138,13 @@ class ResourceDefinition(object):
|
|||||||
self._hash ^= _hash_data(update_policy)
|
self._hash ^= _hash_data(update_policy)
|
||||||
|
|
||||||
if external_id is not None:
|
if external_id is not None:
|
||||||
assert isinstance(external_id, (six.string_types,
|
assert isinstance(external_id, (str,
|
||||||
function.Function))
|
function.Function))
|
||||||
self._hash ^= _hash_data(external_id)
|
self._hash ^= _hash_data(external_id)
|
||||||
self._deletion_policy = self.RETAIN
|
self._deletion_policy = self.RETAIN
|
||||||
|
|
||||||
if condition is not None:
|
if condition is not None:
|
||||||
assert isinstance(condition, (six.string_types, bool,
|
assert isinstance(condition, (str, bool,
|
||||||
function.Function))
|
function.Function))
|
||||||
self._hash ^= _hash_data(condition)
|
self._hash ^= _hash_data(condition)
|
||||||
|
|
||||||
@ -255,7 +254,7 @@ class ResourceDefinition(object):
|
|||||||
path(PROPERTIES))
|
path(PROPERTIES))
|
||||||
metadata_deps = function.dependencies(self._metadata,
|
metadata_deps = function.dependencies(self._metadata,
|
||||||
path(METADATA))
|
path(METADATA))
|
||||||
implicit_depends = six.moves.map(lambda rp: rp.name,
|
implicit_depends = map(lambda rp: rp.name,
|
||||||
itertools.chain(prop_deps,
|
itertools.chain(prop_deps,
|
||||||
metadata_deps))
|
metadata_deps))
|
||||||
|
|
||||||
@ -287,9 +286,7 @@ class ResourceDefinition(object):
|
|||||||
if getattr(res, 'strict_dependency', True):
|
if getattr(res, 'strict_dependency', True):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
return six.moves.filter(None,
|
return filter(None, map(get_resource, self.required_resource_names()))
|
||||||
six.moves.map(get_resource,
|
|
||||||
self.required_resource_names()))
|
|
||||||
|
|
||||||
def set_translation_rules(self, rules=None, client_resolve=True):
|
def set_translation_rules(self, rules=None, client_resolve=True):
|
||||||
"""Helper method to update properties with translation rules."""
|
"""Helper method to update properties with translation rules."""
|
||||||
@ -434,12 +431,12 @@ def _hash_data(data):
|
|||||||
if isinstance(data, function.Function):
|
if isinstance(data, function.Function):
|
||||||
data = copy.deepcopy(data)
|
data = copy.deepcopy(data)
|
||||||
|
|
||||||
if not isinstance(data, six.string_types):
|
if not isinstance(data, str):
|
||||||
if isinstance(data, collections.Sequence):
|
if isinstance(data, collections.Sequence):
|
||||||
return hash(tuple(_hash_data(d) for d in data))
|
return hash(tuple(_hash_data(d) for d in data))
|
||||||
|
|
||||||
if isinstance(data, collections.Mapping):
|
if isinstance(data, collections.Mapping):
|
||||||
item_hashes = (hash(k) ^ _hash_data(v) for k, v in data.items())
|
item_hashes = (hash(k) ^ _hash_data(v) for k, v in data.items())
|
||||||
return six.moves.reduce(operator.xor, item_hashes, 0)
|
return functools.reduce(operator.xor, item_hashes, 0)
|
||||||
|
|
||||||
return hash(data)
|
return hash(data)
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
# 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 functools
|
||||||
import sys
|
import sys
|
||||||
import types
|
import types
|
||||||
|
|
||||||
@ -18,7 +19,6 @@ import eventlet
|
|||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_utils import encodeutils
|
from oslo_utils import encodeutils
|
||||||
from oslo_utils import excutils
|
from oslo_utils import excutils
|
||||||
import six
|
|
||||||
|
|
||||||
from heat.common.i18n import _
|
from heat.common.i18n import _
|
||||||
from heat.common import timeutils
|
from heat.common import timeutils
|
||||||
@ -39,9 +39,9 @@ def task_description(task):
|
|||||||
if name is not None and isinstance(task, (types.MethodType,
|
if name is not None and isinstance(task, (types.MethodType,
|
||||||
types.FunctionType)):
|
types.FunctionType)):
|
||||||
if getattr(task, '__self__', None) is not None:
|
if getattr(task, '__self__', None) is not None:
|
||||||
return '%s from %s' % (six.text_type(name), task.__self__)
|
return '%s from %s' % (str(name), task.__self__)
|
||||||
else:
|
else:
|
||||||
return six.text_type(name)
|
return str(name)
|
||||||
return encodeutils.safe_decode(repr(task))
|
return encodeutils.safe_decode(repr(task))
|
||||||
|
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ class Timeout(BaseException):
|
|||||||
|
|
||||||
def __init__(self, task_runner, timeout):
|
def __init__(self, task_runner, timeout):
|
||||||
"""Initialise with the TaskRunner and a timeout period in seconds."""
|
"""Initialise with the TaskRunner and a timeout period in seconds."""
|
||||||
message = _('%s Timed out') % six.text_type(task_runner)
|
message = _('%s Timed out') % str(task_runner)
|
||||||
super(Timeout, self).__init__(message)
|
super(Timeout, self).__init__(message)
|
||||||
|
|
||||||
self._duration = timeutils.Duration(timeout)
|
self._duration = timeutils.Duration(timeout)
|
||||||
@ -90,7 +90,6 @@ class TimedCancel(Timeout):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
@six.python_2_unicode_compatible
|
|
||||||
class ExceptionGroup(Exception):
|
class ExceptionGroup(Exception):
|
||||||
"""Container for multiple exceptions.
|
"""Container for multiple exceptions.
|
||||||
|
|
||||||
@ -110,7 +109,6 @@ class ExceptionGroup(Exception):
|
|||||||
return str([str(ex) for ex in self.exceptions])
|
return str([str(ex) for ex in self.exceptions])
|
||||||
|
|
||||||
|
|
||||||
@six.python_2_unicode_compatible
|
|
||||||
class TaskRunner(object):
|
class TaskRunner(object):
|
||||||
"""Wrapper for a resumable task (co-routine)."""
|
"""Wrapper for a resumable task (co-routine)."""
|
||||||
|
|
||||||
@ -141,12 +139,12 @@ class TaskRunner(object):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
"""Return a human-readable string representation of the task."""
|
"""Return a human-readable string representation of the task."""
|
||||||
text = 'Task %s' % self.name
|
text = 'Task %s' % self.name
|
||||||
return six.text_type(text)
|
return str(text)
|
||||||
|
|
||||||
def _sleep(self, wait_time):
|
def _sleep(self, wait_time):
|
||||||
"""Sleep for the specified number of seconds."""
|
"""Sleep for the specified number of seconds."""
|
||||||
if ENABLE_SLEEP and wait_time is not None:
|
if ENABLE_SLEEP and wait_time is not None:
|
||||||
LOG.debug('%s sleeping', six.text_type(self))
|
LOG.debug('%s sleeping', str(self))
|
||||||
eventlet.sleep(wait_time)
|
eventlet.sleep(wait_time)
|
||||||
|
|
||||||
def __call__(self, wait_time=1, timeout=None, progress_callback=None):
|
def __call__(self, wait_time=1, timeout=None, progress_callback=None):
|
||||||
@ -173,7 +171,7 @@ class TaskRunner(object):
|
|||||||
assert self._runner is None, "Task already started"
|
assert self._runner is None, "Task already started"
|
||||||
assert not self._done, "Task already cancelled"
|
assert not self._done, "Task already cancelled"
|
||||||
|
|
||||||
LOG.debug('%s starting', six.text_type(self))
|
LOG.debug('%s starting', str(self))
|
||||||
|
|
||||||
if timeout is not None:
|
if timeout is not None:
|
||||||
self._timeout = Timeout(self, timeout)
|
self._timeout = Timeout(self, timeout)
|
||||||
@ -185,7 +183,7 @@ class TaskRunner(object):
|
|||||||
else:
|
else:
|
||||||
self._runner = False
|
self._runner = False
|
||||||
self._done = True
|
self._done = True
|
||||||
LOG.debug('%s done (not resumable)', six.text_type(self))
|
LOG.debug('%s done (not resumable)', str(self))
|
||||||
|
|
||||||
def step(self):
|
def step(self):
|
||||||
"""Run another step of the task.
|
"""Run another step of the task.
|
||||||
@ -205,15 +203,15 @@ class TaskRunner(object):
|
|||||||
|
|
||||||
self._timeout.trigger(self._runner)
|
self._timeout.trigger(self._runner)
|
||||||
else:
|
else:
|
||||||
LOG.debug('%s running', six.text_type(self))
|
LOG.debug('%s running', str(self))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
poll_period = next(self._runner)
|
poll_period = next(self._runner)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
self._done = True
|
self._done = True
|
||||||
LOG.debug('%s complete', six.text_type(self))
|
LOG.debug('%s complete', str(self))
|
||||||
else:
|
else:
|
||||||
if isinstance(poll_period, six.integer_types):
|
if isinstance(poll_period, int):
|
||||||
self._poll_period = max(poll_period, 1)
|
self._poll_period = max(poll_period, 1)
|
||||||
else:
|
else:
|
||||||
self._poll_period = 1
|
self._poll_period = 1
|
||||||
@ -269,7 +267,7 @@ class TaskRunner(object):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if not self.started() or grace_period is None:
|
if not self.started() or grace_period is None:
|
||||||
LOG.debug('%s cancelled', six.text_type(self))
|
LOG.debug('%s cancelled', str(self))
|
||||||
self._done = True
|
self._done = True
|
||||||
if self.started():
|
if self.started():
|
||||||
self._runner.close()
|
self._runner.close()
|
||||||
@ -311,7 +309,7 @@ def wrappertask(task): # noqa: C901
|
|||||||
self.cleanup()
|
self.cleanup()
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@six.wraps(task)
|
@functools.wraps(task)
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
parent = task(*args, **kwargs)
|
parent = task(*args, **kwargs)
|
||||||
|
|
||||||
@ -399,7 +397,7 @@ class DependencyTaskGroup(object):
|
|||||||
if name is None:
|
if name is None:
|
||||||
name = '(%s) %s' % (getattr(task, '__name__',
|
name = '(%s) %s' % (getattr(task, '__name__',
|
||||||
task_description(task)),
|
task_description(task)),
|
||||||
six.text_type(dependencies))
|
str(dependencies))
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
@ -413,7 +411,7 @@ class DependencyTaskGroup(object):
|
|||||||
thrown_exceptions = []
|
thrown_exceptions = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
while any(six.itervalues(self._runners)):
|
while any(self._runners.values()):
|
||||||
try:
|
try:
|
||||||
for k, r in self._ready():
|
for k, r in self._ready():
|
||||||
r.start()
|
r.start()
|
||||||
@ -423,36 +421,31 @@ class DependencyTaskGroup(object):
|
|||||||
if self._graph:
|
if self._graph:
|
||||||
try:
|
try:
|
||||||
yield
|
yield
|
||||||
except Exception:
|
except Exception as err:
|
||||||
thrown_exceptions.append(sys.exc_info())
|
thrown_exceptions.append(err)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
for k, r in self._running():
|
for k, r in self._running():
|
||||||
if r.step():
|
if r.step():
|
||||||
del self._graph[k]
|
del self._graph[k]
|
||||||
except Exception:
|
except Exception as err:
|
||||||
exc_info = None
|
|
||||||
try:
|
|
||||||
exc_info = sys.exc_info()
|
|
||||||
if self.aggregate_exceptions:
|
if self.aggregate_exceptions:
|
||||||
self._cancel_recursively(k, r)
|
self._cancel_recursively(k, r)
|
||||||
else:
|
else:
|
||||||
self.cancel_all(grace_period=self.error_wait_time)
|
self.cancel_all(grace_period=self.error_wait_time)
|
||||||
raised_exceptions.append(exc_info)
|
raised_exceptions.append(err)
|
||||||
finally:
|
|
||||||
del exc_info
|
|
||||||
except: # noqa
|
except: # noqa
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception():
|
||||||
self.cancel_all()
|
self.cancel_all()
|
||||||
|
|
||||||
if raised_exceptions:
|
if raised_exceptions:
|
||||||
if self.aggregate_exceptions:
|
if self.aggregate_exceptions:
|
||||||
raise ExceptionGroup(v for t, v, tb in raised_exceptions)
|
raise ExceptionGroup(err for err in raised_exceptions)
|
||||||
else:
|
else:
|
||||||
if thrown_exceptions:
|
if thrown_exceptions:
|
||||||
six.reraise(*thrown_exceptions[-1])
|
raise thrown_exceptions[-1]
|
||||||
else:
|
else:
|
||||||
six.reraise(*raised_exceptions[0])
|
raise raised_exceptions[0]
|
||||||
finally:
|
finally:
|
||||||
del raised_exceptions
|
del raised_exceptions
|
||||||
del thrown_exceptions
|
del thrown_exceptions
|
||||||
@ -464,7 +457,7 @@ class DependencyTaskGroup(object):
|
|||||||
def get_grace_period(key):
|
def get_grace_period(key):
|
||||||
return grace_period
|
return grace_period
|
||||||
|
|
||||||
for k, r in six.iteritems(self._runners):
|
for k, r in self._runners.items():
|
||||||
if not r.started() or r.done():
|
if not r.started() or r.done():
|
||||||
gp = None
|
gp = None
|
||||||
else:
|
else:
|
||||||
@ -472,13 +465,13 @@ class DependencyTaskGroup(object):
|
|||||||
try:
|
try:
|
||||||
r.cancel(grace_period=gp)
|
r.cancel(grace_period=gp)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
LOG.debug('Exception cancelling task: %s', six.text_type(ex))
|
LOG.debug('Exception cancelling task: %s', str(ex))
|
||||||
|
|
||||||
def _cancel_recursively(self, key, runner):
|
def _cancel_recursively(self, key, runner):
|
||||||
try:
|
try:
|
||||||
runner.cancel()
|
runner.cancel()
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
LOG.debug('Exception cancelling task: %s', six.text_type(ex))
|
LOG.debug('Exception cancelling task: %s', str(ex))
|
||||||
node = self._graph[key]
|
node = self._graph[key]
|
||||||
for dependent_node in node.required_by():
|
for dependent_node in node.required_by():
|
||||||
node_runner = self._runners[dependent_node]
|
node_runner = self._runners[dependent_node]
|
||||||
@ -508,4 +501,4 @@ class DependencyTaskGroup(object):
|
|||||||
def running(k_r):
|
def running(k_r):
|
||||||
return k_r[0] in self._graph and k_r[1].started()
|
return k_r[0] in self._graph and k_r[1].started()
|
||||||
|
|
||||||
return six.moves.filter(running, six.iteritems(self._runners))
|
return filter(running, self._runners.items())
|
||||||
|
@ -32,7 +32,6 @@ from oslo_service import threadgroup
|
|||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
from osprofiler import profiler
|
from osprofiler import profiler
|
||||||
import six
|
|
||||||
import webob
|
import webob
|
||||||
|
|
||||||
from heat.common import context
|
from heat.common import context
|
||||||
@ -251,7 +250,7 @@ class ThreadGroupManager(object):
|
|||||||
|
|
||||||
for th in threads:
|
for th in threads:
|
||||||
th.link(mark_done, th)
|
th.link(mark_done, th)
|
||||||
while not all(six.itervalues(links_done)):
|
while not all(links_done.values()):
|
||||||
eventlet.sleep()
|
eventlet.sleep()
|
||||||
|
|
||||||
def send(self, stack_id, message):
|
def send(self, stack_id, message):
|
||||||
@ -695,7 +694,7 @@ class EngineService(service.ServiceBase):
|
|||||||
except AssertionError:
|
except AssertionError:
|
||||||
raise
|
raise
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
raise exception.StackValidationFailed(message=six.text_type(ex))
|
raise exception.StackValidationFailed(message=str(ex))
|
||||||
|
|
||||||
max_resources = cfg.CONF.max_resources_per_stack
|
max_resources = cfg.CONF.max_resources_per_stack
|
||||||
if max_resources == -1:
|
if max_resources == -1:
|
||||||
@ -834,7 +833,7 @@ class EngineService(service.ServiceBase):
|
|||||||
stack.create_stack_user_project_id()
|
stack.create_stack_user_project_id()
|
||||||
except exception.AuthorizationFailure as ex:
|
except exception.AuthorizationFailure as ex:
|
||||||
stack.state_set(stack.action, stack.FAILED,
|
stack.state_set(stack.action, stack.FAILED,
|
||||||
six.text_type(ex))
|
str(ex))
|
||||||
|
|
||||||
def _stack_create(stack, msg_queue=None):
|
def _stack_create(stack, msg_queue=None):
|
||||||
# Create/Adopt a stack, and create the periodic task if successful
|
# Create/Adopt a stack, and create the periodic task if successful
|
||||||
@ -1288,7 +1287,7 @@ class EngineService(service.ServiceBase):
|
|||||||
try:
|
try:
|
||||||
self._validate_template(cnxt, tmpl)
|
self._validate_template(cnxt, tmpl)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
return {'Error': six.text_type(ex)}
|
return {'Error': str(ex)}
|
||||||
|
|
||||||
stack_name = 'dummy'
|
stack_name = 'dummy'
|
||||||
stack = parser.Stack(cnxt, stack_name, tmpl,
|
stack = parser.Stack(cnxt, stack_name, tmpl,
|
||||||
@ -1297,7 +1296,7 @@ class EngineService(service.ServiceBase):
|
|||||||
stack.validate(ignorable_errors=ignorable_errors,
|
stack.validate(ignorable_errors=ignorable_errors,
|
||||||
validate_res_tmpl_only=True)
|
validate_res_tmpl_only=True)
|
||||||
except exception.StackValidationFailed as ex:
|
except exception.StackValidationFailed as ex:
|
||||||
return {'Error': six.text_type(ex)}
|
return {'Error': str(ex)}
|
||||||
|
|
||||||
def filter_parameter(p):
|
def filter_parameter(p):
|
||||||
return p.name not in stack.parameters.PSEUDO_PARAMETERS
|
return p.name not in stack.parameters.PSEUDO_PARAMETERS
|
||||||
@ -1642,7 +1641,7 @@ class EngineService(service.ServiceBase):
|
|||||||
supported_funcs.update(tmpl_class.plugin.condition_functions)
|
supported_funcs.update(tmpl_class.plugin.condition_functions)
|
||||||
|
|
||||||
functions = []
|
functions = []
|
||||||
for func_name, func in six.iteritems(supported_funcs):
|
for func_name, func in supported_funcs.items():
|
||||||
if func is not hot_functions.Removed:
|
if func is not hot_functions.Removed:
|
||||||
desc = pydoc.splitdoc(pydoc.getdoc(func))[0]
|
desc = pydoc.splitdoc(pydoc.getdoc(func))[0]
|
||||||
functions.append(
|
functions.append(
|
||||||
@ -1679,7 +1678,7 @@ class EngineService(service.ServiceBase):
|
|||||||
raise exception.ResourceTypeUnavailable(
|
raise exception.ResourceTypeUnavailable(
|
||||||
service_name=resource_class.default_client_name,
|
service_name=resource_class.default_client_name,
|
||||||
resource_type=type_name,
|
resource_type=type_name,
|
||||||
reason=six.text_type(exc))
|
reason=str(exc))
|
||||||
else:
|
else:
|
||||||
if not svc_available:
|
if not svc_available:
|
||||||
raise exception.ResourceTypeUnavailable(
|
raise exception.ResourceTypeUnavailable(
|
||||||
@ -2021,7 +2020,7 @@ class EngineService(service.ServiceBase):
|
|||||||
stack = parser.Stack.load(cnxt, stack=s)
|
stack = parser.Stack.load(cnxt, stack=s)
|
||||||
|
|
||||||
return [api.format_stack_resource(resource)
|
return [api.format_stack_resource(resource)
|
||||||
for name, resource in six.iteritems(stack)
|
for name, resource in stack.items()
|
||||||
if resource_name is None or name == resource_name]
|
if resource_name is None or name == resource_name]
|
||||||
|
|
||||||
@context.request_context
|
@context.request_context
|
||||||
@ -2103,7 +2102,7 @@ class EngineService(service.ServiceBase):
|
|||||||
if stack.status == stack.IN_PROGRESS:
|
if stack.status == stack.IN_PROGRESS:
|
||||||
LOG.info('%(stack)s is in state %(action)s_IN_PROGRESS, '
|
LOG.info('%(stack)s is in state %(action)s_IN_PROGRESS, '
|
||||||
'snapshot is not permitted.', {
|
'snapshot is not permitted.', {
|
||||||
'stack': six.text_type(stack),
|
'stack': str(stack),
|
||||||
'action': stack.action})
|
'action': stack.action})
|
||||||
raise exception.ActionInProgress(stack_name=stack.name,
|
raise exception.ActionInProgress(stack_name=stack.name,
|
||||||
action=stack.action)
|
action=stack.action)
|
||||||
|
@ -11,14 +11,14 @@
|
|||||||
# 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 itertools
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import requests
|
import requests
|
||||||
import six
|
from urllib import parse
|
||||||
from six.moves.urllib import parse as urlparse
|
|
||||||
|
|
||||||
from heat.common import crypt
|
from heat.common import crypt
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
@ -88,8 +88,7 @@ class SoftwareConfigService(object):
|
|||||||
cnxt, server_id)
|
cnxt, server_id)
|
||||||
|
|
||||||
# filter out the sds with None config
|
# filter out the sds with None config
|
||||||
flt_sd = six.moves.filterfalse(lambda sd: sd.config is None,
|
flt_sd = itertools.filterfalse(lambda sd: sd.config is None, all_sd)
|
||||||
all_sd)
|
|
||||||
# sort the configs by config name, to give the list of metadata a
|
# sort the configs by config name, to give the list of metadata a
|
||||||
# deterministic and controllable order.
|
# deterministic and controllable order.
|
||||||
flt_sd_s = sorted(flt_sd, key=lambda sd: sd.config.name)
|
flt_sd_s = sorted(flt_sd, key=lambda sd: sd.config.name)
|
||||||
@ -153,7 +152,7 @@ class SoftwareConfigService(object):
|
|||||||
raise exception.ConcurrentTransaction(action=action)
|
raise exception.ConcurrentTransaction(action=action)
|
||||||
|
|
||||||
def _refresh_swift_software_deployment(self, cnxt, sd, deploy_signal_id):
|
def _refresh_swift_software_deployment(self, cnxt, sd, deploy_signal_id):
|
||||||
container, object_name = urlparse.urlparse(
|
container, object_name = parse.urlparse(
|
||||||
deploy_signal_id).path.split('/')[-2:]
|
deploy_signal_id).path.split('/')[-2:]
|
||||||
swift_plugin = cnxt.clients.client_plugin('swift')
|
swift_plugin = cnxt.clients.client_plugin('swift')
|
||||||
swift = swift_plugin.client()
|
swift = swift_plugin.client()
|
||||||
@ -281,7 +280,7 @@ class SoftwareConfigService(object):
|
|||||||
'stack_user_project_id': stack_user_project_id,
|
'stack_user_project_id': stack_user_project_id,
|
||||||
'action': action,
|
'action': action,
|
||||||
'status': status,
|
'status': status,
|
||||||
'status_reason': six.text_type(status_reason)})
|
'status_reason': str(status_reason)})
|
||||||
self._push_metadata_software_deployments(
|
self._push_metadata_software_deployments(
|
||||||
cnxt, server_id, stack_user_project_id)
|
cnxt, server_id, stack_user_project_id)
|
||||||
return api.format_software_deployment(sd)
|
return api.format_software_deployment(sd)
|
||||||
@ -332,7 +331,7 @@ class SoftwareConfigService(object):
|
|||||||
if status == rpc_api.SOFTWARE_DEPLOYMENT_FAILED:
|
if status == rpc_api.SOFTWARE_DEPLOYMENT_FAILED:
|
||||||
# build a status reason out of all of the values of outputs
|
# build a status reason out of all of the values of outputs
|
||||||
# flagged as error_output
|
# 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]
|
for k in status_reasons]
|
||||||
status_reason = ', '.join(status_reasons)
|
status_reason = ', '.join(status_reasons)
|
||||||
else:
|
else:
|
||||||
@ -362,7 +361,7 @@ class SoftwareConfigService(object):
|
|||||||
if status:
|
if status:
|
||||||
update_data['status'] = status
|
update_data['status'] = status
|
||||||
if status_reason:
|
if status_reason:
|
||||||
update_data['status_reason'] = six.text_type(status_reason)
|
update_data['status_reason'] = str(status_reason)
|
||||||
if updated_at:
|
if updated_at:
|
||||||
update_data['updated_at'] = timeutils.normalize_time(
|
update_data['updated_at'] = timeutils.normalize_time(
|
||||||
timeutils.parse_isotime(updated_at))
|
timeutils.parse_isotime(updated_at))
|
||||||
|
@ -17,7 +17,6 @@ APIs for dealing with input and output definitions for Software Configurations.
|
|||||||
|
|
||||||
import collections
|
import collections
|
||||||
import copy
|
import copy
|
||||||
import six
|
|
||||||
|
|
||||||
from heat.common.i18n import _
|
from heat.common.i18n import _
|
||||||
|
|
||||||
@ -104,7 +103,7 @@ class IOConfig(object):
|
|||||||
try:
|
try:
|
||||||
self._props.validate()
|
self._props.validate()
|
||||||
except exception.StackValidationFailed as exc:
|
except exception.StackValidationFailed as exc:
|
||||||
raise ValueError(six.text_type(exc))
|
raise ValueError(str(exc))
|
||||||
|
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the input or output."""
|
"""Return the name of the input or output."""
|
||||||
@ -181,7 +180,7 @@ def check_io_schema_list(io_configs):
|
|||||||
"""
|
"""
|
||||||
if (not isinstance(io_configs, collections.Sequence) or
|
if (not isinstance(io_configs, collections.Sequence) or
|
||||||
isinstance(io_configs, collections.Mapping) or
|
isinstance(io_configs, collections.Mapping) or
|
||||||
isinstance(io_configs, six.string_types)):
|
isinstance(io_configs, str)):
|
||||||
raise TypeError('Software Config I/O Schema must be in a list')
|
raise TypeError('Software Config I/O Schema must be in a list')
|
||||||
|
|
||||||
if not all(isinstance(conf, collections.Mapping) for conf in io_configs):
|
if not all(isinstance(conf, collections.Mapping) for conf in io_configs):
|
||||||
|
@ -25,7 +25,6 @@ from oslo_utils import excutils
|
|||||||
from oslo_utils import timeutils as oslo_timeutils
|
from oslo_utils import timeutils as oslo_timeutils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
from osprofiler import profiler
|
from osprofiler import profiler
|
||||||
import six
|
|
||||||
|
|
||||||
from heat.common import context as common_context
|
from heat.common import context as common_context
|
||||||
from heat.common import environment_format as env_fmt
|
from heat.common import environment_format as env_fmt
|
||||||
@ -75,20 +74,20 @@ class ForcedCancel(Exception):
|
|||||||
|
|
||||||
|
|
||||||
def reset_state_on_error(func):
|
def reset_state_on_error(func):
|
||||||
@six.wraps(func)
|
@functools.wraps(func)
|
||||||
def handle_exceptions(stack, *args, **kwargs):
|
def handle_exceptions(stack, *args, **kwargs):
|
||||||
errmsg = None
|
errmsg = None
|
||||||
try:
|
try:
|
||||||
return func(stack, *args, **kwargs)
|
return func(stack, *args, **kwargs)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception():
|
||||||
errmsg = six.text_type(exc)
|
errmsg = str(exc)
|
||||||
LOG.error('Unexpected exception in %(func)s: %(msg)s',
|
LOG.error('Unexpected exception in %(func)s: %(msg)s',
|
||||||
{'func': func.__name__, 'msg': errmsg})
|
{'func': func.__name__, 'msg': errmsg})
|
||||||
except BaseException as exc:
|
except BaseException as exc:
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception():
|
||||||
exc_type = type(exc).__name__
|
exc_type = type(exc).__name__
|
||||||
errmsg = '%s(%s)' % (exc_type, six.text_type(exc))
|
errmsg = '%s(%s)' % (exc_type, str(exc))
|
||||||
LOG.info('Stopped due to %(msg)s in %(func)s',
|
LOG.info('Stopped due to %(msg)s in %(func)s',
|
||||||
{'func': func.__name__, 'msg': errmsg})
|
{'func': func.__name__, 'msg': errmsg})
|
||||||
finally:
|
finally:
|
||||||
@ -101,7 +100,6 @@ def reset_state_on_error(func):
|
|||||||
return handle_exceptions
|
return handle_exceptions
|
||||||
|
|
||||||
|
|
||||||
@six.python_2_unicode_compatible
|
|
||||||
class Stack(collections.Mapping):
|
class Stack(collections.Mapping):
|
||||||
|
|
||||||
ACTIONS = (
|
ACTIONS = (
|
||||||
@ -337,7 +335,7 @@ class Stack(collections.Mapping):
|
|||||||
resources = self._db_resources_get()
|
resources = self._db_resources_get()
|
||||||
|
|
||||||
stk_def_cache = {}
|
stk_def_cache = {}
|
||||||
for rsc in six.itervalues(resources):
|
for rsc in resources.values():
|
||||||
loaded_res = self._resource_from_db_resource(rsc, stk_def_cache)
|
loaded_res = self._resource_from_db_resource(rsc, stk_def_cache)
|
||||||
if loaded_res is not None:
|
if loaded_res is not None:
|
||||||
yield loaded_res
|
yield loaded_res
|
||||||
@ -520,14 +518,14 @@ class Stack(collections.Mapping):
|
|||||||
"""
|
"""
|
||||||
if self._dependencies is None:
|
if self._dependencies is None:
|
||||||
deps = dependencies.Dependencies()
|
deps = dependencies.Dependencies()
|
||||||
for res in six.itervalues(self.resources):
|
for res in self.resources.values():
|
||||||
res.add_explicit_dependencies(deps)
|
res.add_explicit_dependencies(deps)
|
||||||
self._dependencies = deps
|
self._dependencies = deps
|
||||||
return self._dependencies
|
return self._dependencies
|
||||||
|
|
||||||
def _add_implicit_dependencies(self, deps, ignore_errors=True):
|
def _add_implicit_dependencies(self, deps, ignore_errors=True):
|
||||||
"""Augment the given dependencies with implicit ones from plugins."""
|
"""Augment the given dependencies with implicit ones from plugins."""
|
||||||
for res in six.itervalues(self.resources):
|
for res in self.resources.values():
|
||||||
try:
|
try:
|
||||||
res.add_dependencies(deps)
|
res.add_dependencies(deps)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
@ -540,8 +538,8 @@ class Stack(collections.Mapping):
|
|||||||
else:
|
else:
|
||||||
LOG.warning('Ignoring error adding implicit '
|
LOG.warning('Ignoring error adding implicit '
|
||||||
'dependencies for %(res)s: %(err)s',
|
'dependencies for %(res)s: %(err)s',
|
||||||
{'res': six.text_type(res),
|
{'res': str(res),
|
||||||
'err': six.text_type(exc)})
|
'err': str(exc)})
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def load(cls, context, stack_id=None, stack=None, show_deleted=True,
|
def load(cls, context, stack_id=None, stack=None, show_deleted=True,
|
||||||
@ -655,7 +653,7 @@ class Stack(collections.Mapping):
|
|||||||
stack.update({
|
stack.update({
|
||||||
'action': self.action,
|
'action': self.action,
|
||||||
'status': self.status,
|
'status': self.status,
|
||||||
'status_reason': six.text_type(self.status_reason)})
|
'status_reason': str(self.status_reason)})
|
||||||
|
|
||||||
if only_db:
|
if only_db:
|
||||||
stack['parent_resource_name'] = self.parent_resource_name
|
stack['parent_resource_name'] = self.parent_resource_name
|
||||||
@ -801,7 +799,7 @@ class Stack(collections.Mapping):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
"""Return a human-readable string representation of the stack."""
|
"""Return a human-readable string representation of the stack."""
|
||||||
text = 'Stack "%s" [%s]' % (self.name, self.id)
|
text = 'Stack "%s" [%s]' % (self.name, self.id)
|
||||||
return six.text_type(text)
|
return str(text)
|
||||||
|
|
||||||
def resource_by_refid(self, refid):
|
def resource_by_refid(self, refid):
|
||||||
"""Return the resource in this stack with the specified refid.
|
"""Return the resource in this stack with the specified refid.
|
||||||
@ -809,7 +807,7 @@ class Stack(collections.Mapping):
|
|||||||
:returns: resource in this stack with the specified refid, or None if
|
:returns: resource in this stack with the specified refid, or None if
|
||||||
not found.
|
not found.
|
||||||
"""
|
"""
|
||||||
for r in six.itervalues(self):
|
for r in self.values():
|
||||||
if r.state not in ((r.INIT, r.COMPLETE),
|
if r.state not in ((r.INIT, r.COMPLETE),
|
||||||
(r.CREATE, r.IN_PROGRESS),
|
(r.CREATE, r.IN_PROGRESS),
|
||||||
(r.CREATE, r.COMPLETE),
|
(r.CREATE, r.COMPLETE),
|
||||||
@ -906,7 +904,7 @@ class Stack(collections.Mapping):
|
|||||||
else:
|
else:
|
||||||
iter_rsc = self._explicit_dependencies()
|
iter_rsc = self._explicit_dependencies()
|
||||||
|
|
||||||
unique_defns = set(res.t for res in six.itervalues(resources))
|
unique_defns = set(res.t for res in resources.values())
|
||||||
unique_defn_names = set(defn.name for defn in unique_defns)
|
unique_defn_names = set(defn.name for defn in unique_defns)
|
||||||
|
|
||||||
for res in iter_rsc:
|
for res in iter_rsc:
|
||||||
@ -939,7 +937,7 @@ class Stack(collections.Mapping):
|
|||||||
raise exception.StackValidationFailed(message=result)
|
raise exception.StackValidationFailed(message=result)
|
||||||
eventlet.sleep(0)
|
eventlet.sleep(0)
|
||||||
|
|
||||||
for op_name, output in six.iteritems(self.outputs):
|
for op_name, output in self.outputs.items():
|
||||||
try:
|
try:
|
||||||
output.validate()
|
output.validate()
|
||||||
except exception.StackValidationFailed as ex:
|
except exception.StackValidationFailed as ex:
|
||||||
@ -958,7 +956,7 @@ class Stack(collections.Mapping):
|
|||||||
during its lifecycle using the configured deferred authentication
|
during its lifecycle using the configured deferred authentication
|
||||||
method.
|
method.
|
||||||
"""
|
"""
|
||||||
return any(res.requires_deferred_auth for res in six.itervalues(self))
|
return any(res.requires_deferred_auth for res in self.values())
|
||||||
|
|
||||||
def _add_event(self, action, status, reason):
|
def _add_event(self, action, status, reason):
|
||||||
"""Add a state change event to the database."""
|
"""Add a state change event to the database."""
|
||||||
@ -1045,7 +1043,7 @@ class Stack(collections.Mapping):
|
|||||||
if stack is not None:
|
if stack is not None:
|
||||||
values = {'action': self.action,
|
values = {'action': self.action,
|
||||||
'status': self.status,
|
'status': self.status,
|
||||||
'status_reason': six.text_type(self.status_reason)}
|
'status_reason': str(self.status_reason)}
|
||||||
self._send_notification_and_add_event()
|
self._send_notification_and_add_event()
|
||||||
if self.convergence:
|
if self.convergence:
|
||||||
# do things differently for convergence
|
# do things differently for convergence
|
||||||
@ -1075,7 +1073,7 @@ class Stack(collections.Mapping):
|
|||||||
if stack is not None:
|
if stack is not None:
|
||||||
values = {'action': self.action,
|
values = {'action': self.action,
|
||||||
'status': self.status,
|
'status': self.status,
|
||||||
'status_reason': six.text_type(self.status_reason)}
|
'status_reason': str(self.status_reason)}
|
||||||
self._send_notification_and_add_event()
|
self._send_notification_and_add_event()
|
||||||
stack.persist_state_and_release_lock(self.context, self.id,
|
stack.persist_state_and_release_lock(self.context, self.id,
|
||||||
engine_id, values)
|
engine_id, values)
|
||||||
@ -1095,7 +1093,7 @@ class Stack(collections.Mapping):
|
|||||||
def preview_resources(self):
|
def preview_resources(self):
|
||||||
"""Preview the stack with all of the resources."""
|
"""Preview the stack with all of the resources."""
|
||||||
return [resource.preview()
|
return [resource.preview()
|
||||||
for resource in six.itervalues(self.resources)]
|
for resource in self.resources.values()]
|
||||||
|
|
||||||
def get_nested_parameters(self, filter_func):
|
def get_nested_parameters(self, filter_func):
|
||||||
"""Return nested parameters schema, if any.
|
"""Return nested parameters schema, if any.
|
||||||
@ -1105,7 +1103,7 @@ class Stack(collections.Mapping):
|
|||||||
stack.
|
stack.
|
||||||
"""
|
"""
|
||||||
result = {}
|
result = {}
|
||||||
for name, rsrc in six.iteritems(self.resources):
|
for name, rsrc in self.resources.items():
|
||||||
nested = rsrc.get_nested_parameters_stack()
|
nested = rsrc.get_nested_parameters_stack()
|
||||||
if nested is None:
|
if nested is None:
|
||||||
continue
|
continue
|
||||||
@ -1182,7 +1180,7 @@ class Stack(collections.Mapping):
|
|||||||
None, action)
|
None, action)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.state_set(action, self.FAILED, e.args[0] if e.args else
|
self.state_set(action, self.FAILED, e.args[0] if e.args else
|
||||||
'Failed stack pre-ops: %s' % six.text_type(e))
|
'Failed stack pre-ops: %s' % str(e))
|
||||||
if callable(post_func):
|
if callable(post_func):
|
||||||
post_func()
|
post_func()
|
||||||
if notify is not None:
|
if notify is not None:
|
||||||
@ -1238,7 +1236,7 @@ class Stack(collections.Mapping):
|
|||||||
# ExceptionGroup, but the raw exception.
|
# ExceptionGroup, but the raw exception.
|
||||||
# see scheduler.py line 395-399
|
# see scheduler.py line 395-399
|
||||||
stack_status = self.FAILED
|
stack_status = self.FAILED
|
||||||
reason = 'Resource %s failed: %s' % (action, six.text_type(ex))
|
reason = 'Resource %s failed: %s' % (action, str(ex))
|
||||||
|
|
||||||
if pre_completion_func:
|
if pre_completion_func:
|
||||||
pre_completion_func(self, action, stack_status, reason)
|
pre_completion_func(self, action, stack_status, reason)
|
||||||
@ -1272,7 +1270,7 @@ class Stack(collections.Mapping):
|
|||||||
return hasattr(res, 'handle_%s' % res.CHECK.lower())
|
return hasattr(res, 'handle_%s' % res.CHECK.lower())
|
||||||
|
|
||||||
all_supported = all(is_supported(res)
|
all_supported = all(is_supported(res)
|
||||||
for res in six.itervalues(self.resources))
|
for res in self.resources.values())
|
||||||
|
|
||||||
if not all_supported:
|
if not all_supported:
|
||||||
msg = ". '%s' not fully supported (see resources)" % self.CHECK
|
msg = ". '%s' not fully supported (see resources)" % self.CHECK
|
||||||
@ -1316,7 +1314,7 @@ class Stack(collections.Mapping):
|
|||||||
if not self.disable_rollback and self.state == (self.ADOPT,
|
if not self.disable_rollback and self.state == (self.ADOPT,
|
||||||
self.FAILED):
|
self.FAILED):
|
||||||
# enter the same flow as abandon and just delete the stack
|
# enter the same flow as abandon and just delete the stack
|
||||||
for res in six.itervalues(self.resources):
|
for res in self.resources.values():
|
||||||
res.abandon_in_progress = True
|
res.abandon_in_progress = True
|
||||||
self.delete(action=self.ROLLBACK, abandon=True)
|
self.delete(action=self.ROLLBACK, abandon=True)
|
||||||
|
|
||||||
@ -1426,7 +1424,7 @@ class Stack(collections.Mapping):
|
|||||||
try:
|
try:
|
||||||
self.delete_all_snapshots()
|
self.delete_all_snapshots()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
self.state_set(self.action, self.FAILED, six.text_type(exc))
|
self.state_set(self.action, self.FAILED, str(exc))
|
||||||
self.purge_db()
|
self.purge_db()
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -1576,11 +1574,11 @@ class Stack(collections.Mapping):
|
|||||||
return set(n.rsrc_id for n in dep_nodes if not n.is_update)
|
return set(n.rsrc_id for n in dep_nodes if not n.is_update)
|
||||||
|
|
||||||
def reset_stack_and_resources_in_progress(self, reason):
|
def reset_stack_and_resources_in_progress(self, reason):
|
||||||
for name, rsrc in six.iteritems(self.resources):
|
for name, rsrc in self.resources.items():
|
||||||
if rsrc.status == rsrc.IN_PROGRESS:
|
if rsrc.status == rsrc.IN_PROGRESS:
|
||||||
rsrc.state_set(rsrc.action,
|
rsrc.state_set(rsrc.action,
|
||||||
rsrc.FAILED,
|
rsrc.FAILED,
|
||||||
six.text_type(reason))
|
str(reason))
|
||||||
if self.action == self.UPDATE and not self.convergence:
|
if self.action == self.UPDATE and not self.convergence:
|
||||||
backup_stack = self._backup_stack(False)
|
backup_stack = self._backup_stack(False)
|
||||||
existing_params = environment.Environment({env_fmt.PARAMETERS:
|
existing_params = environment.Environment({env_fmt.PARAMETERS:
|
||||||
@ -1591,7 +1589,7 @@ class Stack(collections.Mapping):
|
|||||||
self._merge_user_param_template(existing_params, template,
|
self._merge_user_param_template(existing_params, template,
|
||||||
bkp_stack_template)
|
bkp_stack_template)
|
||||||
|
|
||||||
self.state_set(self.action, self.FAILED, six.text_type(reason))
|
self.state_set(self.action, self.FAILED, str(reason))
|
||||||
|
|
||||||
@scheduler.wrappertask
|
@scheduler.wrappertask
|
||||||
def update_task(self, newstack, action=UPDATE,
|
def update_task(self, newstack, action=UPDATE,
|
||||||
@ -1609,7 +1607,7 @@ class Stack(collections.Mapping):
|
|||||||
newstack, action)
|
newstack, action)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.state_set(action, self.FAILED, e.args[0] if e.args else
|
self.state_set(action, self.FAILED, e.args[0] if e.args else
|
||||||
'Failed stack pre-ops: %s' % six.text_type(e))
|
'Failed stack pre-ops: %s' % str(e))
|
||||||
if notify is not None:
|
if notify is not None:
|
||||||
notify.signal()
|
notify.signal()
|
||||||
return
|
return
|
||||||
@ -1756,7 +1754,7 @@ class Stack(collections.Mapping):
|
|||||||
|
|
||||||
:returns: a boolean for require rollback flag.
|
:returns: a boolean for require rollback flag.
|
||||||
"""
|
"""
|
||||||
self.status_reason = six.text_type(exc)
|
self.status_reason = str(exc)
|
||||||
self.status = self.FAILED
|
self.status = self.FAILED
|
||||||
if action != self.UPDATE:
|
if action != self.UPDATE:
|
||||||
return False
|
return False
|
||||||
@ -1800,7 +1798,7 @@ class Stack(collections.Mapping):
|
|||||||
|
|
||||||
def copy_data(source_res, destination_res):
|
def copy_data(source_res, destination_res):
|
||||||
if source_res.data():
|
if source_res.data():
|
||||||
for key, val in six.iteritems(source_res.data()):
|
for key, val in source_res.data().items():
|
||||||
destination_res.data_set(key, val)
|
destination_res.data_set(key, val)
|
||||||
|
|
||||||
for key, backup_res in stack.resources.items():
|
for key, backup_res in stack.resources.items():
|
||||||
@ -1905,7 +1903,7 @@ class Stack(collections.Mapping):
|
|||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
LOG.exception("Error deleting project")
|
LOG.exception("Error deleting project")
|
||||||
stack_status = self.FAILED
|
stack_status = self.FAILED
|
||||||
reason = "Error deleting project: %s" % six.text_type(ex)
|
reason = "Error deleting project: %s" % str(ex)
|
||||||
|
|
||||||
return stack_status, reason
|
return stack_status, reason
|
||||||
|
|
||||||
@ -1957,7 +1955,7 @@ class Stack(collections.Mapping):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.state_set(action, self.FAILED,
|
self.state_set(action, self.FAILED,
|
||||||
e.args[0] if e.args else
|
e.args[0] if e.args else
|
||||||
'Failed stack pre-ops: %s' % six.text_type(e))
|
'Failed stack pre-ops: %s' % str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
action_task = scheduler.DependencyTaskGroup(self.dependencies,
|
action_task = scheduler.DependencyTaskGroup(self.dependencies,
|
||||||
@ -1967,7 +1965,7 @@ class Stack(collections.Mapping):
|
|||||||
scheduler.TaskRunner(action_task)(timeout=self.timeout_secs())
|
scheduler.TaskRunner(action_task)(timeout=self.timeout_secs())
|
||||||
except exception.ResourceFailure as ex:
|
except exception.ResourceFailure as ex:
|
||||||
stack_status = self.FAILED
|
stack_status = self.FAILED
|
||||||
reason = 'Resource %s failed: %s' % (action, six.text_type(ex))
|
reason = 'Resource %s failed: %s' % (action, str(ex))
|
||||||
except scheduler.Timeout:
|
except scheduler.Timeout:
|
||||||
stack_status = self.FAILED
|
stack_status = self.FAILED
|
||||||
reason = '%s timed out' % action.title()
|
reason = '%s timed out' % action.title()
|
||||||
@ -2092,7 +2090,7 @@ class Stack(collections.Mapping):
|
|||||||
ss_defn = self.defn.clone_with_new_template(template,
|
ss_defn = self.defn.clone_with_new_template(template,
|
||||||
self.identifier())
|
self.identifier())
|
||||||
resources = self._resources_for_defn(ss_defn)
|
resources = self._resources_for_defn(ss_defn)
|
||||||
for name, rsrc in six.iteritems(resources):
|
for name, rsrc in resources.items():
|
||||||
data = snapshot.data['resources'].get(name)
|
data = snapshot.data['resources'].get(name)
|
||||||
if data:
|
if data:
|
||||||
scheduler.TaskRunner(rsrc.delete_snapshot, data)()
|
scheduler.TaskRunner(rsrc.delete_snapshot, data)()
|
||||||
@ -2159,7 +2157,7 @@ class Stack(collections.Mapping):
|
|||||||
'status': self.status,
|
'status': self.status,
|
||||||
'template': self.t.t,
|
'template': self.t.t,
|
||||||
'resources': dict((res.name, res.prepare_abandon())
|
'resources': dict((res.name, res.prepare_abandon())
|
||||||
for res in six.itervalues(self.resources)),
|
for res in self.resources.values()),
|
||||||
'project_id': self.tenant_id,
|
'project_id': self.tenant_id,
|
||||||
'stack_user_project_id': self.stack_user_project_id,
|
'stack_user_project_id': self.stack_user_project_id,
|
||||||
'tags': self.tags,
|
'tags': self.tags,
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
import six
|
|
||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.engine import attributes
|
from heat.engine import attributes
|
||||||
@ -232,7 +231,7 @@ class ResourceProxy(status.ResourceStatus):
|
|||||||
the "show" attribute.
|
the "show" attribute.
|
||||||
"""
|
"""
|
||||||
all_attrs = self._res_data().attributes()
|
all_attrs = self._res_data().attributes()
|
||||||
return dict((k, v) for k, v in six.iteritems(all_attrs)
|
return dict((k, v) for k, v in all_attrs.items()
|
||||||
if k != attributes.SHOW_ATTR)
|
if k != attributes.SHOW_ATTR)
|
||||||
|
|
||||||
|
|
||||||
@ -253,8 +252,8 @@ def update_resource_data(stack_definition, resource_name, resource_data):
|
|||||||
res_defns = stack_definition._resource_defns or {}
|
res_defns = stack_definition._resource_defns or {}
|
||||||
op_defns = stack_definition._output_defns or {}
|
op_defns = stack_definition._output_defns or {}
|
||||||
|
|
||||||
all_defns = itertools.chain(six.itervalues(res_defns),
|
all_defns = itertools.chain(res_defns.values(),
|
||||||
six.itervalues(op_defns))
|
op_defns.values())
|
||||||
for defn in all_defns:
|
for defn in all_defns:
|
||||||
if resource_name in defn.required_resource_names():
|
if resource_name in defn.required_resource_names():
|
||||||
defn._all_dep_attrs = None
|
defn._all_dep_attrs = None
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import ast
|
import ast
|
||||||
import six
|
|
||||||
import tenacity
|
import tenacity
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
@ -84,7 +83,7 @@ def _str_unpack_tuple(s):
|
|||||||
def _deserialize(d):
|
def _deserialize(d):
|
||||||
d2 = {}
|
d2 = {}
|
||||||
for k, v in d.items():
|
for k, v in d.items():
|
||||||
if isinstance(k, six.string_types) and k.startswith(u'tuple:('):
|
if isinstance(k, str) and k.startswith(u'tuple:('):
|
||||||
k = _str_unpack_tuple(k)
|
k = _str_unpack_tuple(k)
|
||||||
if isinstance(v, dict):
|
if isinstance(v, dict):
|
||||||
v = _deserialize(v)
|
v = _deserialize(v)
|
||||||
|
@ -17,7 +17,6 @@ import copy
|
|||||||
import functools
|
import functools
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
import six
|
|
||||||
from stevedore import extension
|
from stevedore import extension
|
||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
@ -37,8 +36,8 @@ _template_classes = None
|
|||||||
|
|
||||||
def get_version(template_data, available_versions):
|
def get_version(template_data, available_versions):
|
||||||
version_keys = set(key for key, version in available_versions)
|
version_keys = set(key for key, version in available_versions)
|
||||||
candidate_keys = set(k for k, v in six.iteritems(template_data) if
|
candidate_keys = set(k for k, v in template_data.items() if
|
||||||
isinstance(v, six.string_types))
|
isinstance(v, str))
|
||||||
|
|
||||||
keys_present = version_keys & candidate_keys
|
keys_present = version_keys & candidate_keys
|
||||||
|
|
||||||
@ -61,7 +60,7 @@ def _get_template_extension_manager():
|
|||||||
|
|
||||||
|
|
||||||
def raise_extension_exception(extmanager, ep, err):
|
def raise_extension_exception(extmanager, ep, err):
|
||||||
raise TemplatePluginNotRegistered(name=ep.name, error=six.text_type(err))
|
raise TemplatePluginNotRegistered(name=ep.name, error=str(err))
|
||||||
|
|
||||||
|
|
||||||
class TemplatePluginNotRegistered(exception.HeatException):
|
class TemplatePluginNotRegistered(exception.HeatException):
|
||||||
@ -296,7 +295,7 @@ class Template(collections.Mapping):
|
|||||||
sections (e.g. parameters are check by parameters schema class).
|
sections (e.g. parameters are check by parameters schema class).
|
||||||
"""
|
"""
|
||||||
t_digest = hashlib.sha256(
|
t_digest = hashlib.sha256(
|
||||||
six.text_type(self.t).encode('utf-8')).hexdigest()
|
str(self.t).encode('utf-8')).hexdigest()
|
||||||
|
|
||||||
# TODO(kanagaraj-manickam) currently t_digest is stored in self. which
|
# TODO(kanagaraj-manickam) currently t_digest is stored in self. which
|
||||||
# is used to check whether already template is validated or not.
|
# is used to check whether already template is validated or not.
|
||||||
@ -315,7 +314,7 @@ class Template(collections.Mapping):
|
|||||||
raise exception.InvalidTemplateSection(section=k)
|
raise exception.InvalidTemplateSection(section=k)
|
||||||
|
|
||||||
# check resources
|
# check resources
|
||||||
for res in six.itervalues(self[self.RESOURCES]):
|
for res in self[self.RESOURCES].values():
|
||||||
try:
|
try:
|
||||||
if not res or not res.get('Type'):
|
if not res or not res.get('Type'):
|
||||||
message = _('Each Resource must contain '
|
message = _('Each Resource must contain '
|
||||||
@ -358,10 +357,10 @@ def parse(functions, stack, snippet, path='', template=None):
|
|||||||
|
|
||||||
if isinstance(snippet, collections.Mapping):
|
if isinstance(snippet, collections.Mapping):
|
||||||
def mkpath(key):
|
def mkpath(key):
|
||||||
return '.'.join([path, six.text_type(key)])
|
return '.'.join([path, str(key)])
|
||||||
|
|
||||||
if len(snippet) == 1:
|
if len(snippet) == 1:
|
||||||
fn_name, args = next(six.iteritems(snippet))
|
fn_name, args = next(iter(snippet.items()))
|
||||||
Func = functions.get(fn_name)
|
Func = functions.get(fn_name)
|
||||||
if Func is not None:
|
if Func is not None:
|
||||||
try:
|
try:
|
||||||
@ -376,11 +375,11 @@ def parse(functions, stack, snippet, path='', template=None):
|
|||||||
except (ValueError, TypeError, KeyError) as e:
|
except (ValueError, TypeError, KeyError) as e:
|
||||||
raise exception.StackValidationFailed(
|
raise exception.StackValidationFailed(
|
||||||
path=path,
|
path=path,
|
||||||
message=six.text_type(e))
|
message=str(e))
|
||||||
|
|
||||||
return dict((k, recurse(v, mkpath(k)))
|
return dict((k, recurse(v, mkpath(k)))
|
||||||
for k, v in six.iteritems(snippet))
|
for k, v in snippet.items())
|
||||||
elif (not isinstance(snippet, six.string_types) and
|
elif (not isinstance(snippet, str) and
|
||||||
isinstance(snippet, collections.Iterable)):
|
isinstance(snippet, collections.Iterable)):
|
||||||
|
|
||||||
def mkpath(idx):
|
def mkpath(idx):
|
||||||
|
@ -15,8 +15,6 @@ import collections
|
|||||||
import functools
|
import functools
|
||||||
import weakref
|
import weakref
|
||||||
|
|
||||||
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 conditions
|
from heat.engine import conditions
|
||||||
@ -77,7 +75,7 @@ class CommonTemplate(template.Template):
|
|||||||
|
|
||||||
yield ('resource_type',
|
yield ('resource_type',
|
||||||
self._parse_resource_field(self.RES_TYPE,
|
self._parse_resource_field(self.RES_TYPE,
|
||||||
six.string_types, 'string',
|
str, 'string',
|
||||||
name, data, parse))
|
name, data, parse))
|
||||||
|
|
||||||
yield ('properties',
|
yield ('properties',
|
||||||
@ -96,11 +94,11 @@ class CommonTemplate(template.Template):
|
|||||||
collections.Sequence,
|
collections.Sequence,
|
||||||
'list or string',
|
'list or string',
|
||||||
name, data, no_parse)
|
name, data, no_parse)
|
||||||
if isinstance(depends, six.string_types):
|
if isinstance(depends, str):
|
||||||
depends = [depends]
|
depends = [depends]
|
||||||
elif depends:
|
elif depends:
|
||||||
for dep in depends:
|
for dep in depends:
|
||||||
if not isinstance(dep, six.string_types):
|
if not isinstance(dep, str):
|
||||||
msg = _('Resource %(name)s %(key)s '
|
msg = _('Resource %(name)s %(key)s '
|
||||||
'must be a list of strings') % {
|
'must be a list of strings') % {
|
||||||
'name': name, 'key': self.RES_DEPENDS_ON}
|
'name': name, 'key': self.RES_DEPENDS_ON}
|
||||||
@ -109,7 +107,7 @@ class CommonTemplate(template.Template):
|
|||||||
yield 'depends', depends
|
yield 'depends', depends
|
||||||
|
|
||||||
del_policy = self._parse_resource_field(self.RES_DELETION_POLICY,
|
del_policy = self._parse_resource_field(self.RES_DELETION_POLICY,
|
||||||
(six.string_types,
|
(str,
|
||||||
function.Function),
|
function.Function),
|
||||||
'string',
|
'string',
|
||||||
name, data, parse)
|
name, data, parse)
|
||||||
@ -130,7 +128,7 @@ class CommonTemplate(template.Template):
|
|||||||
|
|
||||||
yield ('description',
|
yield ('description',
|
||||||
self._parse_resource_field(self.RES_DESCRIPTION,
|
self._parse_resource_field(self.RES_DESCRIPTION,
|
||||||
six.string_types, 'string',
|
str, 'string',
|
||||||
name, data, no_parse))
|
name, data, no_parse))
|
||||||
|
|
||||||
def _get_condition_definitions(self):
|
def _get_condition_definitions(self):
|
||||||
@ -195,7 +193,7 @@ class CommonTemplate(template.Template):
|
|||||||
enabled = conds.is_enabled(function.resolve(cond))
|
enabled = conds.is_enabled(function.resolve(cond))
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
path = [self.OUTPUTS, key, self.OUTPUT_CONDITION]
|
path = [self.OUTPUTS, key, self.OUTPUT_CONDITION]
|
||||||
message = six.text_type(exc)
|
message = str(exc)
|
||||||
raise exception.StackValidationFailed(path=path,
|
raise exception.StackValidationFailed(path=path,
|
||||||
message=message)
|
message=message)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user