Closed malinoff closed 10 years ago
Alright, the problem is because salt looks for a function name. It finds wrapped
instead of run
- and there is no wrapped
in __outputter__
.
To be able to do such things, I have two ways, as I see:
def _pre_run(frun):
def wrapped(step, **kwargs):
if step == 'configure':
__salt__['saltutil.refresh_pillar']()
return frun(step, **kwargs)
wrapped.func_name = 'run'
return wrapped
def _pre_run(frun):
def run(step, **kwargs):
if step == 'configure':
__salt__['saltutil.refresh_pillar']()
return frun(step, **kwargs)
return run
But if I'll have more functions in my module, both of approaches will fail. Uh, figured out the third way:
def _pre_run(frun):
def wrapped(step, **kwargs):
if step == 'configure':
__salt__['saltutil.refresh_pillar']()
return frun(step, **kwargs)
wrapped.func_name = frun.func_name
return wrapped
But this is ugly.
Thanks!
I'm not sure, is this a bug or not, but I think salt should handle such things.
$ cat _modules/project.py
I use it this way:
salt -C 'G@project:project-id and G@env:live' project.run deploy
,salt -C 'G@project:project-id and G@env:live' project.run configure
and so on.I want to get a properly formatted result, so I try to use
__outputter__
, but it's not working. If I comment_pre_run
decorator, it works.Also, calling
salt -C 'G@project:project-id and G@env:live' project.run configure --out=highstate
works as expected.