KvmRunShell
API Request
URLs
PUT zstack/v1/hosts/kvm/actionsHeaders
Authorization: OAuth the-session-uuidBody
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.
{
"kvmRunShell": {
"hostUuids": [
"d987c37b69e14c0fbc02e32f0689e81e",
"6d47a55252504d49a5c8f344190a578c"
],
"script": "ls"
},
"systemTags": [],
"userTags": []
}
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"kvmRunShell":{"hostUuids":["7b474bb39b14397b97bc7d8d0bdd8854","580f2a7f2ca23af6aa1c93e88d4a788e"],"script":"ls"}}' \
http://localhost:8080/zstack/v1/hosts/kvm/actions
Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| hostUuids | Set | body (contained in the kvmRunShell structure) | The target host UUIDs. | 0.6 | |
| script | String | body (contained in the kvmRunShell structure) | The script. | 0.6 | |
| systemTags | List | body | Optional. The system tags. | 0.6 | |
| userTags | List | body | Optional. The user tags. | 0.6 |
API Response
Sample Response
{
"inventory": {
"8903b4b7fa694c149d932bc53ee716df": {
"returnCode": 100.0,
"stdout": "hello",
"errorCode": {}
}
}
}
| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 0.6 |
| inventory | Map | See inventory. | 0.6 |
#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 0.6 |
| description | String | The brief description of the error. | 0.6 |
| details | String | The details about the error. | 0.6 |
| elaboration | String | The reserved field. Default value: null. | 0.6 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 0.6 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 0.6 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| returnCode | int | 0.6 | |
| stdout | String | 0.6 | |
| stderr | String | 0.6 | |
| errorCode | ErrorCode | See errorCode. | 0.6 |
#errorCode
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 0.6 |
| description | String | The brief description of the error. | 0.6 |
| details | String | The details about the error. | 0.6 |
| elaboration | String | The reserved field. Default value: null. | 0.6 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 0.6 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 0.6 |
SDK Sample
Java
SDK
KvmRunShellAction action = new KvmRunShellAction();
action.hostUuids = asList("f3349fddda414ee0b64c5f32635ff76e","624ca9859a044fbe909f2aeef4e95b3e");
action.script = "ls";
action.sessionId = "c5e92dd1ca554dd781a50961fd8121ac";
KvmRunShellAction.Result res = action.call();Python
SDK
KvmRunShellAction action = KvmRunShellAction()
action.hostUuids = [b0e1155a97644eb1a756dd8d3de8eb3b, 04a502bd377e4763850d7a94ba4ffb43]
action.script = "ls"
action.sessionId = "72425e0cb8d8425f96114b5760d9a495"
KvmRunShellAction.Result res = action.call()