Document navigation

VM Scheduling Rule Group Operations

CreateHostSchedulingRuleGroup

API Request

URLs
POST zstack/v1/hostSchedulingRuleGroup
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "name": "test",
    "description": "test desc",
    "zoneUuid": "4e083eaa197835778fa94d9bfcf012d6",
    "clusterUuid": "e7127ff00fbb3ed3a9755c37447b7bf8"
  },
  "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":{"name":"test","description":"test desc","zoneUuid":"4e083eaa197835778fa94d9bfcf012d6","clusterUuid":"e7127ff00fbb3ed3a9755c37447b7bf8"}}' http://localhost:8080/zstack/v1/hostSchedulingRuleGroup
Request Parameters
Name Type Location Description Optional Value Starting Version
name String body (contained in the params structure) The resource name. 4.6.0
description String body (contained in the params structure) Optional. Optional. The detailed description of the resource. 4.6.0
zoneUuid String body (contained in the params structure) The zone UUID. 4.6.0
clusterUuid String body (contained in the params structure) The cluster UUID. 4.6.0
resourceUuid String body (contained in the params structure) Optional. The resource UUID. 4.6.0
tagUuids List body (contained in the params structure) Optional. The tag UUID list. 4.6.0
systemTags List body Optional. The system tags. 4.6.0
userTags List body Optional. The user tags. 4.6.0

API Response

Sample Response
{
  "inventory": {
    "name": "test",
    "description": "test desc",
    "zoneUuid": "1eca7fc3081a3750b55930b194d82991",
    "clusterUuid": "e73c4aa3e6a03ee3bb4f325ab3b395b1"
  }
}
Name Type Description Starting Version
success boolean 4.6.0
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 4.6.0
inventory AffinityGroupInventory See inventory. 4.6.0
#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.6.0
description String The brief description of the error. 4.6.0
details String The details about the error. 4.6.0
elaboration String The reserved field. Default value: null. 4.6.0
opaque LinkedHashMap The reserved field. Default value: null. 4.6.0
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.6.0
#inventory
Name Type Description Starting Version
uuid String The resource UUID. 4.6.0
name String The resource name. 4.6.0
description String Optional. The detailed description of the resource. 4.6.0
zoneUuid String The zone UUID. 4.6.0
clusterUuid String The cluster UUID. 4.6.0
createDate Timestamp The creation date. 4.6.0
lastOpDate Timestamp The last operation date. 4.6.0

SDK Sample

Java SDK
CreateHostSchedulingRuleGroupAction action = new CreateHostSchedulingRuleGroupAction();
action.name = "test";
action.description = "test desc";
action.zoneUuid = "4e083eaa197835778fa94d9bfcf012d6";
action.clusterUuid = "e7127ff00fbb3ed3a9755c37447b7bf8";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateHostSchedulingRuleGroupAction.Result res = action.call();
Python SDK
CreateHostSchedulingRuleGroupAction action = CreateHostSchedulingRuleGroupAction()
action.name = "test"
action.description = "test desc"
action.zoneUuid = "4e083eaa197835778fa94d9bfcf012d6"
action.clusterUuid = "e7127ff00fbb3ed3a9755c37447b7bf8"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateHostSchedulingRuleGroupAction.Result res = action.call()

DeleteHostSchedulingRuleGroup

API Request

URLs
DELETE zstack/v1/hostSchedulingRuleGroup/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/hostSchedulingRuleGroup/8e02276953ab35e2b591505b0f3167c9
Request Parameters
Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 4.6.0
systemTags List body Optional. The system tags. 4.6.0
userTags List body Optional. The user tags. 4.6.0

API Response

When the API succeeded, an empty JSON structure {} is returned. When the API failed, the returned JSON structure includes an error field. For example,
{
    "error": {
        "code": "SYS.1001",
        "description": "A message or a operation timeout",
        "details": "Create VM on KVM timeout after 300s"
    }
}

SDK Sample

Java SDK
DeleteHostSchedulingRuleGroupAction action = new DeleteHostSchedulingRuleGroupAction();
action.uuid = "8e02276953ab35e2b591505b0f3167c9";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteHostSchedulingRuleGroupAction.Result res = action.call();
Python SDK
DeleteHostSchedulingRuleGroupAction action = DeleteHostSchedulingRuleGroupAction()
action.uuid = "8e02276953ab35e2b591505b0f3167c9"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteHostSchedulingRuleGroupAction.Result res = action.call()

UpdateHostSchedulingRuleGroup

API Request

