VM Related Interfaces

Query Virtual Machine

GET/zstack/v1/vm-instances
GET/zstack/v1/vm-instances/{uuid}

Headers

Authorization: OAuth the-session-uuid

Curl 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.100
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/vm-instances/72573bf842273c02a09f33dc061bb6f8

Queryable 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"
        }
      ]
    }
  ]
}
NameTypeDescriptionStarting Version
successboolean 0.6
errorErrorCodeError code. If not null, the operation failed; if null, the operation succeeded. See error0.6
inventoriesListSee inventories0.6

error

NameTypeDescriptionStarting Version
codeStringError code, a globally unique identifier for the error, for example SYS.1000, HOST.10010.6
descriptionStringBrief error description0.6
detailsStringDetailed error information0.6
elaborationStringReserved field, defaults to null0.6
opaqueLinkedHashMapReserved field, defaults to null0.6
causeErrorCodeRoot cause: the source error that triggered the current error; if there is no source error, this field is null0.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

  • ApplianceVm

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

  • Starting
  • Running
  • Stopping
  • Stopped
  • Rebooting
  • Destroying
  • Destroyed
  • Migrating
  • Expunging
  • Pausing
  • Paused
  • Resuming
  • VolumeMigrating
  • Unknown

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

NameTypeDescriptionStarting Version
uuidStringUUID of the resource, uniquely identifying the resource0.6
vmInstanceUuidStringVirtual Machine UUID0.6
l3NetworkUuidStringDistributed Port Group UUID0.6
ipStringIP Address0.6
macStringMAC Address0.6
hypervisorTypeStringVirtualization Type0.6
netmaskStringSubnet Mask0.6
gatewayStringGateway0.6
metaDataString 0.6
ipVersionIntegerIP Address Version0.6
driverTypeString 4.7.13
internalNameString 4.7.13
deviceIdIntegerDevice ID0.6
typeStringNIC Type0.6
stateStringNIC Status4.7.13
createDateTimestampCreation Time0.6
lastOpDateTimestampLast Operation Date0.6
usedIpsListSee usedIps0.6

usedIps

NameTypeDescriptionStarting Version
uuidStringUUID of the resource, uniquely identifying the resource0.6
ipRangeUuidStringIP Range UUID0.6
l3NetworkUuidStringDistributed Port Group UUID0.6
ipVersionIntegerIP Protocol Number3.1
ipStringIP Address0.6
netmaskStringNetmask0.6
gatewayStringGateway Address0.6
usedForString 0.6
ipInLonglong 0.6
vmNicUuidStringVirtual Machine NIC UUID3.1
createDateTimestampCreation Time0.6
lastOpDateTimestampLast Operation Date0.6

allVolumes

NameTypeDescriptionStarting Version
uuidStringUUID of the resource, uniquely identifying the resource0.6
nameStringResource name0.6
descriptionStringDetailed description of the resource0.6
primaryStorageUuidStringData Storage UUID0.6
vmInstanceUuidStringVirtual Machine UUID0.6
diskOfferingUuidStringDisk Offering UUID0.6
rootImageUuidStringRoot Image UUID0.6
installPathStringDisk path on the data storage0.6
typeStringDisk type, data disk/root disk0.6
formatStringDisk Format0.6
sizeLongDisk Size0.6
actualSizeLongActual Disk Size0.6
deviceIdInteger 0.6
stateStringWhether the disk is enabled0.6
statusStringDisk Status0.6
createDateTimestampCreation Time0.6
lastOpDateTimestampLast Operation Date0.6
isShareableBooleanWhether the disk is shared0.6
volumeQosStringDisk QoS, format such as total=10485763.2.0
lastDetachDateTimestamp 4.7.13
lastVmInstanceUuidString 4.7.13

vmCdRoms

NameTypeDescriptionStarting Version
uuidStringUUID of the resource, uniquely identifying the resource4.5.0
vmInstanceUuidStringVirtual Machine UUID4.5.0
deviceIdIntegerCD-ROM Device Order4.5.0
isoUuidStringISO Image UUID4.5.0
isoInstallPathStringISO Image Mount Path4.5.0
nameStringResource name4.5.0
descriptionStringDetailed description of the resource4.5.0
createDateTimestampCreation Time4.5.0
lastOpDateTimestampLast Operation Date4.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()