mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
addding not_during_range to schedule
This commit is contained in:
parent
5c737100c4
commit
52c2366c23
@ -58,6 +58,7 @@ SCHEDULE_CONF = [
|
|||||||
'return_config',
|
'return_config',
|
||||||
'return_kwargs',
|
'return_kwargs',
|
||||||
'run_on_start'
|
'run_on_start'
|
||||||
|
'not_during_range',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -353,7 +354,7 @@ def build_schedule_item(name, **kwargs):
|
|||||||
|
|
||||||
for item in ['range', 'when', 'once', 'once_fmt', 'cron',
|
for item in ['range', 'when', 'once', 'once_fmt', 'cron',
|
||||||
'returner', 'after', 'return_config', 'return_kwargs',
|
'returner', 'after', 'return_config', 'return_kwargs',
|
||||||
'until', 'run_on_start']:
|
'until', 'run_on_start', 'not_during_range']:
|
||||||
if item in kwargs:
|
if item in kwargs:
|
||||||
schedule[name][item] = kwargs[item]
|
schedule[name][item] = kwargs[item]
|
||||||
|
|
||||||
|
@ -1322,6 +1322,37 @@ class Schedule(object):
|
|||||||
Ignoring job {0}.'.format(job))
|
Ignoring job {0}.'.format(job))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if 'not_during_range' in data:
|
||||||
|
if not _RANGE_SUPPORTED:
|
||||||
|
log.error('Missing python-dateutil. Ignoring job {0}'.format(job))
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
if isinstance(data['not_during_range'], dict):
|
||||||
|
try:
|
||||||
|
start = int(time.mktime(dateutil_parser.parse(data['not_during_range']['start']).timetuple()))
|
||||||
|
except ValueError:
|
||||||
|
log.error('Invalid date string for start in not_during_range. Ignoring job {0}.'.format(job))
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
end = int(time.mktime(dateutil_parser.parse(data['not_during_range']['end']).timetuple()))
|
||||||
|
except ValueError:
|
||||||
|
log.error('Invalid date string for end in not_during_range. Ignoring job {0}.'.format(job))
|
||||||
|
log.error(data)
|
||||||
|
continue
|
||||||
|
if end > start:
|
||||||
|
if start <= now <= end:
|
||||||
|
run = False
|
||||||
|
else:
|
||||||
|
run = True
|
||||||
|
else:
|
||||||
|
log.error('schedule.handle_func: Invalid range, end must be larger than start. \
|
||||||
|
Ignoring job {0}.'.format(job))
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
log.error('schedule.handle_func: Invalid, range must be specified as a dictionary. \
|
||||||
|
Ignoring job {0}.'.format(job))
|
||||||
|
continue
|
||||||
|
|
||||||
if not run:
|
if not run:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user