DRS Policy APIs
GetClusterDRSStatus
API Request
URLs
GET zstack/v1/clusters/drs/statusHeaders
Authorization: OAuth the-session-uuidCurl Example
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/clusters/drs/statusParameter List
| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| drsUuid | String | query | The UUID of the Cluster DRS | 4.0.0 | |
| systemTags (Optional) | List | query | System tags | 4.0.0 | |
| userTags (Optional) | List | query | User tags | 4.0.0 |
API Response
On success, this API returns an empty JSON structure
{}. On failure, the returned JSON structure contains 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 Examples
Java
SDK
GetClusterDRSStatusAction action = new GetClusterDRSStatusAction();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetClusterDRSStatusAction.Result res = action.call();Python
SDK
GetClusterDRSStatusAction action = GetClusterDRSStatusAction()
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetClusterDRSStatusAction.Result res = action.call()QueryClusterDRS
API Request
URLs
GET zstack/v1/clusters/drs
GET zstack/v1/clusters/drs/{uuid}Headers
Authorization: OAuth the-session-uuidCurl Example
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/clusters/drscurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/clusters/drs/aaa6a44233d23decb16c085599167233Queryable Fields
Run the CLI command-line tool, type QueryClusterDRS and press the Tab key to view all queryable fields and cross-table queryable resource names.
API Response
On success, this API returns an empty JSON structure
{}. On failure, the returned JSON structure contains 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 Examples
Java
SDK
QueryClusterDRSAction action = new QueryClusterDRSAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryClusterDRSAction.Result res = action.call();Python
SDK
QueryClusterDRSAction action = QueryClusterDRSAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryClusterDRSAction.Result res = action.call()QueryDRSAdvice
API Request
URLs
GET zstack/v1/clusters/drs/advice
GET zstack/v1/clusters/drs/advice/{uuid}Headers
Authorization: OAuth the-session-uuidCurl Example
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/clusters/drs/advicecurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/clusters/drs/advice/e0f394447d143aceb0dc96ec0373a4cbQueryable Fields
Run the CLI command-line tool, type QueryClusterDRS and press the Tab key to view all queryable fields and cross-table queryable resource names.
API Response
On success, this API returns an empty JSON structure
{}. On failure, the returned JSON structure contains 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 Examples
Java
SDK
QueryDRSAdviceAction action = new QueryDRSAdviceAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryDRSAdviceAction.Result res = action.call();Python
SDK
QueryDRSAdviceAction action = QueryDRSAdviceAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryDRSAdviceAction.Result res = action.call()QueryDRSVmMigrationActivity
API Request
URLs
GET zstack/v1/clusters/drs/vm-migration-activities
GET zstack/v1/clusters/drs/vm-migration-activities/{uuid}Headers
Authorization: OAuth the-session-uuidCurl Example
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/clusters/drs/vm-migration-activitiescurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/clusters/drs/vm-migration-activities/757ecbe2929e3ad7b5935c6b38229279Queryable Fields
Run the CLI command-line tool, type QueryClusterDRS and press the Tab key to view all queryable fields and cross-table queryable resource names.
API Response
On success, this API returns an empty JSON structure
{}. On failure, the returned JSON structure contains 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 Examples
Java
SDK
QueryDRSVmMigrationActivityAction action = new QueryDRSVmMigrationActivityAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryDRSVmMigrationActivityAction.Result res = action.call();Python
SDK
QueryDRSVmMigrationActivityAction action = QueryDRSVmMigrationActivityAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryDRSVmMigrationActivityAction.Result res = action.call()ApplyDRSAdvice
API Request
URLs
PUT zstack/v1/clusters/drs/advice/{adviceUuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
Note: In the above example, the
{
"applyDRSAdvice": {},
"systemTags": [],
"userTags": []
}
Note: In the above example, the 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 PUT -d '{"applyDRSAdvice":{}}' \
http://localhost:8080/zstack/v1/clusters/drs/advice/ff0813227ab932de82d8c5c593993200/actionsParameter List
| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| adviceUuid | String | url | The UUID of the DRS scheduling advice | 4.0.0 | |
| systemTags (Optional) | List | body | System tags | 4.0.0 | |
| userTags (Optional) | List | body | User tags | 4.0.0 |
API Response
On success, this API returns an empty JSON structure
{}. On failure, the returned JSON structure contains 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 Examples
Java
SDK
ApplyDRSAdviceAction action = new ApplyDRSAdviceAction();
action.adviceUuid = "ff0813227ab932de82d8c5c593993200";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ApplyDRSAdviceAction.Result res = action.call();Python
SDK
ApplyDRSAdviceAction action = ApplyDRSAdviceAction()
action.adviceUuid = "ff0813227ab932de82d8c5c593993200"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ApplyDRSAdviceAction.Result res = action.call()CreateClusterDRS
API Request
URLs
POST zstack/v1/clusters/{clusterUuid}/drsHeaders
Authorization: OAuth the-session-uuidBody
Note: In the above example, the
{
"params": {
"name": "test",
"automationLevel": "Automatic",
"thresholds": [
{
"thresholdName": "cpuUsedPercentThreshold",
"thresholdValue": "90",
"operator": "\u003e\u003d"
}
],
"thresholdDuration": 10,
"defaultEnable": true
},
"systemTags": [],
"userTags": []
}
Note: In the above example, the 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":{"name":"test","automationLevel":"Automatic","thresholds":[{"thresholdName":"cpuUsedPercentThreshold","thresholdValue":"90","operator":">="}],"thresholdDuration":10,"defaultEnable":true}}' \
http://localhost:8080/zstack/v1/clusters/ff0bcb94de7a3567b641d3fde2329d00/drsParameter List
| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| name | String | body(included in the params structure) |
The resource name | 4.0.0 | |
| description (Optional) | String | body(included in the params structure) |
The detailed description of the resource | 4.0.0 | |
| clusterUuid | String | url | The Cluster UUID | 4.0.0 | |
| automationLevel | String | body(included in the params structure) |
Whether scheduling is triggered manually or automatically |
|
4.0.0 |
| thresholds | List | body(included in the params structure) |
The threshold criteria | 4.0.0 | |
| thresholdDuration | Integer | body(included in the params structure) |
The threshold evaluation duration. The system queries the workload data for the period from the current time back to thresholdDuration, calculates the result, and compares it with the threshold to determine whether the Cluster requires scheduling. | 4.0.0 | |
| defaultEnable (Optional) | boolean | body(included in the params structure) |
The enabled state of the Cluster DRS upon creation | 4.0.0 | |
| resourceUuid (Optional) | String | body(included in the params structure) |
The resource UUID | 4.0.0 | |
| tagUuids (Optional) | List | body(included in the params structure) |
The list of tag UUIDs | 3.4.0 | |
| systemTags (Optional) | List | body | System tags | 4.0.0 | |
| userTags (Optional) | List | body | User tags | 4.0.0 |
API Response
On success, this API returns an empty JSON structure
{}. On failure, the returned JSON structure contains 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 Examples
Java
SDK
CreateClusterDRSAction action = new CreateClusterDRSAction();
action.name = "test";
action.clusterUuid = "ff0bcb94de7a3567b641d3fde2329d00";
action.automationLevel = "Automatic";
action.thresholds = asList([thresholdName:cpuUsedPercentThreshold, thresholdValue:90, operator:>=]);
action.thresholdDuration = 10;
action.defaultEnable = true;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateClusterDRSAction.Result res = action.call();Python
SDK
CreateClusterDRSAction action = CreateClusterDRSAction()
action.name = "test"
action.clusterUuid = "ff0bcb94de7a3567b641d3fde2329d00"
action.automationLevel = "Automatic"
action.thresholds = [[thresholdName:cpuUsedPercentThreshold, thresholdValue:90, operator:>=]]
action.thresholdDuration = 10
action.defaultEnable = true
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateClusterDRSAction.Result res = action.call()DeleteClusterDRS
API Request
URLs
DELETE zstack/v1/clusters/drs/{uuid}Headers
Authorization: OAuth the-session-uuidCurl Example
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/clusters/drs/ff067b9ad438337aa3d5beea6f504f00Parameter List
| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The UUID of the resource. Uniquely identifies the resource. | 4.0.0 | |
| deleteMode (Optional) | String | body | The delete mode (Permissive / Enforcing, Permissive) | 4.0.0 | |
| systemTags (Optional) | List | body | System tags | 4.0.0 | |
| userTags (Optional) | List | body | User tags | 4.0.0 |
API Response
On success, this API returns an empty JSON structure
{}. On failure, the returned JSON structure contains 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 Examples
Java
SDK
DeleteClusterDRSAction action = new DeleteClusterDRSAction();
action.uuid = "ff067b9ad438337aa3d5beea6f504f00";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteClusterDRSAction.Result res = action.call();Python
SDK
DeleteClusterDRSAction action = DeleteClusterDRSAction()
action.uuid = "ff067b9ad438337aa3d5beea6f504f00"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteClusterDRSAction.Result res = action.call()ExecuteDRSScheduling
API Request
URLs
PUT zstack/v1/clusters/drs/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
Note: In the above example, the
{
"executeDRSScheduling": {},
"systemTags": [],
"userTags": []
}
Note: In the above example, the 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 PUT -d '{"executeDRSScheduling":{}}' \
http://localhost:8080/zstack/v1/clusters/drs/ff067b9ad438337aa3d5beea6f504f00/actionsParameter List
| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The UUID of the Cluster DRS, not the Cluster UUID | 4.0.0 | |
| systemTags (Optional) | List | body | System tags | 4.0.0 | |
| userTags (Optional) | List | body | User tags | 4.0.0 |
API Response
On success, this API returns an empty JSON structure
{}. On failure, the returned JSON structure contains 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 Examples
Java
SDK
ExecuteDRSSchedulingAction action = new ExecuteDRSSchedulingAction();
action.uuid = "ff067b9ad438337aa3d5beea6f504f00";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ExecuteDRSSchedulingAction.Result res = action.call();Python
SDK
ExecuteDRSSchedulingAction action = ExecuteDRSSchedulingAction()
action.uuid = "ff067b9ad438337aa3d5beea6f504f00"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ExecuteDRSSchedulingAction.Result res = action.call()UpdateClusterDRS
API Request
URLs
PUT zstack/v1/clusters/drs/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
Note: In the above example, the
{
"updateClusterDRS": {
"name": "Test",
"description": "Test",
"automationLevel": "Manual",
"thresholdDuration": 10,
"state": "Enabled"
},
"systemTags": [],
"userTags": []
}
Note: In the above example, the 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 PUT -d '{"updateClusterDRS":{"name":"Test","description":"Test","automationLevel":"Manual","thresholdDuration":10,"state":"Enabled"}}' \
http://localhost:8080/zstack/v1/clusters/drs/ff067b9ad438337aa3d5beea6f504f00/actionsParameter List
| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The UUID of the Cluster DRS. Uniquely identifies the resource. | 4.0.0 | |
| name (Optional) | String | body(included in the updateClusterDRS structure) |
The resource name | 4.0.0 | |
| description (Optional) | String | body(included in the updateClusterDRS structure) |
The detailed description of the resource | 4.0.0 | |
| automationLevel (Optional) | String | body(included in the updateClusterDRS structure) |
Whether scheduling is triggered manually or automatically |
|
4.0.0 |
| thresholds (Optional) | List | body(included in the updateClusterDRS structure) |
The threshold criteria | 4.0.0 | |
| thresholdDuration (Optional) | Integer | body(included in the updateClusterDRS structure) |
The threshold evaluation duration. The system queries the workload data for the period from the current time back to thresholdDuration, calculates the result, and compares it with the threshold to determine whether the Cluster requires scheduling. | 4.0.0 | |
| state (Optional) | String | body(included in the updateClusterDRS structure) |
The enabled state of the Cluster DRS |
|
4.0.0 |
| systemTags (Optional) | List | body | System tags | 4.0.0 | |
| userTags (Optional) | List | body | User tags | 4.0.0 |
API Response
On success, this API returns an empty JSON structure
{}. On failure, the returned JSON structure contains 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 Examples
Java
SDK
UpdateClusterDRSAction action = new UpdateClusterDRSAction();
action.uuid = "ff067b9ad438337aa3d5beea6f504f00";
action.name = "Test";
action.description = "Test";
action.automationLevel = "Manual";
action.thresholdDuration = 10;
action.state = "Enabled";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateClusterDRSAction.Result res = action.call();Python
SDK
UpdateClusterDRSAction action = UpdateClusterDRSAction()
action.uuid = "ff067b9ad438337aa3d5beea6f504f00"
action.name = "Test"
action.description = "Test"
action.automationLevel = "Manual"
action.thresholdDuration = 10
action.state = "Enabled"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateClusterDRSAction.Result res = action.call()ValidateClusterSupportDRS
API Request
URLs
GET zstack/v1/clusters/{clusterUuid}/drs/validHeaders
Authorization: OAuth the-session-uuidCurl Example
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/clusters/ff0bcb94de7a3567b641d3fde2329d00/drs/validParameter List
| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| clusterUuid | String | url | The Cluster UUID, not the Cluster DRS UUID | 4.0.0 | |
| systemTags (Optional) | List | query | System tags | 4.0.0 | |
| userTags (Optional) | List | query | User tags | 4.0.0 |
API Response
On success, this API returns an empty JSON structure
{}. On failure, the returned JSON structure contains 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 Examples
Java
SDK
ValidateClusterSupportDRSAction action = new ValidateClusterSupportDRSAction();
action.clusterUuid = "ff0bcb94de7a3567b641d3fde2329d00";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ValidateClusterSupportDRSAction.Result res = action.call();Python
SDK
ValidateClusterSupportDRSAction action = ValidateClusterSupportDRSAction()
action.clusterUuid = "ff0bcb94de7a3567b641d3fde2329d00"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ValidateClusterSupportDRSAction.Result res = action.call()