mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Add mod_init interface to states
The mod init interface allows for another special function to be added to a state module, the mod_init function allows for something to be run which initializes the minion environment for the execution of states.
This commit is contained in:
parent
a09021c003
commit
e5fd3a78f6
@ -103,6 +103,21 @@ class State(object):
|
||||
opts['grains'] = salt.loader.grains(opts)
|
||||
self.opts = opts
|
||||
self.load_modules()
|
||||
self.mod_init = set()
|
||||
|
||||
def _mod_init(self, low):
|
||||
'''
|
||||
Check the module initilization function, if this is the first run of
|
||||
a state package that has a mod_init function, then execute the
|
||||
mod_init function in the state module.
|
||||
'''
|
||||
minit = '{0}.mod_init'.format(low['state'])
|
||||
if not low['state'] in self.mod_init:
|
||||
self.mod_init.add(low['state'])
|
||||
else:
|
||||
return
|
||||
if mod_init in self.states:
|
||||
self.states[mod_init]()
|
||||
|
||||
def load_modules(self):
|
||||
'''
|
||||
@ -607,6 +622,7 @@ class State(object):
|
||||
Check if a chunk has any requires, execute the requires and then the
|
||||
chunk
|
||||
'''
|
||||
self._mod_init(low)
|
||||
tag = _gen_tag(low)
|
||||
requisites = ('require', 'watch')
|
||||
status = self.check_requisite(low, running, chunks)
|
||||
|
Loading…
Reference in New Issue
Block a user