Get Host Resource Allocation Information Based on VM Requirements

POST/zstack/v1/hosts/{uuid}/resource-allocation

Headers

Authorization: OAuth the-session-uuid

Body

{
  "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

  • normal
  • performance

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"
    }
  ]
}
NameTypeDescriptionStarting Version
errorErrorCodeError code. If not null, the operation failed. If null, the operation succeeded. See details error4.3.12
nameStringResource name4.3.12
uuidStringResource UUID, uniquely identifies the resource4.3.12
vCPUPinarray[json]Recommended vCPU pin information for this allocation, see details CPU Pin4.3.12

error

NameTypeDescriptionStarting Version
codeStringError code number, globally unique identifier of the error, e.g. SYS.1000, HOST.10014.3.12
descriptionStringBrief description of the error4.3.12
detailsStringDetailed error information4.3.12
elaborationStringReserved field, default is null4.3.12
opaqueLinkedHashMapReserved field, default is null4.3.12
causeErrorCodeRoot cause, the error that caused the current error. If there is no original error, this field is null4.3.12

#CPU Pin

NameTypeDescriptionStarting Version
vCPUstringVM vCPU ID4.3.12
pCPUstringHost pCPU ID4.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()