动态资源调度策略相关接口

获取集群DRS详情(GetClusterDRSStatus)

API请求

URLs
GET zstack/v1/clusters/drs/status
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/clusters/drs/status
参数列表
名字 类型 位置 描述 可选值 起始版本
drsUuid String query 集群DRS的UUID 4.0.0
systemTags (可选) List query 系统标签 4.0.0
userTags (可选) List query 用户标签 4.0.0

API返回

该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
	"error": {
		"code": "SYS.1001",
		"description": "A message or a operation timeout",
		"details": "Create VM on KVM timeout after 300s"
	}
}

SDK示例

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

查询集群DRS(QueryClusterDRS)

API请求

URLs
GET zstack/v1/clusters/drs
GET zstack/v1/clusters/drs/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/clusters/drs
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/clusters/drs/aaa6a44233d23decb16c085599167233

可查询字段

运行CLI命令行工具,输入QueryClusterDRS并按Tab键查看所有可查询字段以及可跨表查询的资源名。

API返回

该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
	"error": {
		"code": "SYS.1001",
		"description": "A message or a operation timeout",
		"details": "Create VM on KVM timeout after 300s"
	}
}

SDK示例

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

查询集群DRS调度建议(QueryDRSAdvice)

API请求

URLs
GET zstack/v1/clusters/drs/advice
GET zstack/v1/clusters/drs/advice/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/clusters/drs/advice
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/clusters/drs/advice/e0f394447d143aceb0dc96ec0373a4cb

可查询字段

运行CLI命令行工具,输入QueryClusterDRS并按Tab键查看所有可查询字段以及可跨表查询的资源名。

API返回

该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
	"error": {
		"code": "SYS.1001",
		"description": "A message or a operation timeout",
		"details": "Create VM on KVM timeout after 300s"
	}
}

SDK示例

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

查询集群DRS调度任务(QueryDRSVmMigrationActivity)

API请求

URLs
GET zstack/v1/clusters/drs/vm-migration-activities
GET zstack/v1/clusters/drs/vm-migration-activities/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/clusters/drs/vm-migration-activities
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/clusters/drs/vm-migration-activities/757ecbe2929e3ad7b5935c6b38229279

可查询字段

运行CLI命令行工具,输入QueryClusterDRS并按Tab键查看所有可查询字段以及可跨表查询的资源名。

API返回

该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
	"error": {
		"code": "SYS.1001",
		"description": "A message or a operation timeout",
		"details": "Create VM on KVM timeout after 300s"
	}
}

SDK示例

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

应用DRS建议(ApplyDRSAdvice)

API请求

URLs
PUT zstack/v1/clusters/drs/advice/{adviceUuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "applyDRSAdvice": {},
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
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/actions
参数列表
名字 类型 位置 描述 可选值 起始版本
adviceUuid String url DRS调度建议UUID 4.0.0
systemTags (可选) List body 系统标签 4.0.0
userTags (可选) List body 用户标签 4.0.0

API返回

该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
	"error": {
		"code": "SYS.1001",
		"description": "A message or a operation timeout",
		"details": "Create VM on KVM timeout after 300s"
	}
}

SDK示例

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

创建集群DRS(CreateClusterDRS)

API请求

URLs
POST zstack/v1/clusters/{clusterUuid}/drs
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "name": "test",
    "automationLevel": "Automatic",
    "thresholds": [
      {
        "thresholdName": "cpuUsedPercentThreshold",
        "thresholdValue": "90",
        "operator": "\u003e\u003d"
      }
    ],
    "thresholdDuration": 10,
    "defaultEnable": true
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
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/drs
参数列表
名字 类型 位置 描述 可选值 起始版本
name String body(包含在params结构中) 资源名称 4.0.0
description (可选) String body(包含在params结构中) 资源的详细描述 4.0.0
clusterUuid String url 集群UUID 4.0.0
automationLevel String body(包含在params结构中) 调度是手动触发还是自动触发
  • Automatic
  • Manual
