Merge pull request #993 from trane/verify_top

Verify top file return failure on invalid (#345)
This commit is contained in:
Thomas S Hatch 2012-03-23 08:58:17 -07:00
commit ad1373a0eb

View File

@ -1010,6 +1010,19 @@ class BaseHighState(object):
if env in include:
include.pop(env)
errors = []
for env,ctops in tops.items():
if env == '':
errors.append("Empty environment")
for ctop in ctops:
for key,val in ctop.items():
if val['']:
errors.append("Empty string used as key in {0}".format(
ctop))
if errors:
errors.insert(0, 'invalid')
return errors
return tops
def merge_tops(self, tops):
@ -1042,6 +1055,8 @@ class BaseHighState(object):
Returns the high data derived from the top file
'''
tops = self.get_tops()
if tops[0] == 'invalid':
return tops
return self.merge_tops(tops)
def top_matches(self, top):
@ -1221,6 +1236,8 @@ class BaseHighState(object):
Run the sequence to execute the salt highstate for this minion
'''
top = self.get_top()
if top[0] == 'invalid':
return top
matches = self.top_matches(top)
self.load_dynamic(matches)
high, errors = self.render_highstate(matches)
@ -1242,6 +1259,8 @@ class BaseHighState(object):
Return just the highstate or the errors
'''
top = self.get_top()
if top[0] == 'invalid':
return top
matches = self.top_matches(top)
high, errors = self.render_highstate(matches)
@ -1257,6 +1276,8 @@ class BaseHighState(object):
'''
err = []
top = self.get_top()
if top[0] == 'invalid':
return top
matches = self.top_matches(top)
high, errors = self.render_highstate(matches)