URLs
PUT zstack/v1/hostSchedulingRuleGroup/{uuid}
Headers
Authorization: OAuth the-session-uuid
Body
{
  "updateHostSchedulingRuleGroup": {
    "name": "test",
    "description": "desc"
  },
  "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 PUT -d '{"updateHostSchedulingRuleGroup":{"name":"test","description":"desc"}}' http://localhost:8080/zstack/v1/hostSchedulingRuleGroup/7127bed5295f3a3c94d9b3dbc307450d
Request Parameters
Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 4.6.0
name String body (contained in the updateHostSchedulingRuleGroup structure) Optional. The resource name. 4.6.0
description String body (contained in the updateHostSchedulingRuleGroup structure) Optional. Optional. The detailed description of the resource. 4.6.0
systemTags List body Optional. The system tags. 4.6.0
userTags List body Optional. The user tags. 4.6.0

API Response

Sample Response
{
  "inventory": {
    "uuid": "b96c8635e48435eca42d3cbfca25704f",
    "name": "test",
    "description": "desc",
    "zoneUuid": "afcd30e31ebb38a8b0a2f013fce73f7a",
    "clusterUuid": "ae9b2f516fd43913b1d458ebe5f7222d"
  }
}
Name Type Description Starting Version
success boolean 4.6.0
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error 4.6.0
inventory AffinityGroupInventory See inventory 4.6.0
#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.6.0
description String The brief description of the error. 4.6.0
details String The details about the error. 4.6.0
elaboration String The reserved field. Default value: null. 4.6.0
opaque LinkedHashMap The reserved field. Default value: null. 4.6.0
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.6.0
#inventory
Name Type Description Starting Version
uuid String The resource UUID. 4.6.0
name String The resource name. 4.6.0
description String Optional. The detailed description of the resource. 4.6.0
zoneUuid String The zone UUID. 4.6.0
clusterUuid String The cluster UUID. 4.6.0
createDate Timestamp The creation date. 4.6.0
lastOpDate Timestamp The last operation date. 4.6.0

SDK Sample

Java SDK
UpdateHostSchedulingRuleGroupAction action = new UpdateHostSchedulingRuleGroupAction();
action.uuid = "7127bed5295f3a3c94d9b3dbc307450d";
action.name = "test";
action.description = "desc";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateHostSchedulingRuleGroupAction.Result res = action.call();
Python SDK
UpdateHostSchedulingRuleGroupAction action = UpdateHostSchedulingRuleGroupAction()
action.uuid = "7127bed5295f3a3c94d9b3dbc307450d"
action.name = "test"
action.description = "desc"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateHostSchedulingRuleGroupAction.Result res = action.call()

AddHostToHostSchedulingRuleGroup

API Request

URLs
POST zstack/v1/hostSchedulingRuleGroup/{hostGroupUuid}/host/{hostUuid}
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST http://localhost:8080/zstack/v1/hostSchedulingRuleGroup/801af67a7f1f3610a76e834e45aebf5b/host/602ca3d56dca40fcb04944dbaa9861ee
Request Parameters
Name Type Location Description Optional Value Starting Version
hostGroupUuid String url The hostGroup UUID. 4.6.0
hostUuid String body The host UUID. 4.6.0
systemTags List body Optional. The system tags. 4.6.0
userTags List body Optional. The user tags. 4.6.0

API Response

When the API succeeded, an empty JSON structure {} is returned. When the API failed, the returned JSON structure includes an error field. For example,
{
    "error": {
        "code": "SYS.1001",
        "description": "A message or a operation timeout",
        "details": "Create VM on KVM timeout after 300s"
    }
}

SDK Sample

Java SDK
AddHostTohostSchedulingRuleGroupAction action = new AddHostTohostSchedulingRuleGroupAction();
action.hostGroupUuid = "663fb7c5b74f3bc9bf629ca3523fb8cc";
action.hostUuid = "64d7de2d3eb431c99998292d1ed5411e";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AddHostTohostSchedulingRuleGroupAction.Result res = action.call();
Python SDK
AddHostTohostSchedulingRuleGroupAction action = AddHostTohostSchedulingRuleGroupAction()
action.hostGroupUuid = "663fb7c5b74f3bc9bf629ca3523fb8cc"
action.hostUuid = "64d7de2d3eb431c99998292d1ed5411e"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AddHostTohostSchedulingRuleGroupAction.Result res = action.call()

DetachHostFromHostSchedulingRuleGroup

API Request

URLs
DELETE zstack/v1/hostSchedulingRuleGroup/{hostGroupUuid}/host
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/hostSchedulingRuleGroup/801af67a7f1f3610a76e834e45aebf5b/host
Request Parameters
Name Type Location Description Optional Value Starting Version
hostGroupUuid String url The UUID of the host scheduling group. 4.6.0
hostUuid String body The host UUID. 4.6.0
systemTags List body Optional. The system tags. 4.6.0
userTags List body Optional. The user tags. 4.6.0

API Response

When the API succeeded, an empty JSON structure {} is returned. When the API failed, the returned JSON structure includes an error field. For example,
{
    "error": {
        "code": "SYS.1001",
        "description": "A message or a operation timeout",
        "details": "Create VM on KVM timeout after 300s"
    }
}

SDK Sample

Java SDK
DetachHostFromHostSchedulingRuleGroupAction action = new DetachHostFromHostSchedulingRuleGroupAction();
action.hostGroupUuid = "801af67a7f1f3610a76e834e45aebf5b";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DetachHostFromHostSchedulingRuleGroupAction.Result res = action.call();
Python SDK
DetachHostFromHostSchedulingRuleGroupAction action = DetachHostFromHostSchedulingRuleGroupAction()
action.hostGroupUuid = "801af67a7f1f3610a76e834e45aebf5b"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DetachHostFromHostSchedulingRuleGroupAction.Result res = action.call()

CreateVmSchedulingRuleGroup

API Request

URLs
POST zstack/v1/vmSchedulingRuleGroup
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "zoneUuid": "eae13168e86b3698807837ca88c3b2ae",
    "name": "test",
    "description": "test desc"
  },
  "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":{"zoneUuid":"eae13168e86b3698807837ca88c3b2ae","name":"test","description":"test desc"}}' http://localhost:8080/zstack/v1/vmSchedulingRuleGroup