4.0.0
thresholds List body(包含在params结构中) 阈值判断项目 4.0.0
thresholdDuration Integer body(包含在params结构中) 阈值判断时长。系统将查询从现在往前 thresholdDuration 的时段的负载数据进行统计,算出的结果和阈值比较来判断集群是否需要调度 4.0.0
defaultEnable (可选) boolean body(包含在params结构中) 集群DRS的启用状态,刚创建完是启用还是禁用 4.0.0
resourceUuid (可选) String body(包含在params结构中) 资源UUID 4.0.0
tagUuids (可选) List body(包含在params结构中) 标签UUID列表 3.4.0
systemTags (可选) List body 系统标签 4.0.0
userTags (可选) List body 用户标签 4.0.0

API返回

该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
	"error": {
		"code": "SYS.1001",
		"description": "A message or a operation timeout",
		"details": "Create VM on KVM timeout after 300s"
	}
}

SDK示例

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

删除集群DRS(DeleteClusterDRS)

API请求

URLs
DELETE zstack/v1/clusters/drs/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/clusters/drs/ff067b9ad438337aa3d5beea6f504f00
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 资源的UUID,唯一标示该资源 4.0.0
deleteMode (可选) String body 删除模式(Permissive / Enforcing,Permissive) 4.0.0
systemTags (可选) List body 系统标签 4.0.0
userTags (可选) List body 用户标签 4.0.0

API返回

该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
	"error": {
		"code": "SYS.1001",
		"description": "A message or a operation timeout",
		"details": "Create VM on KVM timeout after 300s"
	}
}

SDK示例

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

执行DRS调度(ExecuteDRSScheduling)

API请求

URLs
PUT zstack/v1/clusters/drs/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "executeDRSScheduling": {},
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
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/actions
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 集群DRS的UUID,不是集群UUID 4.0.0
systemTags (可选) List body 系统标签 4.0.0
userTags (可选) List body 用户标签 4.0.0

API返回

该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
	"error": {
		"code": "SYS.1001",
		"description": "A message or a operation timeout",
		"details": "Create VM on KVM timeout after 300s"
	}
}

SDK示例

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

更新集群DRS(UpdateClusterDRS)

API请求

URLs
PUT zstack/v1/clusters/drs/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "updateClusterDRS": {
    "name": "Test",
    "description": "Test",
    "automationLevel": "Manual",
    "thresholdDuration": 10,
    "state": "Enabled"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
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/actions
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 集群DRS的UUID,唯一标示该资源 4.0.0
name (可选) String body(包含在updateClusterDRS结构中) 资源名称 4.0.0
description (可选) String body(包含在updateClusterDRS结构中) 资源的详细描述 4.0.0
automationLevel (可选) String body(包含在updateClusterDRS结构中) 调度是手动触发还是自动触发
  • Automatic
  • Manual
4.0.0
thresholds (可选) List body(包含在updateClusterDRS结构中) 阈值判断项目 4.0.0
thresholdDuration (可选) Integer body(包含在updateClusterDRS结构中) 阈值判断时长。系统将查询从现在往前 thresholdDuration 的时段的负载数据进行统计,算出的结果和阈值比较来判断集群是否需要调度 4.0.0
state (可选) String body(包含在updateClusterDRS结构中) 集群DRS的启用状态
  • Enabled
  • Disabled
4.0.0
systemTags (可选) List body 系统标签 4.0.0
userTags (可选) List body 用户标签 4.0.0

API返回

该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
	"error": {
		"code": "SYS.1001",
		"description": "A message or a operation timeout",
		"details": "Create VM on KVM timeout after 300s"
	}
}

SDK示例

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

查看集群是否支持DRS(ValidateClusterSupportDRS)

API请求

URLs
GET zstack/v1/clusters/{clusterUuid}/drs/valid
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/clusters/ff0bcb94de7a3567b641d3fde2329d00/drs/valid
参数列表
名字 类型 位置 描述 可选值 起始版本
clusterUuid String url 集群UUID,不是集群DRS的UUID 4.0.0
systemTags (可选) List query 系统标签 4.0.0
userTags (可选) List query 用户标签 4.0.0

API返回

该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
	"error": {
		"code": "SYS.1001",
		"description": "A message or a operation timeout",
		"details": "Create VM on KVM timeout after 300s"
	}
}

SDK示例

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()
开发手册 | ZStack ZSphere · ZVF | ZStack 资源中心