Available Resource Query Operations
GetCpuMemoryCapacity
API Request
URLs
GET zstack/v1/hosts/capacities/cpu-memoryHeaders
Authorization: OAuth the-session-uuidCurl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/hosts/capacities/cpu-memory?zoneUuids=6510dcd4e77939d695b035ecbcfb217c&zoneUuids=33a39cd9391538a4a4d45666e8505dda&clusterUuids=b7c233dd9c573f63b5bb97f50028fa7f&clusterUuids=08d332af6fdb351da456aea3b6b5d029&hostUuids=ba1bfc20682136c4b2f76920af8f010e&hostUuids=b09cd47a6fa93302ae55918ef8da2af4&hypervisorType=KVM&all=trueRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| zoneUuids | List | query | Optional. The zone UUID list. | 0.6 | |
| clusterUuids | List | query | Optional. The cluster UUID list used for attaching the network and the storage. | 0.6 | |
| hostUuids | List | query | Optional. The host UUID list used for adding and deleting the host. | 0.6 | |
| all | boolean | query | Optional. Default value: false.
|
0.6 | |
| hypervisorType | String | query | Optional. The hypervisor type. |
|
0.6 |
| systemTags | List | query | Optional. The system tags. | 0.6 | |
| userTags | List | query | Optional. The user tags. | 0.6 |
API Response
Sample
Response
{
"totalCpu": 4.0,
"availableCpu": 2.0,
"totalMemory": 8.0,
"availableMemory": 4.0,
"managedCpuNum": 4.0,
"capacityData": [
{
"resourceUuid": "db558260b0b53e36aa8ebf7e40c7c9c6",
"totalCpu": 4.0,
"availableCpu": 2.0,
"totalMemory": 8.0,
"availableMemory": 4.0,
"managedCpuNum": 4.0
}
],
"resourceType": "HostVO"
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| totalCpu | long | The total CPU count. | 0.6 |
| availableCpu | long | The available CPU count. | 0.6 |
| totalMemory | long | The total memory. | 0.6 |
| availableMemory | long | The available memory. | 0.6 |
| managedCpuNum | long | The number of managed host CPUs. | 2.5.0 |
| resourceType | String | The type of queried resources, such as the host, cluster, and zone. | 3.9.0 |
| success | boolean | Whether the API succeeds. | 0.6 |
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 0.6 |
| capacityData | List | See capacityData. | 3.9.0 |
| error | ErrorCode | See error. | 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 |
#capacityData
| Name | Type | Description | Starting Version |
|---|---|---|---|
| resourceUuid | String | The resource UUID. | 3.9.0 |
| totalCpu | long | The total CPU count. | 3.9.0 |
| availableCpu | long | The available CPU count. | 3.9.0 |
| totalMemory | long | The total memory. | 3.9.0 |
| availableMemory | long | The available memory. | 3.9.0 |
| managedCpuNum | long | The number of managed host CPUs. | 3.9.0 |
#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 |
SDK Sample
Java
SDK
GetCpuMemoryCapacityAction action = new GetCpuMemoryCapacityAction();
action.zoneUuids = asList("79383afd88f54a0b994515d84dbfa447","907c8ca71ee440e3bb0327f19d60754a");
action.clusterUuids = asList("9f5431123b834d95ae642c3cb923ba32","09cdcc7e28f340ccace7c427a32e2c05");
action.hostUuids = asList("2926839176934652ac3c6a77e4ce1484","c1b46284d0dd4d2a8a7637f0d4792d31");
action.hypervisorType = "KVM";
action.all = true;
action.sessionId = "f3aedb623b3c47a7bb215ea3f4be90d7";
GetCpuMemoryCapacityAction.Result res = action.call();Python
SDK
GetCpuMemoryCapacityAction action = GetCpuMemoryCapacityAction()
action.zoneUuids = [28cd4ea55a72429d815205b0738b87b3, 2571613b0ba642b7a1c99ddc17aee8e3]
action.clusterUuids = [3e9e56c96fa545fea0b759cb601aad1c, 98ec43d31af446a9bf290b117af95e52]
action.hostUuids = [b5cf96f88a1943f89417d6bea0715b6c, b358d13ac15049a581e47c76183c1358]
action.hypervisorType = "KVM"
action.all = true
action.sessionId = "b0b7e398d33d4d7893255547d0859731"
GetCpuMemoryCapacityAction.Result res = action.call()