Added sanity check: is 'pillar' in self.opts

This fixes an exception that is thrown when using the 'when' clause in a
master scheduler. The master does not appear to create a 'pillar' entry
in self.opts
This commit is contained in:
Brendan McGrath 2016-02-21 12:39:36 +11:00
parent 174ee10fc2
commit 91e74feaf3

View file

@ -867,7 +867,7 @@ class Schedule(object):
if isinstance(data['when'], list):
_when = []
for i in data['when']:
if ('whens' in self.opts['pillar'] and
if ('pillar' in self.opts and 'whens' in self.opts['pillar'] and
i in self.opts['pillar']['whens']):
if not isinstance(self.opts['pillar']['whens'],
dict):
@ -936,7 +936,7 @@ class Schedule(object):
continue
else:
if ('whens' in self.opts['pillar'] and
if ('pillar' in self.opts and 'whens' in self.opts['pillar'] and
data['when'] in self.opts['pillar']['whens']):
if not isinstance(self.opts['pillar']['whens'], dict):
log.error('Pillar item "whens" must be dict.'