Request Parameters
Name Type Location Description Optional Value Starting Version
zoneUuid String body (contained in the params structure) The zone UUID. 4.6.0
name String body (contained in the params structure) The resource name. 4.6.0
description String body (contained in the params structure) Optional. Optional. The detailed description of the resource. 4.6.0
resourceUuid String body (contained in the params structure) The resource UUID. 4.6.0
tagUuids List body (contained in the params structure) Optional. The tag UUID list. 4.6.0
systemTags List body Optional. The system tags. 4.6.0
userTags List body Optional. The user tags. 4.6.0

API Response

Sample Response
{
  "inventory": {
    "uuid": "e79dc7a0170c31d18429c7478772c5d7",
    "name": "test",
    "description": "test desc",
    "appliance": "CUSTOMER",
    "zoneUuid": "e6a7cd7917473bedbfd420797d93ed50"
  }
}
Name Type Description Starting Version
success boolean 4.6.0
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 4.6.0
inventory AffinityGroupInventory See inventory 4.6.0
#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.6.0
description String The brief description of the error. 4.6.0
details String The details about the error. 4.6.0
elaboration String The reserved field. Default value: null. 4.6.0
opaque LinkedHashMap The reserved field. Default value: null. 4.6.0
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.6.0
#inventory
Name Type Description Starting Version
uuid String The resource UUID. 4.6.0
name String The resource name. 4.6.0
description String Optional. The detailed description of the resource. 4.6.0
appliance String 4.6.0
zoneUuid String The zone UUID. 4.6.0
createDate Timestamp The creation date. 4.6.0
lastOpDate Timestamp The last operation date. 4.6.0

SDK Sample

Java SDK
CreateVmSchedulingRuleGroupAction action = new CreateVmSchedulingRuleGroupAction();
action.zoneUuid = "eae13168e86b3698807837ca88c3b2ae";
action.name = "test";
action.description = "test desc";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateVmSchedulingRuleGroupAction.Result res = action.call();
Python SDK
CreateVmSchedulingRuleGroupAction action = CreateVmSchedulingRuleGroupAction()
action.zoneUuid = "eae13168e86b3698807837ca88c3b2ae"
action.name = "test"
action.description = "test desc"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateVmSchedulingRuleGroupAction.Result res = action.call()

DeleteVmSchedulingRuleGroup

API Request

URLs
DELETE zstack/v1/vmSchedulingRuleGroup/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/vmSchedulingRuleGroup/d150bf5dca4c32768464817ab2937ac4
Request Parameters
Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 4.6.0
systemTags List body Optional. The system tags. 4.6.0
userTags List body Optional. The user tags. 4.6.0

API Response

