Document navigation

AllocateHostResource

API Request

URLs
POST zstack/v1/hosts/{uuid}/allocate-resource
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "strategy": "continuous",
    "scene": "normal",
    "vcpu": 2,
    "memSize": 1234567
  },
  "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 -d '{"params":{"strategy":"continuous","scene":"normal","vcpu":2,"memSize":1234567}}' \
http://localhost:8080/zstack/v1/hosts/0ce1fccc44b53601a54c3090233c07dd/allocate-resource
Request Parameters
Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 4.7.11
strategy String body (contained in the params structure) The resource allocation policy. continuous 4.7.11
scene String body (contained in the params structure) The scene type.
  • normal
  • performance
4.7.11
vcpu int body (contained in the params structure) The number of vCPUs that need to be allocated to a VM instance. 4.7.11
memSize Long body (contained in the params structure) Optional. The memory size of the vNUMA node. 4.7.11
systemTags List body Optional. The system tags. 4.7.11
userTags List body Optional. The user tags. 4.7.11

API Response

Sample Response
{
  "name": "example",
  "uuid": "f7bae73b9874344b8766dfcdda48ad6e",
  "vCPUPin": [
    {
      "vCPU": "0",
      "pCPU": "13"
    }
  ]
}
Name Type Description Starting Version
success boolean 4.7.11
name String The resource name. 4.7.11
uuid String The resource UUID. 4.7.11
vCPUPin List The CPU pinning. 4.7.11
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error 4.7.11
#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.7.11
description String The short description of the error. 4.7.11
details String The details about the error. 4.7.11
elaboration String The reserved field. Default value: null. 4.7.11
opaque LinkedHashMap The reserved field. Default value: null. 4.7.11
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.7.11

SDK Sample

Java SDK
AllocateHostResourceAction action = new AllocateHostResourceAction();
action.uuid = "0ce1fccc44b53601a54c3090233c07dd";
action.strategy = "continuous";
action.scene = "normal";
action.vcpu = 2;
action.memSize = 1234567;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AllocateHostResourceAction.Result res = action.call();
Python SDK
AllocateHostResourceAction action = AllocateHostResourceAction()
action.uuid = "0ce1fccc44b53601a54c3090233c07dd"
action.strategy = "continuous"
action.scene = "normal"
action.vcpu = 2
action.memSize = 1234567
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AllocateHostResourceAction.Result res = action.call()
API Reference | 5.5.30 | ZStack Cloud · ZCF | ZStack Resource Center