Document navigation

QueryHost

API Request

URLs
GET zstack/v1/hosts
GET zstack/v1/hosts/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 99a86d711f154752b52a7de2b3c43a63" \
-X GET http://localhost:8080/zstack/v1/hosts?q=uuid=66547f0fc9fd45d98f6b8482488f2993
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth bd46777b8a8c4616a64f0cdbcf1bf98e" \
-X GET http://localhost:8080/zstack/v1/hosts/bb582f21cfad4f61a2ab1ec062131b4a

Queryable Fields

You can check all queryable fields and resource names that can be queried across tables by using zstack-cli, entering QueryHost, and pressing the Tab key.

API Response

Sample Response
{
  "inventories": [
    {
      "zoneUuid": "37649b12f572303a883c19c4c7af0856",
      "name": "example",
      "uuid": "f7bae73b9874344b8766dfcdda48ad6e",
      "clusterUuid": "d59c027b81fe3bbc9d78ef45f574febb",
      "description": "example",
      "managementIp": "192.168.0.1",
      "hypervisorType": "KVM",
      "state": "Enabled",
      "status": "Connected",
      "totalCpuCapacity": 4.0,
      "availableCpuCapacity": 2.0,
      "cpuSockets": 4.0,
      "totalMemoryCapacity": 1840414720,
      "availableMemoryCapacity": 1840414720,
      "cpuNum": 4.0
    }
  ]
}
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
Name Type Description Starting Version
zoneUuid String The zone UUID. 0.6
name String The resource name. 0.6
uuid String The resource UUID. 0.6
clusterUuid String The cluster UUID. 0.6
description String The detailed description of the resource. 0.6
managementIp String 0.6
hypervisorType String 0.6
state String The host state, including:
  • Enabled
  • Disabled
  • PreMaintenance
  • Maintenance
0.6
status String The host status, including:
  • Connecting
  • Connected
  • Disconnected
0.6
totalCpuCapacity Long 0.6
availableCpuCapacity Long 0.6
cpuSockets Integer 0.6
totalMemoryCapacity Long 0.6
availableMemoryCapacity Long 0.6
cpuNum Integer 0.6
createDate Timestamp The creation date. 0.6
lastOpDate Timestamp The last operation date. 0.6
Note: The state of a host can be changed as follows:
  • A host in the Enabled state can be changed to the Disabled or PreMaintenance state.
  • A host in the Disabled state can be changed to the Enabled or PreMaintenance sate.
  • A host in the PreMaintenance state can be changed to the Disabled, Enabled, or Maintenance state.
  • A host in the Maintenance state can be changed to the Disabled or Enabled state.

SDK Sample

Java SDK
QueryHostAction action = new QueryHostAction();
action.conditions = asList("uuid=fb0510cd5bf04565be44c43da20169c7");
action.sessionId = "d69767ca64854cfb99960282fcdb8aed";
QueryHostAction.Result res = action.call();
Python SDK
QueryHostAction action = QueryHostAction()
action.conditions = ["uuid=2ddc05f8f46b4d5ab40053fdb72ae69d"]
action.sessionId = "96b183220af446c39d7cf2674761d85e"
QueryHostAction.Result res = action.call()
API Reference | 5.5.30 | ZStack Cloud · ZCF | ZStack Resource Center