When the API succeeded, an empty JSON structure {} is returned. When the API failed, the returned JSON structure includes an error field. For example,
{
    "error": {
        "code": "SYS.1001",
        "description": "A message or a operation timeout",
        "details": "Create VM on KVM timeout after 300s"
    }
}

SDK Sample

Java SDK
DeleteVmSchedulingRuleGroupAction action = new DeleteVmSchedulingRuleGroupAction();
action.uuid = "d150bf5dca4c32768464817ab2937ac4";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteVmSchedulingRuleGroupAction.Result res = action.call();
Python SDK
DeleteVmSchedulingRuleGroupAction action = DeleteVmSchedulingRuleGroupAction()
action.uuid = "d150bf5dca4c32768464817ab2937ac4"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteVmSchedulingRuleGroupAction.Result res = action.call()

UpdateVmSchedulingRuleGroup

API Request

URLs
PUT zstack/v1/vmSchedulingRuleGroup/{uuid}/update
Headers
Authorization: OAuth the-session-uuid
Body
{
  "updateVmSchedulingRuleGroup": {
    "name": "test",
    "description": "test desc"
  },
  "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 PUT -d '{"updateVmSchedulingRuleGroup":{"name":"test","description":"test desc"}}' http://localhost:8080/zstack/v1/vmSchedulingRuleGroup/0e8a74e4ff8d3da9bff07f0cc7d58f91/update
Request Parameters
Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 4.6.0
name String body (contained in the updateVmSchedulingRuleGroup structure) Optional. The resource name. 4.6.0
description String body (contained in the updateVmSchedulingRuleGroup structure) Optional. Optional. The detailed description of the resource. 4.6.0
systemTags List body Optional. The system tags. 4.6.0
userTags List body Optional. The user tags. 4.6.0

API Response

Sample Response
{
  "inventory": {
    "uuid": "75840459a5f83afebc36e605a3189289",
    "name": "test",
    "description": "test desc",
    "appliance": "CUSTOMER",
    "zoneUuid": "261246b65f253787b06a29c6c266543c"
  }
}
Name Type Description Starting Version
success boolean 4.6.0
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error 4.6.0
inventory AffinityGroupInventory See inventory 4.6.0
#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.6.0
description String The brief description of the error. 4.6.0
details String The details about the error. 4.6.0
elaboration String The reserved field. Default value: null. 4.6.0
opaque LinkedHashMap The reserved field. Default value: null. 4.6.0
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.6.0
#inventory
Name Type Description Starting Version
uuid String The resource UUID. 4.6.0
name String The resource name. 4.6.0
description String Optional. The detailed description of the resource. 4.6.0
appliance String 4.6.0
zoneUuid String The zone UUID. 4.6.0
createDate Timestamp The creation date. 4.6.0
lastOpDate Timestamp The last operation date. 4.6.0

SDK Sample

Java SDK
UpdateVmSchedulingRuleGroupAction action = new UpdateVmSchedulingRuleGroupAction();
action.uuid = "0e8a74e4ff8d3da9bff07f0cc7d58f91";
action.name = "test";
action.description = "test desc";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateVmSchedulingRuleGroupAction.Result res = action.call();
Python SDK
UpdateVmSchedulingRuleGroupAction action = UpdateVmSchedulingRuleGroupAction()
action.uuid = "0e8a74e4ff8d3da9bff07f0cc7d58f91"
action.name = "test"
action.description = "test desc"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateVmSchedulingRuleGroupAction.Result res = action.call()

AddVmToVmSchedulingRuleGroup

API Request

URLs
POST zstack/v1/vmSchedulingRuleGroup/{vmGroupUuid}/vmInstance/{vmUuid}
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST http://localhost:8080/zstack/v1/vmSchedulingRuleGroup/663fb7c5b74f3bc9bf629ca3523fb8cc/vmInstance/64d7de2d3eb431c99998292d1ed5411e
Request Parameters
Name Type Location Description Optional Value Starting Version
vmGroupUuid String url The VM scheduling group UUID. 4.6.0
vmUuid String url The VM instance UUID. 4.6.0
systemTags List body Optional. The system tags. 4.6.0
userTags List body Optional. The user tags. 4.6.0

API Response

When the API succeeded, an empty JSON structure {} is returned. When the API failed, the returned JSON structure includes an error field. For example,
{
    "error": {
        "code": "SYS.1001",
        "description": "A message or a operation timeout",
        "details": "Create VM on KVM timeout after 300s"
    }
}

SDK Sample

Java SDK
AddVmToVmSchedulingRuleGroupAction action = new AddVmToVmSchedulingRuleGroupAction();
action.vmGroupUuid = "663fb7c5b74f3bc9bf629ca3523fb8cc";
action.vmUuid = "64d7de2d3eb431c99998292d1ed5411e";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AddVmToVmSchedulingRuleGroupAction.Result res = action.call();
Python SDK
AddVmToVmSchedulingRuleGroupAction action = AddVmToVmSchedulingRuleGroupAction()
action.vmGroupUuid = "663fb7c5b74f3bc9bf629ca3523fb8cc"
action.vmUuid = "64d7de2d3eb431c99998292d1ed5411e"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AddVmToVmSchedulingRuleGroupAction.Result res = action.call()

DetachVmFromVmSchedulingRuleGroup

API Request

URLs
DELETE zstack/v1/vmSchedulingRuleGroup/{vmGroupUuid}/vmInstance/
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/vmSchedulingRuleGroup/90c8c8b53cfc302684532e1c447e0a16/vmInstance/
Request Parameters
Name Type Location Description Optional Value Starting Version
vmGroupUuid String url The VM scheduling group UUID. 4.6.0
vmUuid String body The VM UUID. 4.6.0
systemTags List body Optional. The system tags. 4.6.0
userTags List body Optional. The user tags. 4.6.0

API Response

When the API succeeded, an empty JSON structure {} is returned. When the API failed, the returned JSON structure includes an error field. For example,
{
    "error": {
        "code": "SYS.1001",
        "description": "A message or a operation timeout",
        "details": "Create VM on KVM timeout after 300s"
    }
}

SDK Sample

Java SDK
DetachVmFromVmSchedulingRuleGroupAction action = new DetachVmFromVmSchedulingRuleGroupAction();
action.vmGroupUuid = "90c8c8b53cfc302684532e1c447e0a16";
action.vmUuid = "560967aeab103cedb06a4a8d440c8d3d";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DetachVmFromVmSchedulingRuleGroupAction.Result res = action.call();
Python SDK
DetachVmFromVmSchedulingRuleGroupAction action = DetachVmFromVmSchedulingRuleGroupAction()
action.vmGroupUuid = "90c8c8b53cfc302684532e1c447e0a16"
action.vmUuid = "560967aeab103cedb06a4a8d440c8d3d"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DetachVmFromVmSchedulingRuleGroupAction.Result res = action.call()

GetVmSchedulingRulesExecuteState

API Request

URLs
POST zstack/v1/get/vmSchedulingRules/conflict/state
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "uuids": [
      "c6bb1e89239235f8b49bb10bc5d484cc"
    ]
  },
  "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":{"uuids":["c6bb1e89239235f8b49bb10bc5d484cc"]}}' http://localhost:8080/zstack/v1/get/vmSchedulingRules/conflict/state
