创建集群DRS
Headers
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "test",
"automationLevel": "Automatic",
"thresholds": [
{
"thresholdName": "cpuUsedPercentThreshold",
"thresholdValue": "90",
"operator": ">="
}
],
"thresholdDuration": 10,
"defaultEnable": true
},
"systemTags": [],
"userTags": []
}上述示例中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(包含在 | 资源名称 |
| 4.0.0 |
description (可选) | String | body(包含在 | 资源的详细描述 |
| 4.0.0 |
clusterUuid | String | url | 集群UUID |
| 4.0.0 |
automationLevel | String | body(包含在 | 调度是手动触发还是自动触发 |
| 4.0.0 |
thresholds | List | body(包含在 | 阈值判断项目 |
| 4.0.0 |
thresholdDuration | Integer | body(包含在 | 阈值判断时长。系统将查询从现在往前 thresholdDuration 的时段的负载数据进行统计,算出的结果和阈值比较来判断集群是否需要调度 |
| 4.0.0 |
defaultEnable (可选) | boolean | body(包含在 | 集群DRS的启用状态,刚创建完是启用还是禁用 |
| 4.0.0 |
resourceUuid (可选) | String | body(包含在 | 资源UUID |
| 4.0.0 |
tagUuids (可选) | List | body(包含在 | 标签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()