Exemplo n.º 1
0
    def conditions(self, stack):
        get_cache_stack, cached_conds = self._conditions_cache
        if (cached_conds is not None and get_cache_stack is not None
                and get_cache_stack() is stack):
            return cached_conds

        raw_defs = self._get_condition_definitions()
        if not isinstance(raw_defs, collections.Mapping):
            message = _('Condition definitions must be a map. Found a '
                        '%s instead') % type(raw_defs).__name__
            raise exception.StackValidationFailed(
                error='Conditions validation error', message=message)

        parsed = {
            n: self.parse_condition(stack, c, '.'.join([self.CONDITIONS, n]))
            for n, c in raw_defs.items()
        }
        conds = conditions.Conditions(parsed)

        get_cache_stack = weakref.ref(stack) if stack is not None else None
        self._conditions_cache = get_cache_stack, conds
        return conds
Exemplo n.º 2
0
 def conditions(self, stack):
     """Return a dictionary of resolved conditions."""
     return conditions.Conditions({})