QueryVmInstance
API Request
URLs
GET zstack/v1/vm-instances
GET zstack/v1/vm-instances/{uuid}Headers
Authorization: OAuth the-session-uuidCurl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 06771ba1b893402bb4c715b7acf3606e" \
-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 95c7b190063f423ea6b305f054af8bf5" \
-X GET http://localhost:8080/zstack/v1/vm-instances/3b9c1b2bca5848459881bfad378540b5Queryable Fields
You can check all queryable fields and resource names that can be queried across
tables by using zstack-cli, entering
QueryVmInstance, and pressing the Tab key.
API Response
Sample
Response
{
"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",
"architecture": "x86_64",
"defaultL3NetworkUuid": "3bcc70b465c4371b8a7f9bd975fdec76",
"type": "UserVm",
"hypervisorType": "KVM",
"memorySize": 8.589934592E9,
"cpuNum": 1.0,
"allocatorStrategy": "LastHostPreferredAllocatorStrategy",
"createDate": "Nov 14, 2017 9:20:57 AM",
"lastOpDate": "Nov 14, 2017 9:20:57 AM",
"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.0,
"createDate": "Nov 14, 2017 9:20:57 AM",
"lastOpDate": "Nov 14, 2017 9:20:57 AM"
}
],
"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": 1.073741824E11,
"actualSize": 2.147483648E10,
"deviceId": 0.0,
"state": "Enabled",
"status": "Ready",
"createDate": "Nov 14, 2017 9:20:57 AM",
"lastOpDate": "Nov 14, 2017 9:20:57 AM"
}
],
"vmCdRoms": [
{
"uuid": "45330c110bf23b08b1e41036d6c6aa6c",
"deviceId": 0.0,
"isoUuid": "5887742601aa32b5ac57e9024ff38ee8",
"name": "cd-1",
"description": "desc",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
],
"guestOsType": "CentOS7"
}
]
}
| 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 |
| inventories | List | See inventories. | 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 |
#inventories
Note: The state of a VM instance can be changed as follows:
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 0.6 |
| name | String | The resource name. | 0.6 |
| description | String | The detailed description of the resource. | 0.6 |
| zoneUuid | String | The zone UUID. | 0.6 |
| clusterUuid | String | The cluster UUID. | 0.6 |
| imageUuid | String | The image UUID. | 0.6 |
| hostUuid | String | The host UUID. | 0.6 |
| lastHostUuid | String | 0.6 | |
| instanceOfferingUuid | String | The instance offering UUID. | 0.6 |
| rootVolumeUuid | String | The root volume UUID. | 0.6 |
| platform | String | 0.6 | |
| architecture | String | The architecture type. | 4.5.0 |
| defaultL3NetworkUuid | String | 0.6 | |
| type | String | The VM instance type. Options:
|
0.6 |
| hypervisorType | String | 0.6 | |
| memorySize | Long | 0.6 | |
| cpuNum | Integer | 0.6 | |
| cpuSpeed | Long | 0.6 | |
| allocatorStrategy | String | 0.6 | |
| createDate | Timestamp | The creation date. | 0.6 |
| lastOpDate | Timestamp | The last operation date. | 0.6 |
| state | String | The state of the VM instance.
Options:
|
0.6 |
| guestOsType | String | The Operating System type. | 4.5.0 |
| vmNics | List | See vmNics. | 0.6 |
| allVolumes | List | See allVolumes. | 0.6 |
| vmCdRoms | List | See vmCdRoms | 4.5.0 |
Note: The state of a VM instance can be changed as follows:- A VM instance in the Created state can be changed to the Starting, Destroying, or Destroyed state.
- A VM instance in the Starting state can be changed to the Running, Stopped, Paused, Destroying, or Unknown state.
- A VM instance in the Running state can be changed to the Destroying, Stopping, Stopped, Rebooting, Migrating, Pausing, Paused, or Unknown state.
- A VM instance in the Stopping state can be changed to the Stopped, Destroying, Running, or Unknown state.
- A VM instance in the Stopped state can be changed to the Starting, Running, Paused, Destroying, VolumeMigrating, or Unknown state.
- A VM instance in the Migrating state can be changed to the Running, Stopped, Unknown, or Destroying state.
- A VM instance in the VolumeMigrating state can be changed to the Stopped, Unknown, or Destroying state.
- A VM instance in the Rebooting state can be changed to the Running, Stopped, Unknown, or Destroying state.
- A VM instance in the Paused state can be changed to the Resuming, Stopped, Running, Stopping, Destroying, Unknown, or Migrating state.
- A VM instance in the Pausing state can be changed to the Paused, Destroying, Running, or Unknown state.
- A VM instance in the Resuming state can be changed to the Running, Destroying, Paused, or Unknown state.
- A VM instance in the Unknown state can be changed to the Destroying, Stopping, Paused, Running, or Stopped state.
- A VM instance in the Destroying state can be changed to the Unknown, Destroyed, Running, or Expunging state.
- A VM instance in the Destroyed state can be changed to the Stopped state.
#vmNics
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 0.6 |
| vmInstanceUuid | String | The VM instance UUID. | 0.6 |
| l3NetworkUuid | String | The L3 network UUID. | 0.6 |
| ip | String | The IP address. | 0.6 |
| mac | String | The MAC address. | 0.6 |
| hypervisorType | String | The hypervisor type. | 0.6 |
| netmask | String | The netmask. | 0.6 |
| gateway | String | The gateway. | 0.6 |
| metaData | String | 0.6 | |
| ipVersion | Integer | The IP version. | 0.6 |
| deviceId | Integer | The device ID. | 0.6 |
| type | String | The NIC type. | 0.6 |
| usedIps | List | For more information, see usedIps | 0.6 |
| createDate | Timestamp | The creation date. | 0.6 |
| lastOpDate | Timestamp | The last operation date. | 0.6 |
#usedIps
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 0.6 |
| ipRangeUuid | String | The IP range UUID. | 0.6 |
| l3NetworkUuid | String | The L3 network UUID. | 0.6 |
| ipVersion | Integer | The IP version. | 3.1 |
| ip | String | The IP address. | 0.6 |
| netmask | String | The netmask. | 0.6 |
| gateway | String | The gateway. | 0.6 |
| usedFor | String | 0.6 | |
| ipInLong | long | 0.6 | |
| vmNicUuid | String | The VM NIC UUID. | 3.1 |
| createDate | Timestamp | The creation date. | 0.6 |
| lastOpDate | Timestamp | The last operation date. | 0.6 |
#allVolumes
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 0.6 |
| name | String | The resource name. | 0.6 |
| description | String | The detailed description of the resource. | 0.6 |
| primaryStorageUuid | String | The primary storage UUID. | 0.6 |
| vmInstanceUuid | String | The VM instance UUID. | 0.6 |
| diskOfferingUuid | String | The disk offering UUID. | 0.6 |
| rootImageUuid | String | The root image UUID. | 0.6 |
| installPath | String | The installation path. | 0.6 |
| type | String | The volume type. | 0.6 |
| format | String | The volume format. | 0.6 |
| size | Long | The volume size. | 0.6 |
| actualSize | Long | The actual size of the volume. | 0.6 |
| deviceId | Integer | 0.6 | |
| state | String | The volume state. | 0.6 |
| status | String | The volume status. | 0.6 |
| createDate | Timestamp | The creation date. | 0.6 |
| lastOpDate | Timestamp | The last operation date. | 0.6 |
| isShareable | Boolean | 0.6 | |
| volumeQos | String | The volume QoS, in the format of total=1048576 | 3.2.0 |
#vmCdRoms
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 4.5.0 |
| vmInstanceUuid | String | The VM instance UUID. | 4.5.0 |
| deviceId | Integer | The drive sequence number. | 4.5.0 |
| isoUuid | String | The ISO image UUID. | 4.5.0 |
| isoInstallPath | String | The mount path of the ISO image. | 4.5.0 |
| name | String | The resource name. | 4.5.0 |
| description | String | Optional. The detailed description of the resource. | 4.5.0 |
| createDate | Timestamp | The creation date. | 4.5.0 |
| lastOpDate | Timestamp | The last operation date. | 4.5.0 |
SDK Sample
Java
SDK
QueryVmInstanceAction action = new QueryVmInstanceAction();
action.conditions = asList("name=vm1","vmNics.ip=192.168.20.100");
action.sessionId = "1a2f35770a8e4e53b4bfb9d0d7ae7e50";
QueryVmInstanceAction.Result res = action.call();Python
SDK
QueryVmInstanceAction action = QueryVmInstanceAction()
action.conditions = ["name=vm1","vmNics.ip=192.168.20.100"]
action.sessionId = "0dd4f4ec663f4502ba3fedda9d0ebc1b"
QueryVmInstanceAction.Result res = action.call()