我正在用 Python 中的 SaltStack API 编写一个小程序,但出现错误
import salt.client
SnakeInSalt = salt.client.LocalClient()
SnakeInSalt.cmd('*',test.ping)
错误:
python test.py
Traceback (most recent call last):
File "test.py", line 4, in <module>
SnakeInSalt.cmd('*',test.ping)
NameError: name 'test' is not defined
如果我从命令行运行salt
,它可以工作
> sudo salt '*' test.ping
> [sudo] password for z:
> z-ThinkPad:
> True