diff --git a/heat/engine/scheduler.py b/heat/engine/scheduler.py index 2492d5279d..92dc50b9b6 100644 --- a/heat/engine/scheduler.py +++ b/heat/engine/scheduler.py @@ -37,11 +37,11 @@ def task_description(task): The description is used to identify the task when logging its status. """ name = task.__name__ if hasattr(task, '__name__') else None - if isinstance(task, types.MethodType): - if name is not None and hasattr(task, '__self__'): + if name is not None and isinstance(task, (types.MethodType, + types.FunctionType)): + if getattr(task, '__self__', None) is not None: return '%s from %s' % (name, task.__self__) - elif isinstance(task, types.FunctionType): - if name is not None: + else: return six.text_type(name) return repr(task) diff --git a/heat/engine/stack.py b/heat/engine/stack.py index 4adb2152b7..82f13e1d6f 100644 --- a/heat/engine/stack.py +++ b/heat/engine/stack.py @@ -14,6 +14,7 @@ import collections import copy import datetime +import functools import itertools import re @@ -909,15 +910,18 @@ class Stack(collections.Mapping): stack_status = self.COMPLETE reason = 'Stack %s completed successfully' % action + action_method = action.lower() + # If a local _$action_kwargs function exists, call it to get the + # action specific argument list, otherwise an empty arg list + handle_kwargs = getattr(self, + '_%s_kwargs' % action_method, + lambda x: {}) + + @functools.wraps(getattr(resource.Resource, action_method)) def resource_action(r): # Find e.g resource.create and call it - action_l = action.lower() - handle = getattr(r, '%s' % action_l) + handle = getattr(r, action_method) - # If a local _$action_kwargs function exists, call it to get the - # action specific argument list, otherwise an empty arg list - handle_kwargs = getattr(self, - '_%s_kwargs' % action_l, lambda x: {}) return handle(**handle_kwargs(r)) action_task = scheduler.DependencyTaskGroup( @@ -1558,11 +1562,8 @@ class Stack(collections.Mapping): 'Failed stack pre-ops: %s' % six.text_type(e)) return - def destroy_resource(stack_resource): - return stack_resource.destroy() - action_task = scheduler.DependencyTaskGroup(self.dependencies, - destroy_resource, + resource.Resource.destroy, reverse=True) try: scheduler.TaskRunner(action_task)(timeout=self.timeout_secs())