Skip to content

RESTful API For Execute

Echo edited this page Apr 28, 2018 · 3 revisions
执行shell命令
Request
POST /saltshaker/api/v1.0/execute/shell?product_id=p-4bc4a5b83bd011e8aa0e000c298454d8

POST Body
{
	"minion_id":["10.10.10.22","10.10.10.23"],
	"command":"uptime"
}
Response
HTTP/1.1 200 OK
Content-Type: application/json

{
    "data": {
        "result": {
            "10.10.10.22": " 16:25:44 up 145 days,  5:23,  1 user,  load average: 0.00, 0.01, 0.05\nUSER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT\nrrrrr pts/0    10.55.21.253     14:36    1:22m  0.11s  0.00s sshd: rrrr [priv]",
            "10.10.10.23": " 16:25:44 up 145 days,  5:15,  0 users,  load average: 0.06, 0.05, 0.05\nUSER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT"
        },
        "command": "w",
        "total": "2",
        "succeed": "2",
        "failure": "0",
        "failure_minion": ""
    },
    "status": true,
    "message": ""
}
执行sls
Request
POST /saltshaker/api/v1.0/execute/sls?product_id=p-4bc4a5b83bd011e8aa0e000c298454d8
# 采用同步的获取方式
POST Body
{
	"minion_id":["10.10.10.22","10.10.10.23"],
	"sls":"git_test"
}
Response
HTTP/1.1 200 OK
Content-Type: application/json

{
    "return": [
        {
            "10.10.10.23": {
                "cmd_|-Start_|-w_|-run": {
                    "comment": "Command \"w\" run",
                    "name": "w",
                    "start_time": "19:59:46.629693",
                    "result": true,
                    "duration": 14.476,
                    "__run_num__": 0,
                    "changes": {
                        "pid": 11381,
                        "retcode": 0,
                        "stderr": "",
                        "stdout": " 19:59:46 up 126 days,  8:57,  1 user,  load average: 0.00, 0.01, 0.05\nUSER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT\ntest pts/0    10.55.21.253     16:24    1:40m  0.18s  0.00s sshd: test [priv]"
                    },
                    "__id__": "Start"
                }
            },
            "10.10.10.22": {
                "cmd_|-Start_|-w_|-run": {
                    "comment": "Command \"w\" run",
                    "name": "w",
                    "start_time": "19:59:47.626505",
                    "result": true,
                    "duration": 16.747,
                    "__run_num__": 0,
                    "changes": {
                        "pid": 2322,
                        "retcode": 0,
                        "stderr": "",
                        "stdout": " 19:59:47 up 126 days,  8:49,  1 user,  load average: 0.01, 0.02, 0.05\nUSER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT\ntest pts/0    10.55.21.253     17:31    9:23   0.35s  0.00s sshd: test [priv]"
                    },
                    "__id__": "Start"
                }
            }
        }
    ],
    "status": true,
    "message": ""
}