Get Host Resource Allocation Information Based on VM Requirements
Headers
Authorization: OAuth the-session-uuidBody
{
"params": {
"strategy": "continuous",
"scene": "normal",
"vcpu": 60
},
"systemTags": [],
"userTags": []
}In the above example, systemTags and userTags fields can be omitted. They are listed to indicate that these two fields can be included in the body.
Curl Example
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST //localhost:8080/zstack/v1/hosts/21529457e42c30f0a9b2a137915a0b28/resource-allocation -d '{"params": {"strategy": "continuous", "scene": "normal", "vcpu": 60}}'Parameter List
Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
uuid | String | url | Host UUID |
| 4.3.12 |
strategy | String | body (contained in params structure) | Resource allocation strategy | continuous (continuous allocation strategy) | 4.3.12 |
scene | String | body (contained in params structure) | Scene type |
| 4.3.12 |
vcpu | String | body (contained in params structure) | vCPU count to allocate for the VM | [1,512] | 4.3.12 |
API Response
Response Example
{
"name": "example",
"uuid": "f7bae73b9874344b8766dfcdda48ad6e",
"vCPUPin": [
{
"vCPU": "0",
"pCPU": "13"
},
{
"vCPU": "1",
"pCPU": "12"
},
{
"vCPU": "2",
"pCPU": "11"
},
{
"vCPU": "3",
"pCPU": "10"
},
{
"vCPU": "4",
"pCPU": "9"
},
{
"vCPU": "5",
"pCPU": "8"
}
]
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | Error code. If not null, the operation failed. If null, the operation succeeded. See details error | 4.3.12 |
| name | String | Resource name | 4.3.12 |
| uuid | String | Resource UUID, uniquely identifies the resource | 4.3.12 |
| vCPUPin | array[json] | Recommended vCPU pin information for this allocation, see details CPU Pin | 4.3.12 |
error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code number, globally unique identifier of the error, e.g. SYS.1000, HOST.1001 | 4.3.12 |
| description | String | Brief description of the error | 4.3.12 |
| details | String | Detailed error information | 4.3.12 |
| elaboration | String | Reserved field, default is null | 4.3.12 |
| opaque | LinkedHashMap | Reserved field, default is null | 4.3.12 |
| cause | ErrorCode | Root cause, the error that caused the current error. If there is no original error, this field is null | 4.3.12 |
#CPU Pin
| Name | Type | Description | Starting Version |
|---|---|---|---|
| vCPU | string | VM vCPU ID | 4.3.12 |
| pCPU | string | Host pCPU ID | 4.3.12 |
SDK Examples
Java SDK
GetHostResourceAllocationAction action = new GetHostResourceAllocationAction()
action.uuid = "ff6d905e75d63e18ab0a9fc2ac14951c"
action.scene = "normal"
action.strategy = "continuous"
action.vcpu = 60
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetHostResourceAllocationAction.Result res = action.call()Python SDK
GetHostResourceAllocationAction action = new GetHostResourceAllocationAction()
action.uuid = "ff6d905e75d63e18ab0a9fc2ac14951c"
action.scene = "normal"
action.strategy = "continuous"
action.vcpu = 60
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetHostResourceAllocationAction.Result res = action.call()