Request Parameters
Name Type Location Description Optional Value Starting Version
uuids List body (contained in the params structure) The VM scheduling group UUID. 4.6.0
systemTags List body Optional. The system tags. 4.6.0
userTags List body Optional. The user tags. 4.6.0

API Response

Sample Response
{
  "ruleMapState": {
    "2951e237b86630ac84d8eeb382513260": "Normal"
  }
}
Name Type Description Starting Version
success boolean
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error 4.6.0
ruleMapState Map See ruleMapState 4.6.0
#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.6.0
description String The brief description of the error. 4.6.0
details String The details about the error. 4.6.0
elaboration String The reserved field. Default value: null. 4.6.0
opaque LinkedHashMap The reserved field. Default value: null. 4.6.0
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.6.0
#ruleMapState
Name Type Description Starting Version
Conflict VmSchedulingRuleExecuteState The conflict state. 4.6.0
Normal VmSchedulingRuleExecuteState The normal state. 4.6.0
Invalid VmSchedulingRuleExecuteState The invalid state. 4.6.0

SDK Sample

Java SDK
GetVmSchedulingRulesExecuteStateAction action = new GetVmSchedulingRulesExecuteStateAction();
action.uuids = asList("c6bb1e89239235f8b49bb10bc5d484cc");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetVmSchedulingRulesExecuteStateAction.Result res = action.call();
Python SDK
GetVmSchedulingRulesExecuteStateAction action = GetVmSchedulingRulesExecuteStateAction()
action.uuids = [c6bb1e89239235f8b49bb10bc5d484cc]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetVmSchedulingRulesExecuteStateAction.Result res = action.call()

CreateVmSchedulingRule

API Request

