Allocate Host Compute Resources

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": []
}

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"
    }
  ]
}
NameTypeDescriptionStarting Version
successboolean 4.7.11
nameStringResource name4.7.11
uuidStringResource UUID, uniquely identifies the resource4.7.11
vCPUPinListpCPU information allocated for the corresponding vCPU count4.7.11
errorErrorCodeError code. If not null, the operation failed. If null, the operation succeeded. See details error4.7.11

error

NameTypeDescriptionStarting Version
codeStringError code number, globally unique identifier of the error, e.g. SYS.1000, HOST.10014.7.11
descriptionStringBrief description of the error4.7.11
detailsStringDetailed error information4.7.11
elaborationStringReserved field, default is null4.7.11
opaqueLinkedHashMapReserved field, default is null4.7.11
causeErrorCodeRoot cause, the error that caused the current error. If there is no original error, this field is null4.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()