Create VM Scheduling Policy

POST/zstack/v1/vmsSchedulingRule

Headers

Authorization: OAuth the-session-uuid

Body

{
  "params": {
    "rule": "AFFINITY",
    "mode": "SOFT",
    "vmGroupUuid": "814bca77193f3e7a871891b17f8e4122",
    "hostGroupUuid": "e4241841b9083aed84726be7cbb966bf",
    "name": "vm-scheduling-rule",
    "description": "desc"
  },
  "systemTags": [],
  "userTags": []
}

The systemTags and userTags fields in the above example are optional. They are listed to indicate that the body can contain these two fields.

Curl Example

curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"rule":"AFFINITY","mode":"SOFT","vmGroupUuid":"814bca77193f3e7a871891b17f8e4122","hostGroupUuid":"e4241841b9083aed84726be7cbb966bf","name":"vm-scheduling-rule","description":"desc"}}' http://localhost:8080/zstack/v1/vmsSchedulingRule

Parameter List

Name

Type

Location

Description

Allowed Values

Starting Version

rule

String

body (contained in the params structure)

Rule

  • AFFINITY
  • ANTIAFFINITY

4.6.0

mode

String

body (contained in the params structure)

Enforcement level

  • SOFT
  • HARD

4.6.0

vmGroupUuid

String

body (contained in the params structure)

VM scheduling group UUID

 

4.6.0

hostGroupUuid (optional)

String

body (contained in the params structure)

Host scheduling group UUID

 

4.6.0

name

String

body (contained in the params structure)

Resource name

 

4.6.0

description (optional)

String

body (contained in the params structure)

Detailed description of the resource

 

4.6.0

policy (optional)

String

body (contained in the params structure)

 

  • antiSoft
  • antiHard

4.6.0

type (optional)

String

body (contained in the params structure)

 

host

4.6.0

zoneUuid (optional)

String

body (contained in the params structure)

Data Center UUID

 

4.6.0

subType (optional)

String

body (contained in the params structure)

 

 

4.6.0

resourceUuid (optional)

String

body (contained in the params structure)

Resource UUID

 

4.6.0

tagUuids (optional)

List

body (contained in the params structure)

Tag UUID list

 

4.6.0

systemTags (optional)

List

body

System tags

 

4.6.0

userTags (optional)

List

body

User tags

 

4.6.0

API Response

Response Example

{
  "inventory": {
    "uuid": "d517b42f669b324288fe8977a7df2e4d",
    "name": "affinity-group-test",
    "description": "affinity group for test",
    "policy": "ANTISOFT",
    "version": "1.0",
    "type": "HOST"
  }
}
NameTypeDescriptionStarting Version
successboolean 4.6.0
errorErrorCodeError code. If not null, the operation failed. This field is null when the operation succeeds. For details, see error4.6.0
inventoryAffinityGroupInventoryFor details, see inventory4.6.0

error

NameTypeDescriptionStarting Version
codeStringError code number. A globally unique identifier for the error, for example, SYS.1000, HOST.10014.6.0
descriptionStringBrief description of the error4.6.0
detailsStringDetailed information about the error4.6.0
elaborationStringReserved field. Default is null4.6.0
opaqueLinkedHashMapReserved field. Default is null4.6.0
causeErrorCodeRoot error. The source error that caused the current error. This field is null if no root error exists4.6.0

inventory

NameTypeDescriptionStarting Version
uuidStringUUID of the resource. Uniquely identifies the resource4.6.0
nameStringResource name4.6.0
descriptionStringDetailed description of the resource4.6.0
policyString 4.6.0
versionString 4.6.0
typeString 4.6.0
applianceString 4.6.0
stateString 4.6.0
createDateTimestampCreation time4.6.0
lastOpDateTimestampLast modification time4.6.0
usagesListFor details, see usages4.6.0

usages

NameTypeDescriptionStarting Version
uuidStringUUID of the resource. Uniquely identifies the resource4.6.0
affinityGroupUuidString 4.6.0
resourceUuidString 4.6.0
resourceTypeString 4.6.0
createDateTimestampCreation time4.6.0
lastOpDateTimestampLast modification time4.6.0

SDK Examples

Java SDK

CreateVmSchedulingRuleAction action = new CreateVmSchedulingRuleAction();
action.rule = "AFFINITY";
action.mode = "SOFT";
action.vmGroupUuid = "814bca77193f3e7a871891b17f8e4122";
action.hostGroupUuid = "e4241841b9083aed84726be7cbb966bf";
action.name = "vm-scheduling-rule";
action.description = "desc";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateVmSchedulingRuleAction.Result res = action.call();

Python SDK

CreateVmSchedulingRuleAction action = CreateVmSchedulingRuleAction()
action.rule = "AFFINITY"
action.mode = "SOFT"
action.vmGroupUuid = "814bca77193f3e7a871891b17f8e4122"
action.hostGroupUuid = "e4241841b9083aed84726be7cbb966bf"
action.name = "vm-scheduling-rule"
action.description = "desc"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateVmSchedulingRuleAction.Result res = action.call()