ExecuteGuestVmCommand
API Request
URLs
PUT zstack/v1/vm-instances/commands/execHeaders
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.
{
"params": {
"vmInstanceUuid": "af89f31332ac3457874450311affadc2",
"platform": "Linux",
"command": "echo helloworld",
"commandTimeout": 20
},
"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 POST -d '{"params":{"vmInstanceUuid":"af89f31332ac3457874450311affadc2","platform":"Linux","command":"echo helloworld","commandTimeout":20}}' http://localhost:8080/zstack/v1/vm-instances/commands/execRequest Parameters
| Name | Type | Location | Description | Valid Value | Starting Version |
|---|---|---|---|---|---|
| vmInstanceUuid | String | body (contained in the params structure) | The VM instance UUID. | 5.2.0 | |
| platform | String | body (contained in the params structure) | The platform. |
|
5.2.0 |
| command | String | body (contained in the params structure) | The command. | 5.2.0 | |
| commandTimeout | Integer | body (contained in the params structure) | Optional. The timeout period. | 5.2.0 | |
| systemTags | List | body | Optional. The system tags. | 5.2.0 | |
| userTags | List | body | Optional. The user tags. | 5.2.0 |
API Response
Sample
Response
{
"stream": "standardStream: hello world, errorStream: 1/0 is not a goodScript",
"vmInstance": {
"uuid": "fc022ba201c135d8809c5e02bf6bf156",
"name": "vm_1"
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| success | boolean | 5.2.0 | |
| stream | String | The stream. | 5.2.0 |
| vmInstance | VmInstanceInventory | See vmInstance | 5.2.0 |
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error | 5.2.0 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 5.2.0 |
| name | String | The resource name. | 5.2.0 |
| description | String | Optional. The detailed description of the resource. | 5.2.0 |
| zoneUuid | String | The zone UUID. | 5.2.0 |
| clusterUuid | String | The cluster UUID. | 5.2.0 |
| imageUuid | String | The image UUID. | 5.2.0 |
| hostUuid | String | The host UUID. | 5.2.0 |
| lastHostUuid | String | 5.2.0 | |
| instanceOfferingUuid | String | The instance offering UUID. | 5.2.0 |
| rootVolumeUuid | String | The root volume UUID. | 5.2.0 |
| platform | String | 5.2.0 | |
| architecture | String | 5.2.0 | |
| defaultL3NetworkUuid | String | 5.2.0 | |
| type | String | 5.2.0 | |
| hypervisorType | String | 5.2.0 | |
| memorySize | Long | 5.2.0 | |
| cpuNum | Integer | 5.2.0 | |
| cpuSpeed | Long | 5.2.0 | |
| allocatorStrategy | String | 5.2.0 | |
| createDate | Timestamp | The creation time. | 5.2.0 |
| lastOpDate | Timestamp | The last operation time. | 5.2.0 |
| state | String | 5.2.0 | |
| guestOsType | String | 5.2.0 | |
| vmNics | List | See vmNics | 5.2.0 |
| allVolumes | List | See allVolumes | 5.2.0 |
| vmCdRoms | List | See vmCdRoms | 5.2.0 |
#vmNics
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 5.2.0 |
| vmInstanceUuid | String | The VM instance UUID. | 5.2.0 |
| l3NetworkUuid | String | The L3 network UUID. | 5.2.0 |
| ip | String | 5.2.0 | |
| mac | String | 5.2.0 | |
| hypervisorType | String | 5.2.0 | |
| netmask | String | 5.2.0 | |
| gateway | String | 5.2.0 | |
| metaData | String | 5.2.0 | |
| ipVersion | Integer | 5.2.0 | |
| driverType | String | 5.2.0 | |
| internalName | String | 5.2.0 | |
| deviceId | Integer | 5.2.0 | |
| type | String | 5.2.0 | |
| state | String | The NIC state. | 5.2.0 |
| createDate | Timestamp | The creation time. | 5.2.0 |
| lastOpDate | Timestamp | The last operation time. | 5.2.0 |
| usedIps | List | See usedIps | 5.2.0 |
#usedIps
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 5.2.0 |
| ipRangeUuid | String | The IP range UUID. | 5.2.0 |
| l3NetworkUuid | String | The L3 network UUID. | 5.2.0 |
| ipVersion | Integer | 5.2.0 | |
| ip | String | 5.2.0 | |
| netmask | String | 5.2.0 | |
| gateway | String | 5.2.0 | |
| usedFor | String | 5.2.0 | |
| ipInLong | long | 5.2.0 | |
| vmNicUuid | String | The VM NIC UUID. | 5.2.0 |
| createDate | Timestamp | The creation time. | 5.2.0 |
| lastOpDate | Timestamp | The last operation time. | 5.2.0 |
#allVolumes
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 5.2.0 |
| name | String | The resource name. | 5.2.0 |
| description | String | Optional. The detailed description of the resource. | 5.2.0 |
| primaryStorageUuid | String | The primary storage UUID. | 5.2.0 |
| vmInstanceUuid | String | The VM instance UUID. | 5.2.0 |
| diskOfferingUuid | String | The disk offering UUID. | 5.2.0 |
| rootImageUuid | String | 5.2.0 | |
| installPath | String | 5.2.0 | |
| type | String | 5.2.0 | |
| format | String | 5.2.0 | |
| size | Long | 5.2.0 | |
| actualSize | Long | 5.2.0 | |
| deviceId | Integer | 5.2.0 | |
| state | String | 5.2.0 | |
| status | String | 5.2.0 | |
| createDate | Timestamp | The creation time. | 5.2.0 |
| lastOpDate | Timestamp | The last operation time. | 5.2.0 |
| isShareable | Boolean | 5.2.0 | |
| volumeQos | String | 5.2.0 | |
| lastDetachDate | Timestamp | 5.2.0 | |
| lastVmInstanceUuid | String | 5.2.0 |
#vmCdRoms
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 5.2.0 |
| vmInstanceUuid | String | The VM instance UUID. | 5.2.0 |
| deviceId | Integer | 5.2.0 | |
| isoUuid | String | 5.2.0 | |
| isoInstallPath | String | 5.2.0 | |
| name | String | The resource name. | 5.2.0 |
| description | String | Optional. The detailed description of the resource. | 5.2.0 |
| createDate | Timestamp | The creation time. | 5.2.0 |
| lastOpDate | Timestamp | The last operation time. | 5.2.0 |
#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. | 5.2.0 |
| description | String | The brief description of the error. | 5.2.0 |
| details | String | The details about the error. | 5.2.0 |
| elaboration | String | The reserved field. Default value: null. | 5.2.0 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 5.2.0 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 5.2.0 |
SDK Sample
Java
SDK
ExecuteGuestVmCommandAction action = new ExecuteGuestVmCommandAction();
action.vmInstanceUuid = "af89f31332ac3457874450311affadc2";
action.platform = "Linux";
action.command = "echo helloworld";
action.commandTimeout = 20;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ExecuteGuestVmCommandAction.Result res = action.call();Python
SDK
ExecuteGuestVmCommandAction action = ExecuteGuestVmCommandAction()
action.vmInstanceUuid = "af89f31332ac3457874450311affadc2"
action.platform = "Linux"
action.command = "echo helloworld"
action.commandTimeout = 20
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ExecuteGuestVmCommandAction.Result res = action.call()