Add function to state module to return the low chunks

This commit is contained in:
Thomas S Hatch 2011-10-28 20:43:33 -06:00
parent d5ad2f5b95
commit abba0181c0
2 changed files with 31 additions and 1 deletions

View File

@ -62,3 +62,13 @@ def highstate():
'''
st_ = salt.state.HighState(__opts__)
return st_.call_highstate()
def show_lowstate():
'''
List out the low data that will be applied to this minion
CLI Example:
salt '*' show_lowstate
'''
st_ = salt.state.HighState(__opts__)
return st_.compile_low_chunks()

View File

@ -463,7 +463,6 @@ class State(object):
Process a high data call and ensure the defined states.
'''
err = []
rets = []
# Verify that the high data is structurally sound
errors = self.verify_high(high)
if errors:
@ -649,3 +648,24 @@ class HighState(object):
if errors:
return errors
return self.state.call_high(high)
def compile_low_chunks(self):
'''
Compile the highstate but don't run it, return the low chunks to see
exactly what the highstate will execute
'''
err = []
top = self.get_top()
matches = self.top_matches(top)
high, errors = self.render_highstate(matches)
# Verify that the high data is structurally sound
errors = self.state.verify_high(high)
# If there is extension data reconcile it
high, ext_errors = self.state.reconcile_extend(high)
errors += ext_errors
# Compile and verify the raw chunks
chunks = self.state.compile_high_data(high)
errors += self.state.verify_chunks(chunks)
if errors:
return errors
return chunks