Document navigation

GetHostResourceAllocation

API Request

URLs
POST zstack/v1/hosts/{uuid}/resource-allocation
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "strategy": "continuous",
    "scene": "normal",
    "vcpu": 60
  },
  "systemTags": [],
  "userTags": []
}
Note: In the preceding sample, both systemTags and userTags are optional. These two fields can be included in the body structure.
Curl Sample
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}}'
Request Parameters
Name Type Location Description Optional Value Starting Version
uuid String url The host UUID. 4.3.12
strategy String body(contained in the params structure) The resource allocation policy. continuous 4.3.12
scene String body(contained in the params structure) The scene type.
  • normal
  • performance
4.3.12
vcpu String body(contained in the params structure) The number of vCPUs that need to be allocated to a VM instance. [1,512] 4.3.12

API Response

Sample Response
{
      "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 The error code. If not null, the operation fails, or vice versa. For more information, see error. 4.3.12
name String The resource name. 4.3.12
uuid String The resource UUID. 4.3.12
vCPUPin array[json] The CPU pinning. For more information, see CPU Pin. 4.3.12
#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. 4.3.12
description String The brief description of the error. 4.3.12
details String The details about the error. 4.3.12
elaboration String The reserved field. Default value: null. 4.3.12
opaque LinkedHashMap The reserved field. Default value: null. 4.3.12
cause ErrorCode The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. 4.3.12
#CPU Pin
Name Type Description Starting Version
vCPU string The VM vCPU ID. 4.3.12
pCPU string The host pCPU ID. 4.3.12

SDK Sample

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()
API Reference | 4.8.38 | ZStack Cloud · ZCF | ZStack Resource Center