如何从Python脚本调用salt-call state.highstate?

时间:2015-04-30 21:26:48

标签: python salt-stack

是否可以在python脚本中调用salt-call state.highstate(命令)并知道它何时完成? (全自动(Masterless))

1 个答案:

答案 0 :(得分:0)

看起来可能需要编写returner,将结果存储在文件或其他内容

并使用

调用该命令
subprocess.check_output("salt-call state.highstate --returner=myReturner",shell=True)
#if the command blocks and does not return immediatly at this point it is finished

#if the command does not block you will have to check for the file that your returner creates until it exists
while not os.path.exists("my_returner_output.txt"):
     time.sleep(1)
print "OK COMMAND COMPLETE"