Salt API
使用salt执行原生linux命令
安装salt-ssh
1
$ pip install salt-ssh
使用底层API执行shell命令
1
2
3
4
5from salt.client.ssh.shell import Shell
shell = Shell({"_ssh_version": (4,9)},"192.168.1.100","root",22,"root123",timeout=60)
result = shell.exec_cmd("df -h")
print(result)salt shell api
1
2
3
4
5
6from salt.client.ssh.client import SSHClient
clinet = SSHClient()
ret = client.cmd("*","cmd.run",("df -h",),30)
print(ret)