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 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 -d '{"params":{"strategy":"continuous","scene":"normal","vcpu":2,"memSize":1234567}}' \
http://localhost:8080/zstack/v1/hosts/0ce1fccc44b53601a54c3090233c07dd/allocate-resource
Parameter List
Name Type Location Description Allowed Values Starting Version
uuid String url Resource UUID, uniquely identifies the resource 4.7.11
strategy String body (contained in params structure) Allocation strategy continuous 4.7.11
scene String body (contained in params structure) Allocation scene
  • normal
  • performance
4.7.11
vcpu int body (contained in params structure) Required vCPU count 4.7.11
memSize (optional) Long body (contained in params structure) Required memory size 4.7.11
systemTags (optional) List body System tag 4.7.11
userTags (optional) List body User tag 4.7.11

API Response

Response Example
{
  "name": "example",
  "uuid": "f7bae73b9874344b8766dfcdda48ad6e",
  "vCPUPin": [
    {
      "vCPU": "0",
      "pCPU": "13"
    }
  ]
}
Name Type Description Starting Version
success boolean Whether the operation succeeded. 4.7.11
name String Resource name 4.7.11
uuid String Resource UUID, uniquely identifies the resource 4.7.11
vCPUPin List pCPU information allocated for the corresponding vCPU count 4.7.11
error ErrorCode Error code. If not null, the operation failed. If null, the operation succeeded. See details error 4.7.11
#error
Name Type Description Starting Version
code String Error code number, globally unique identifier of the error, e.g. SYS.1000, HOST.1001 4.7.11
description String Brief description of the error 4.7.11
details String Detailed error information 4.7.11
elaboration String Reserved field, default is null 4.7.11
opaque LinkedHashMap Reserved field, default is null 4.7.11
cause ErrorCode Root cause, the error that caused the current error. If there is no original error, this field is null 4.7.11

SDK Examples

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 | ZStack ZSphere · ZVF | ZStack Resource Center