URLs
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": []
}
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":{"rule":"AFFINITY","mode":"SOFT","vmGroupUuid":"814bca77193f3e7a871891b17f8e4122","hostGroupUuid":"e4241841b9083aed84726be7cbb966bf","name":"vm-scheduling-rule","description":"desc"}}' http://localhost:8080/zstack/v1/vmsSchedulingRule
Request Parameters
Name Type Location Description Optional Value Starting Version
rule String body (contained in the params structure) The VM scheduling rule.
  • AFFINITY
  • ANTIAFFINITY
4.6.0
mode String body (contained in the params structure) The execution mode.
  • SOFT
  • HARD
4.6.0
vmGroupUuid String body (contained in the params structure) The VM scheduling group UUID. 4.6.0
hostGroupUuid String body (contained in the params structure) The host scheduling group UUID. 4.6.0
name String body (contained in the params structure) The resource name. 4.6.0
description String body (contained in the params structure) Optional. Optional. The detailed description of the resource. 4.6.0
policy String body (contained in the params structure)
  • antiSoft
  • antiHard
4.6.0
type String body (contained in the params structure)
  • host
4.6.0
zoneUuid String body (contained in the params structure) Optional. The zone UUID. 4.6.0
subType String body (contained in the params structure) 4.6.0
resourceUuid String body (contained in the params structure) The resource UUID. 4.6.0
tagUuids List body (contained in the params structure) Optional. The tag UUID list. 4.6.0
systemTags List body Optional. The system tags. 4.6.0
userTags List body Optional. The user tags. 4.6.0

API Response

Sample Response
{
  "inventory": {
    "uuid": "d517b42f669b324288fe8977a7df2e4d",
    "name": "affinity-group-test",
    "description": "affinity group for test",
    "policy": "ANTISOFT",
    "version": "1.0",
    "type": "HOST"
  }
}
Name Type Description Starting Version
success boolean 4.6.0
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 4.6.0
inventory AffinityGroupInventory See inventory. 4.6.0
#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.6.0
description String The brief description of the error. 4.6.0
details String The details about the error. 4.6.0
elaboration String The reserved field. Default value: null. 4.6.0
opaque LinkedHashMap The reserved field. Default value: null. 4.6.0
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.6.0
#inventory
Name Type Description Starting Version
uuid String The resource UUID. 4.6.0
name String The resource name. 4.6.0
description String Optional. The detailed description of the resource. 4.6.0
policy String 4.6.0
version String 4.6.0
type String 4.6.0
appliance String 4.6.0
state String 4.6.0
createDate Timestamp The creation date. 4.6.0
lastOpDate Timestamp The last operation date. 4.6.0
usages List See usages. 4.6.0
#usages
Name Type Description Starting Version
uuid String The resource UUID. 4.6.0
affinityGroupUuid String 4.6.0
resourceUuid String 4.6.0
resourceType String 4.6.0
createDate Timestamp The creation date. 4.6.0
lastOpDate Timestamp The last operation date. 4.6.0

SDK Sample

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()

RemoveVmSchedulingRule

API Request

URLs
DELETE zstack/v1/vmSchedulingRule/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/vmSchedulingRule/b247592a7e773a338a8965dc0d2cffad
Request Parameters
Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 4.6.0
deleteMode String body Optional. The deletion mode.
  • Permissive
  • Enforcing
  • Permissive
4.6.0
systemTags List body Optional. The system tags. 4.6.0
userTags List body Optional. The user tags. 4.6.0

API Response

When the API succeeded, an empty JSON structure {} is returned. When the API failed, the returned JSON structure includes an error field. For example,
{
    "error": {
        "code": "SYS.1001",
        "description": "A message or a operation timeout",
        "details": "Create VM on KVM timeout after 300s"
    }
}

SDK Sample

Java SDK
RemoveVmSchedulingRuleAction action = new RemoveVmSchedulingRuleAction();
action.uuid = "b247592a7e773a338a8965dc0d2cffad";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
RemoveVmSchedulingRuleAction.Result res = action.call();
Python SDK
RemoveVmSchedulingRuleAction action = RemoveVmSchedulingRuleAction()
action.uuid = "b247592a7e773a338a8965dc0d2cffad"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
RemoveVmSchedulingRuleAction.Result res = action.call()

ChangeVmSchedulingRuleState

API Request

URLs
PUT zstack/v1/vmSchedulingRule/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "changeVmSchedulingRuleState": {
    "state": "enable"
  },
  "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 PUT -d '{"changeVmSchedulingRuleState":{"state":"enable"}}' http://localhost:8080/zstack/v1/vmSchedulingRule/907848e59a963a97a237c6dcb26d96ba/actions
