mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Starting on refactor of beacon config parsing
This commit is contained in:
parent
5818b28c85
commit
19af5e5ed3
1 changed files with 20 additions and 10 deletions
|
@ -50,21 +50,18 @@ class Beacon(object):
|
|||
log.trace('Beacon processing: {0}'.format(mod))
|
||||
fun_str = '{0}.beacon'.format(mod)
|
||||
if fun_str in self.beacons:
|
||||
if isinstance(config[mod], list):
|
||||
interval = None
|
||||
interval_config = [arg for arg in config[mod] if 'interval' in arg]
|
||||
if interval_config:
|
||||
interval = interval_config[0]['interval']
|
||||
elif isinstance(config[mod], dict):
|
||||
interval = config[mod].get('interval', False)
|
||||
interval = _process_interval_config(mod, config_mod)
|
||||
if interval:
|
||||
if isinstance(b_config[mod], list):
|
||||
b_config[mod].remove(interval_config[0])
|
||||
elif isinstance(b_config[mod], dict):
|
||||
b_config[mod].pop('interval')
|
||||
if not self._process_interval(mod, interval):
|
||||
log.trace('Skipping beacon {0}. Interval not reached.'.format(mod))
|
||||
continue
|
||||
if not self._process_interval(mod, interval):
|
||||
log.trace('Skipping beacon {0}. Interval not reached.'.format(mod))
|
||||
continue
|
||||
# If configured to do so, skip the becaon processing while a state run
|
||||
# is happening.
|
||||
|
||||
raw = self.beacons[fun_str](b_config[mod])
|
||||
for data in raw:
|
||||
tag = 'salt/beacon/{0}/{1}/'.format(self.opts['id'], mod)
|
||||
|
@ -77,6 +74,19 @@ class Beacon(object):
|
|||
log.debug('Unable to process beacon {0}'.format(mod))
|
||||
return ret
|
||||
|
||||
def _process_interval_config(mod, config_mod):
|
||||
'''
|
||||
Process a beacon configuration to determine its interval
|
||||
'''
|
||||
if isinstance(config[mod], list):
|
||||
interval = None
|
||||
interval_config = [arg for arg in config[mod] if 'interval' in arg]
|
||||
if interval_config:
|
||||
interval = interval_config[0]['interval']
|
||||
elif isinstance(config[mod], dict):
|
||||
interval = config[mod].get('interval', False)
|
||||
return interval
|
||||
|
||||
def _process_interval(self, mod, interval):
|
||||
'''
|
||||
Process beacons with intervals
|
||||
|
|
Loading…
Add table
Reference in a new issue