From 203a09a6d4acfe656427a8c32abff2e288419778 Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Mon, 5 May 2014 10:45:03 -0600 Subject: [PATCH] clean up mod_aggregate into a seperate method also change it to use config.option --- salt/state.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/salt/state.py b/salt/state.py index 987da9e090..10042f5a1c 100644 --- a/salt/state.py +++ b/salt/state.py @@ -572,6 +572,20 @@ class State(object): return self.mod_init.add(low['state']) + def _mod_aggregate(self, low, running, chunks): + ''' + Execute the aggregation systems to runtime modify the low chunk + ''' + if self.functions['config.option']('mod_aggregate') and not low.get('__agg__'): + agg_fun = '{0}.mod_aggregate'.format(low['state']) + if agg_fun in self.states: + try: + low = self.states[agg_fun](low, chunks, running) + low['__agg__'] = True + except TypeError: + log.error('Failed to execute aggregate for state {0}'.format(low['state'])) + return low + def load_modules(self, data=None): ''' Load the modules into the state @@ -1595,13 +1609,7 @@ class State(object): Check if a chunk has any requires, execute the requires and then the chunk ''' - if self.opts.get('state_aggregate') and not low.get('__agg__'): - agg_fun = '{0}.mod_aggregate'.format(low['state']) - if agg_fun in self.states: - try: - low = self.states[agg_fun](low, chunks, running) - except TypeError: - log.error('Failed to execute aggregate for state {0}'.format(low['state'])) + low = self._mod_aggregate(low, running, chunks) self._mod_init(low) tag = _gen_tag(low) if not low.get('prerequired'):