Request Parameters
Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 4.6.0
state String body (contained in the changeVmSchedulingRuleState structure) The state after the modification.
  • enable
  • disable
4.6.0
systemTags List body Optional. The system tags. 4.6.0
userTags List body Optional. The user tags. 4.6.0

API Response

Sample Response
{
  "inventory": {
    "rule": "AFFINITY",
    "mode": "SOFT",
    "uuid": "8ab474e792183589b6a58bbe473c635a",
    "name": "Test-AffinityGroup",
    "description": "Test-AffinityGroup",
    "version": "1.0",
    "type": "HOST",
    "appliance": "CUSTOMER",
    "createDate": "Nov 14, 2017 10:20:57 PM",
    "lastOpDate": "Nov 14, 2017 10:20:57 PM"
  }
}
Name Type Description Starting Version
success boolean 4.6.0
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error 4.6.0
inventory AffinityGroupInventory See inventory 4.6.0
#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.6.0
description String The brief description of the error. 4.6.0
details String The details about the error. 4.6.0
elaboration String The reserved field. Default value: null. 4.6.0
opaque LinkedHashMap The reserved field. Default value: null. 4.6.0
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.6.0
#inventory
Name Type Description Starting Version
rule String The VM scheduling rule. 4.6.0
mode String The execution mode of the rule. 4.6.0
uuid String The resource UUID. 4.6.0
name String The resource name. 4.6.0
description String Optional. The detailed description of the resource. 4.6.0
policy String 4.6.0
version String 4.6.0
type String 4.6.0
appliance String 4.6.0
zoneUuid String The zone UUID. 4.6.0
state String 4.6.0
createDate Timestamp The creation date. 4.6.0
lastOpDate Timestamp The last operation date. 4.6.0
usages List See usages 4.6.0
#usages
Name Type Description Starting Version
uuid String The resource UUID. 4.6.0
affinityGroupUuid String 4.6.0
resourceUuid String 4.6.0
resourceType String 4.6.0
createDate Timestamp The creation date. 4.6.0
lastOpDate Timestamp The last operation date. 4.6.0

SDK Sample

Java SDK
ChangeVmSchedulingRuleStateAction action = new ChangeVmSchedulingRuleStateAction();
action.uuid = "907848e59a963a97a237c6dcb26d96ba";
action.state = "enable";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ChangeVmSchedulingRuleStateAction.Result res = action.call();
Python SDK
ChangeVmSchedulingRuleStateAction action = ChangeVmSchedulingRuleStateAction()
action.uuid = "907848e59a963a97a237c6dcb26d96ba"
action.state = "enable"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ChangeVmSchedulingRuleStateAction.Result res = action.call()

UpdateVmSchedulingRule

API Request

