ZStack Cloud Platform
Single Server, Free Trial for One Year
POST zstack/v1/hosts/kvmAuthorization: OAuth the-session-uuid{ "params": { "username": "userName", "password": "password", "sshPort": 22, "name": "newHost", "managementIp": "127.0.0.1", "clusterUuid": "9adf394ca46432afb1218d220bf2925e" }, "systemTags": [], "userTags": [] }
Note: In the preceding example, systemTags and userTags are optional. They are listed to show these fields can be included in the body.curl -H "Content-Type: application/json;charset=UTF-8" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X POST -d '{"params":{"username":"userName","password":"password","sshPort":"22","name":"newHost","managementIp":"127.0.0.1","clusterUuid":"9adf394ca46432afb1218d220bf2925e"}}' \ http://localhost:8080/zstack/v1/hosts/kvm| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| username | String | body (contained in the params structure) | SSH username | 0.6 | |
| password | String | body (contained in the params structure) | SSH password | 0.6 | |
| sshPort (optional) | int | body (contained in the params structure) | SSH port | 0.6 | |
| name | String | body (contained in the params structure) | Resource name | 0.6 | |
| description (optional) | String | body (contained in the params structure) | Resource description | 0.6 | |
| managementIp | String | body (contained in the params structure) | Host management IP | 0.6 | |
| clusterUuid | String | body (contained in the params structure) | Cluster UUID | 0.6 | |
| resourceUuid (optional) | String | body (contained in the params structure) | Resource UUID | 0.6 | |
| systemTags (optional) | List | body | System tag | 0.6 | |
| userTags (optional) | List | body | User tag | 0.6 |
Note: pageTableExtensionDisabledpageTableExtensionDisabled{ "inventory": { "zoneUuid": "24b761ab09f7349684387fdf822aaee7", "name": "example", "uuid": "f893fe1c941939738a0ec271880d8e53", "clusterUuid": "4191157f33ab34d0a55b8e30444a1367", "description": "example", "managementIp": "192.168.0.1", "hypervisorType": "KVM", "state": "Enabled", "status": "Connected", "totalCpuCapacity": 4, "availableCpuCapacity": 2, "totalMemoryCapacity": 4, "availableMemoryCapacity": 4 } }| 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 for details | 0.6 |
| inventory | HostInventory | See inventory for details | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code number, globally unique identifier, e.g. 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 error that caused the current error. If there is no original error, this field is null | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| zoneUuid | String | Data Center UUID | 0.6 |
| name | String | Resource name | 0.6 |
| uuid | String | Resource UUID, uniquely identifies the resource | 0.6 |
| clusterUuid | String | Cluster UUID | 0.6 |
| description | String | Resource description | 0.6 |
| managementIp | String | 0.6 | |
| hypervisorType | String | 0.6 | |
| state | String | 0.6 | |
| status | String | 0.6 | |
| totalCpuCapacity | Long | 0.6 | |
| availableCpuCapacity | Long | 0.6 | |
| cpuSockets | Integer | 0.6 | |
| totalMemoryCapacity | Long | 0.6 | |
| availableMemoryCapacity | Long | 0.6 | |
| cpuNum | Integer | Logical CPU count | 0.6 |
| ipmiAddress | String | IPMI address | 0.6 |
| ipmiUsername | String | IPMI username | 0.6 |
| ipmiPort | Integer | IPMI port | 0.6 |
| ipmiPowerStatus | String | IPMI power status | 0.6 |
| architecture | String | 0.6 | |
| nqn | String | NVMe qualified name | 4.10.6 |
| hostname | String | Host name | 4.10.20 |
| createDate | Timestamp | Creation time | 0.6 |
| lastOpDate | Timestamp | Last modification time | 0.6 |
| cpuStatus | HwMonitorStatus | See cpuStatus | 4.10.0 |
| memoryStatus | HwMonitorStatus | See memoryStatus | 4.10.0 |
| diskStatus | HwMonitorStatus | See diskStatus | 4.10.0 |
| nicStatus | HwMonitorStatus | See nicStatus | 4.10.0 |
| gpuStatus | HwMonitorStatus | See gpuStatus | 4.10.0 |
| powerSupplyStatus | HwMonitorStatus | See powerSupplyStatus | 4.10.0 |
| fanStatus | HwMonitorStatus | See fanStatus | 4.10.0 |
| raidStatus | HwMonitorStatus | See raidStatus | 4.10.0 |
| temperatureStatus | HwMonitorStatus | See temperatureStatus | 4.10.0 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| Normal | HwMonitorStatus | Normal | 4.10.0 |
| Error | HwMonitorStatus | Error | 4.10.0 |
| Unknown | HwMonitorStatus | Unknown | 4.10.0 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| Normal | HwMonitorStatus | Normal | 4.10.0 |
| Error | HwMonitorStatus | Error | 4.10.0 |
| Unknown | HwMonitorStatus | Unknown | 4.10.0 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| Normal | HwMonitorStatus | Normal | 4.10.0 |
| Error | HwMonitorStatus | Error | 4.10.0 |
| Unknown | HwMonitorStatus | Unknown | 4.10.0 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| Normal | HwMonitorStatus | Normal | 4.10.0 |
| Error | HwMonitorStatus | Error | 4.10.0 |
| Unknown | HwMonitorStatus | Unknown | 4.10.0 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| Normal | HwMonitorStatus | Normal | 4.10.0 |
| Error | HwMonitorStatus | Error | 4.10.0 |
| Unknown | HwMonitorStatus | Unknown | 4.10.0 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| Normal | HwMonitorStatus | Normal | 4.10.0 |
| Error | HwMonitorStatus | Error | 4.10.0 |
| Unknown | HwMonitorStatus | Unknown | 4.10.0 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| Normal | HwMonitorStatus | Normal | 4.10.0 |
| Error | HwMonitorStatus | Error | 4.10.0 |
| Unknown | HwMonitorStatus | Unknown | 4.10.0 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| Normal | HwMonitorStatus | Normal | 4.10.0 |
| Error | HwMonitorStatus | Error | 4.10.0 |
| Unknown | HwMonitorStatus | Unknown | 4.10.0 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| Normal | HwMonitorStatus | Normal | 4.10.0 |
| Error | HwMonitorStatus | Error | 4.10.0 |
| Unknown | HwMonitorStatus | Unknown | 4.10.0 |
AddKVMHostAction action = new AddKVMHostAction(); action.username = "userName"; action.password = "password"; action.sshPort = 22; action.name = "newHost"; action.managementIp = "127.0.0.1"; action.clusterUuid = "9adf394ca46432afb1218d220bf2925e"; action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"; AddKVMHostAction.Result res = action.call();action = AddKVMHostAction() action.username = "userName" action.password = "password" action.sshPort = 22 action.name = "newHost" action.managementIp = "127.0.0.1" action.clusterUuid = "9adf394ca46432afb1218d220bf2925e" action.sessionId = "b86c9016b4f24953a9edefb53ca0678c" res = action.call()URLs
DELETE zstack/v1/hosts/{uuid}?deleteMode={deleteMode} Authorization: OAuth the-session-uuidCurl Example
curl -H "Content-Type: application/json;charset=UTF-8" \ -H "Authorization: OAuth 999c480f7f344c3b803c3d74b82b7145" \ -X DELETE http://localhost:8080/zstack/v1/hosts/bb2e5125ac2c4b3680463d7aeaf57773?deleteMode=Permissive | Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | Resource UUID, uniquely identifies the resource | 0.6 | |
| deleteMode (optional) | String | body | Delete mode (Permissive or Enforcing, default is Permissive) | 0.6 | |
| systemTags (optional) | List | body | System tag | 0.6 | |
| userTags (optional) | List | body | User tag | 0.6 |
On success, this API returns an empty JSON structure {}. On error, the returned JSON structure contains an error field, for example:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } } DeleteHostAction action = new DeleteHostAction(); action.uuid = "2d4b91d9831d4630bf113ea75f78cb7a"; action.deleteMode = "Permissive"; action.sessionId = "923c9089a5fd4ea5b9fbfc1dec5802e2"; DeleteHostAction.Result res = action.call();Python SDK
DeleteHostAction action = DeleteHostAction() action.uuid = "f62a37111c154ec9afeaeb2700ebcfe6" action.deleteMode = "Permissive" action.sessionId = "2aa7f575d8654712ba985f4a36594f0a" DeleteHostAction.Result res = action.call() GET zstack/v1/hosts GET zstack/v1/hosts/{uuid}Authorization: OAuth the-session-uuidcurl -H "Content-Type: application/json;charset=UTF-8" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X GET http://localhost:8080/zstack/v1/hosts?q=uuid=66547f0fc9fd45d98f6b8482488f2993curl -H "Content-Type: application/json;charset=UTF-8" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X GET http://localhost:8080/zstack/v1/hosts/bb582f21cfad4f61a2ab1ec062131b4aQueryable Fields
Run the CLI command tool, enter QueryHost, and press Tab to view all queryable fields and resource names that support cross-table queries.
{ "inventories": [ { "zoneUuid": "37649b12f572303a883c19c4c7af0856", "name": "example", "uuid": "f7bae73b9874344b8766dfcdda48ad6e", "clusterUuid": "d59c027b81fe3bbc9d78ef45f574febb", "description": "example", "managementIp": "192.168.0.1", "hypervisorType": "KVM", "state": "Enabled", "status": "Connected", "totalCpuCapacity": 4, "availableCpuCapacity": 2, "cpuSockets": 4, "totalMemoryCapacity": 4294967296, "availableMemoryCapacity": 4294967296, "cpuNum": 4 } ] }| 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 for details | 0.6 |
| inventories | List | See inventories for details | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code number, globally unique identifier, e.g. 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 error that caused the current error. If there is no original error, this field is null | 0.6 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| zoneUuid | String | Data Center UUID | 0.6 |
| name | String | Resource name | 0.6 |
| uuid | String | Resource UUID, uniquely identifies the resource | 0.6 |
| clusterUuid | String | Cluster UUID | 0.6 |
| description | String | Resource description | 0.6 |
| managementIp | String | 0.6 | |
| hypervisorType | String | 0.6 | |
| state | String | Host state, including:
| 0.6 |
| status | String |
| 0.6 |
| totalCpuCapacity | Long | 0.6 | |
| availableCpuCapacity | Long | 0.6 | |
| cpuSockets | Integer | 0.6 | |
| totalMemoryCapacity | Long | 0.6 | |
| availableMemoryCapacity | Long | 0.6 | |
| cpuNum | Integer | Logical CPU count | 0.6 |
| ipmiAddress | String | IPMI address | 0.6 |
| ipmiUsername | String | IPMI username | 0.6 |
| ipmiPort | Integer | IPMI port | 0.6 |
| ipmiPowerStatus | String | IPMI power status | 0.6 |
| architecture | String | 0.6 | |
| nqn | String | NVMe qualified name | 4.10.6 |
| hostname | String | Host name | 4.10.20 |
| createDate | Timestamp | Creation time | 0.6 |
| lastOpDate | Timestamp | Last modification time | 0.6 |
| cpuStatus | HwMonitorStatus | See cpuStatus | 4.10.0 |
| memoryStatus | HwMonitorStatus | See memoryStatus | 4.10.0 |
| diskStatus | HwMonitorStatus | See diskStatus | 4.10.0 |
| nicStatus | HwMonitorStatus | See nicStatus | 4.10.0 |
| gpuStatus | HwMonitorStatus | See gpuStatus | 4.10.0 |
| powerSupplyStatus | HwMonitorStatus | See powerSupplyStatus | 4.10.0 |
| fanStatus | HwMonitorStatus | See fanStatus | 4.10.0 |
| raidStatus | HwMonitorStatus | See raidStatus | 4.10.0 |
| temperatureStatus | HwMonitorStatus | See temperatureStatus | 4.10.0 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| Normal | HwMonitorStatus | Normal | 4.10.0 |
| Error | HwMonitorStatus | Error | 4.10.0 |
| Unknown | HwMonitorStatus | Unknown | 4.10.0 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| Normal | HwMonitorStatus | Normal | 4.10.0 |
| Error | HwMonitorStatus | Error | 4.10.0 |
| Unknown | HwMonitorStatus | Unknown | 4.10.0 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| Normal | HwMonitorStatus | Normal | 4.10.0 |
| Error | HwMonitorStatus | Error | 4.10.0 |
| Unknown | HwMonitorStatus | Unknown | 4.10.0 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| Normal | HwMonitorStatus | Normal | 4.10.0 |
| Error | HwMonitorStatus | Error | 4.10.0 |
| Unknown | HwMonitorStatus | Unknown | 4.10.0 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| Normal | HwMonitorStatus | Normal | 4.10.0 |
| Error | HwMonitorStatus | Error | 4.10.0 |
| Unknown | HwMonitorStatus | Unknown | 4.10.0 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| Normal | HwMonitorStatus | Normal | 4.10.0 |
| Error | HwMonitorStatus | Error | 4.10.0 |
| Unknown | HwMonitorStatus | Unknown | 4.10.0 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| Normal | HwMonitorStatus | Normal | 4.10.0 |
| Error | HwMonitorStatus | Error | 4.10.0 |
| Unknown | HwMonitorStatus | Unknown | 4.10.0 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| Normal | HwMonitorStatus | Normal | 4.10.0 |
| Error | HwMonitorStatus | Error | 4.10.0 |
| Unknown | HwMonitorStatus | Unknown | 4.10.0 |
| Name | Type | Description | Starting Version |
|---|---|---|---|
| Normal | HwMonitorStatus | Normal | 4.10.0 |
| Error | HwMonitorStatus | Error | 4.10.0 |
| Unknown | HwMonitorStatus | Unknown | 4.10.0 |
QueryHostAction action = new QueryHostAction(); action.conditions = asList("uuid=2b8e587e99093c46b27e774dfe93024f"); action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"; QueryHostAction.Result res = action.call();action = QueryHostAction() action.conditions = ["uuid=ff6d905e75d63e18ab0a9fc2ac14951c"] action.sessionId = "b86c9016b4f24953a9edefb53ca0678c" res = action.call()