Query Virtual Machine
Headers
Authorization: OAuth the-session-uuidCurl Example
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/vm-instances?q=name=vm1&q=vmNics.ip=192.168.20.100curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/vm-instances/72573bf842273c02a09f33dc061bb6f8Queryable Fields
Run the CLI command, enter QueryVmInstance and press Tab to view all queryable fields and resource names.
API Response
Response Example
{
"inventories": [
{
"uuid": "a43716db0d713c319be06811ebcc00a1",
"name": "Test-VM",
"description": "web server VM",
"zoneUuid": "dfa731eef1f13f1da298855d6ce282bd",
"clusterUuid": "743b07830cb6324192a2e0cc34186814",
"imageUuid": "ea51c3f89cb53b0db4abdd648c476f80",
"hostUuid": "d808c413110a32cab4d9c4d034818eb0",
"lastHostUuid": "3da349b211ba3cebb5629c0f90aadf63",
"instanceOfferingUuid": "1a3f2ce111cf318688f7bb0cc217d5ff",
"rootVolumeUuid": "b677bd698e1d3e4b9787fa81827d13d4",
"platform": "Linux",
"defaultL3NetworkUuid": "3bcc70b465c4371b8a7f9bd975fdec76",
"type": "UserVm",
"hypervisorType": "KVM",
"memorySize": 8589934592,
"cpuNum": 1,
"allocatorStrategy": "LastHostPreferredAllocatorStrategy",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM",
"state": "Running",
"vmNics": [
{
"uuid": "39da5aec41f336929db3458395614151",
"vmInstanceUuid": "a43716db0d713c319be06811ebcc00a1",
"usedIpUuid": "69008cc8dbd03aeba1787ec024a0b326",
"l3NetworkUuid": "3bcc70b465c4371b8a7f9bd975fdec76",
"ip": "192.168.1.10",
"mac": "00:0c:29:bd:99:fc",
"hypervisorType": "KVM",
"netmask": "255.255.255.0",
"gateway": "192.168.1.1",
"deviceId": 0,
"state": "enable",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
],
"allVolumes": [
{
"uuid": "b677bd698e1d3e4b9787fa81827d13d4",
"name": "Root-Volume-For-VM-a43716db0d713c319be06811ebcc00a1",
"primaryStorageUuid": "413b0d61df4e3b088f5ee045ff84b65b",
"vmInstanceUuid": "a43716db0d713c319be06811ebcc00a1",
"diskOfferingUuid": "37c73ea89a2b3a7bb7126f5fe7a32dc6",
"rootImageUuid": "ea51c3f89cb53b0db4abdd648c476f80",
"installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-b677bd698e1d3e4b9787fa81827d13d4/b677bd698e1d3e4b9787fa81827d13d4.qcow2",
"type": "Root",
"format": "qcow2",
"size": 107374182400,
"actualSize": 21474836480,
"deviceId": 0,
"state": "Enabled",
"status": "Ready",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
]
}
]
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| success | boolean | 0.6 | |
| error | ErrorCode | Error code. If not null, the operation failed; if null, the operation succeeded. See error | 0.6 |
| inventories | List | See inventories | 0.6 |
error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code, a globally unique identifier for the error, for example SYS.1000, HOST.1001 | 0.6 |
| description | String | Brief error description | 0.6 |
| details | String | Detailed error information | 0.6 |
| elaboration | String | Reserved field, defaults to null | 0.6 |
| opaque | LinkedHashMap | Reserved field, defaults to null | 0.6 |
| cause | ErrorCode | Root cause: the source error that triggered the current error; if there is no source error, this field is null | 0.6 |
inventories
Name | Type | Description | Starting Version |
|---|---|---|---|
uuid | String | UUID of the resource, uniquely identifying the resource | 0.6 |
name | String | Resource name | 0.6 |
description | String | Detailed description of the resource | 0.6 |
zoneUuid | String | Data Center UUID | 0.6 |
clusterUuid | String | Cluster UUID | 0.6 |
imageUuid | String | Image UUID | 0.6 |
hostUuid | String | Host UUID | 0.6 |
lastHostUuid | String |
| 0.6 |
instanceOfferingUuid | String | Instance Offering UUID | 0.6 |
rootVolumeUuid | String | Root Volume UUID | 0.6 |
platform | String |
| 0.6 |
architecture | String | Architecture Type | 4.5.0 |
defaultL3NetworkUuid | String |
| 0.6 |
type | String | Virtual Machine type, including: - UserVm
| 0.6 |
hypervisorType | String |
| 0.6 |
memorySize | Long |
| 0.6 |
cpuNum | Integer |
| 0.6 |
cpuSpeed | Long |
| 0.6 |
allocatorStrategy | String |
| 0.6 |
createDate | Timestamp | Creation Time | 0.6 |
lastOpDate | Timestamp | Last Operation Date | 0.6 |
state | String | Virtual Machine state, including: - Created
| 0.6 |
guestOsType | String | Guest OS Type | 4.5.0 |
vmNics | List | See vmNics | 0.6 |
allVolumes | List | See allVolumes | 0.6 |
vmCdRoms | List | See vmCdRoms | 4.5.0 |
vmNics
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | UUID of the resource, uniquely identifying the resource | 0.6 |
| vmInstanceUuid | String | Virtual Machine UUID | 0.6 |
| l3NetworkUuid | String | Distributed Port Group UUID | 0.6 |
| ip | String | IP Address | 0.6 |
| mac | String | MAC Address | 0.6 |
| hypervisorType | String | Virtualization Type | 0.6 |
| netmask | String | Subnet Mask | 0.6 |
| gateway | String | Gateway | 0.6 |
| metaData | String | 0.6 | |
| ipVersion | Integer | IP Address Version | 0.6 |
| driverType | String | 4.7.13 | |
| internalName | String | 4.7.13 | |
| deviceId | Integer | Device ID | 0.6 |
| type | String | NIC Type | 0.6 |
| state | String | NIC Status | 4.7.13 |
| createDate | Timestamp | Creation Time | 0.6 |
| lastOpDate | Timestamp | Last Operation Date | 0.6 |
| usedIps | List | See usedIps | 0.6 |
usedIps
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | UUID of the resource, uniquely identifying the resource | 0.6 |
| ipRangeUuid | String | IP Range UUID | 0.6 |
| l3NetworkUuid | String | Distributed Port Group UUID | 0.6 |
| ipVersion | Integer | IP Protocol Number | 3.1 |
| ip | String | IP Address | 0.6 |
| netmask | String | Netmask | 0.6 |
| gateway | String | Gateway Address | 0.6 |
| usedFor | String | 0.6 | |
| ipInLong | long | 0.6 | |
| vmNicUuid | String | Virtual Machine NIC UUID | 3.1 |
| createDate | Timestamp | Creation Time | 0.6 |
| lastOpDate | Timestamp | Last Operation Date | 0.6 |
allVolumes
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | UUID of the resource, uniquely identifying the resource | 0.6 |
| name | String | Resource name | 0.6 |
| description | String | Detailed description of the resource | 0.6 |
| primaryStorageUuid | String | Data Storage UUID | 0.6 |
| vmInstanceUuid | String | Virtual Machine UUID | 0.6 |
| diskOfferingUuid | String | Disk Offering UUID | 0.6 |
| rootImageUuid | String | Root Image UUID | 0.6 |
| installPath | String | Disk path on the data storage | 0.6 |
| type | String | Disk type, data disk/root disk | 0.6 |
| format | String | Disk Format | 0.6 |
| size | Long | Disk Size | 0.6 |
| actualSize | Long | Actual Disk Size | 0.6 |
| deviceId | Integer | 0.6 | |
| state | String | Whether the disk is enabled | 0.6 |
| status | String | Disk Status | 0.6 |
| createDate | Timestamp | Creation Time | 0.6 |
| lastOpDate | Timestamp | Last Operation Date | 0.6 |
| isShareable | Boolean | Whether the disk is shared | 0.6 |
| volumeQos | String | Disk QoS, format such as total=1048576 | 3.2.0 |
| lastDetachDate | Timestamp | 4.7.13 | |
| lastVmInstanceUuid | String | 4.7.13 |
vmCdRoms
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | UUID of the resource, uniquely identifying the resource | 4.5.0 |
| vmInstanceUuid | String | Virtual Machine UUID | 4.5.0 |
| deviceId | Integer | CD-ROM Device Order | 4.5.0 |
| isoUuid | String | ISO Image UUID | 4.5.0 |
| isoInstallPath | String | ISO Image Mount Path | 4.5.0 |
| name | String | Resource name | 4.5.0 |
| description | String | Detailed description of the resource | 4.5.0 |
| createDate | Timestamp | Creation Time | 4.5.0 |
| lastOpDate | Timestamp | Last Operation Date | 4.5.0 |
SDK Examples
Java SDK
QueryVmInstanceAction action = new QueryVmInstanceAction();
action.conditions = asList("name=vm1","vmNics.ip=192.168.20.100");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryVmInstanceAction.Result res = action.call();Python SDK
action = QueryVmInstanceAction()
action.conditions = ["name=vm1","vmNics.ip=192.168.20.100"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()