URLs
PUT zstack/v1/vmSchedulingRule/{uuid}/update
Headers
Authorization: OAuth the-session-uuid
Body
{
  "updateVmSchedulingRule": {
    "name": "new name",
    "description": "desc",
    "mode": "SOFT"
  },
  "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 PUT -d '{"updateVmSchedulingRule":{"name":"new name","description":"desc","mode":"SOFT"}}' http://localhost:8080/zstack/v1/vmSchedulingRule/5c23ac3de87f33ff955430556e9d1104/update
Request Parameters
Name Type Location Description Optional Value Starting Version
uuid String url The resource UUID. 4.6.0
name String body (contained in the params structure) Optional. The resource name. 4.6.0
description String body (contained in the params structure) Optional. Optional. The detailed description of the resource. 4.6.0
mode String body (contained in the params structure) Optional. 4.6.0
systemTags List body Optional. 4.6.0
userTags List body Optional. 4.6.0

API Response

Sample Response
{
  "inventory": {
    "rule": "AFFINITY",
    "mode": "SOFT",
    "uuid": "36f4174c0fcf3aefa24927f33aa2eba8",
    "name": "group",
    "description": "group for test",
    "policy": "ANTISOFT",
    "type": "HOST"
  }
}
Name Type Description Starting Version
success boolean 4.6.0
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error 4.6.0
inventory AffinityGroupInventory See inventory 4.6.0
#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.6.0
description String The brief description of the error. 4.6.0
details String The details about the error. 4.6.0
elaboration String The reserved field. Default value: null. 4.6.0
opaque LinkedHashMap The reserved field. Default value: null. 4.6.0
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.6.0
#inventory
Name Type Description Starting Version
rule String The VM scheduling rule. 4.6.0
mode String The execution mode of the rule. 4.6.0
uuid String The resource UUID. 4.6.0
name String The resource name. 4.6.0
description String Optional. The detailed description of the resource. 4.6.0
policy String 4.6.0
version String 4.6.0
type String 4.6.0
appliance String 4.6.0
zoneUuid String The zone UUID. 4.6.0
state String 4.6.0
createDate Timestamp The creation date. 4.6.0
lastOpDate Timestamp The last operation date. 4.6.0
usages List See usages 4.6.0
#usages
Name Type Description Starting Version
uuid String The resource UUID. 4.6.0
affinityGroupUuid String 4.6.0
resourceUuid String 4.6.0
resourceType String 4.6.0
createDate Timestamp The creation date. 4.6.0
lastOpDate Timestamp The last operation date. 4.6.0

SDK Sample

Java SDK
UpdateVmSchedulingRuleAction action = new UpdateVmSchedulingRuleAction();
action.uuid = "5c23ac3de87f33ff955430556e9d1104";
action.name = "new name";
action.description = "desc";
action.mode = "SOFT";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateVmSchedulingRuleAction.Result res = action.call();
Python SDK
UpdateVmSchedulingRuleAction action = UpdateVmSchedulingRuleAction()
action.uuid = "5c23ac3de87f33ff955430556e9d1104"
action.name = "new name"
action.description = "desc"
action.mode = "SOFT"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateVmSchedulingRuleAction.Result res = action.call()

ValidateVmSchedulingRule

API Request

URLs
PUT zstack/v1/validate/vmSchedulingRule
Headers
Authorization: OAuth the-session-uuid
Body
{
  "validateVmSchedulingRule": {
    "vmGroupUuid": "2bce1a0af86a3ceebd70ef1aaa3633d1",
    "hostGroupUuid": "15b9f0a9a3c43708890eef7552959746",
    "rule": "AFFINITY",
    "mode": "HARD",
    "zoneUuid": "538bdbde4d9d3b919e2cc9ae44542f09"
  },
  "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 PUT -d '{"validateVmSchedulingRule":{"vmGroupUuid":"2bce1a0af86a3ceebd70ef1aaa3633d1","hostGroupUuid":"15b9f0a9a3c43708890eef7552959746","rule":"AFFINITY","mode":"HARD","zoneUuid":"538bdbde4d9d3b919e2cc9ae44542f09"}}' http://localhost:8080/zstack/v1/validate/vmSchedulingRule
Request Parameters
Name Type Location Description Optional Value Starting Version
vmGroupUuid String body (contained in the validateVmSchedulingRule structure) The VM scheduling group UUID. 4.6.0
hostGroupUuid String body (contained in the validateVmSchedulingRule structure) Optional. The host scheduling group UUID. 4.6.0
rule String body (contained in the validateVmSchedulingRule structure) The VM scheduling rule.
  • AFFINITY
  • ANTIAFFINITY
4.6.0
mode String body (contained in the validateVmSchedulingRule structure) The execution mode of the rule.
  • SOFT
  • HARD
4.6.0
zoneUuid String body (contained in the validateVmSchedulingRule structure) Optional. The zone UUID. 4.6.0
systemTags List body Optional. The system tags. 4.6.0
userTags List body Optional. The user tags. 4.6.0

API Response

When the API succeeded, an empty JSON structure {} is returned. When the API failed, the returned JSON structure includes an error field. For example,
{
    "error": {
        "code": "SYS.1001",
        "description": "A message or a operation timeout",
        "details": "Create VM on KVM timeout after 300s"
    }
}

SDK Sample

Java SDK
ValidateVmSchedulingRuleAction action = new ValidateVmSchedulingRuleAction();
action.vmGroupUuid = "2bce1a0af86a3ceebd70ef1aaa3633d1";
action.hostGroupUuid = "15b9f0a9a3c43708890eef7552959746";
action.rule = "AFFINITY";
action.mode = "HARD";
action.zoneUuid = "538bdbde4d9d3b919e2cc9ae44542f09";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ValidateVmSchedulingRuleAction.Result res = action.call();
Python SDK
ValidateVmSchedulingRuleAction action = ValidateVmSchedulingRuleAction()
action.vmGroupUuid = "2bce1a0af86a3ceebd70ef1aaa3633d1"
action.hostGroupUuid = "15b9f0a9a3c43708890eef7552959746"
action.rule = "AFFINITY"
action.mode = "HARD"
action.zoneUuid = "538bdbde4d9d3b919e2cc9ae44542f09"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ValidateVmSchedulingRuleAction.Result res = action.call()
API Reference | 5.5.30 | ZStack Cloud · ZCF | ZStack Resource Center