弹性伸缩组相关接口
创建弹性伸缩组(CreateAutoScalingGroup)
API请求
URLs
POST zstack/v1/autoscaling/groupsHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "test-group",
"description": "just for test",
"scalingResourceType": "VmInstance",
"minResourceSize": 2.0,
"maxResourceSize": 10.0,
"defaultCooldown": 60.0,
"removalPolicy": "OldestInstance",
"defaultEnable": false
},
"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-group","description":"just for test","scalingResourceType":"VmInstance","minResourceSize":2.0,"maxResourceSize":10.0,"defaultCooldown":60.0,"removalPolicy":"OldestInstance","defaultEnable":false}}' http://localhost:8080/zstack/v1/autoscaling/groups参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| name | String | body(包含在params结构中) | 资源名称 | 3.1.0 | |
| description (可选) | String | body(包含在params结构中) | 资源的详细描述 | 3.1.0 | |
| scalingResourceType | String | body(包含在params结构中) | 伸缩组伸缩资源类型,目前只支持云主机 |
|
3.1.0 |
| minResourceSize | Integer | body(包含在params结构中) | 伸缩组内云主机最少数量 | 3.1.0 | |
| maxResourceSize | Integer | body(包含在params结构中) | 伸缩组内云主机最多数量 | 3.1.0 | |
| defaultCooldown | Long | body(包含在params结构中) | 伸缩组规则默认冷却时间 | 3.1.0 | |
| removalPolicy | String | body(包含在params结构中) | 删除云主机规则 |
|
3.1.0 |
| defaultEnable (可选) | boolean | body(包含在params结构中) | 创建完成后,是否默认启用 | 3.1.0 | |
| resourceUuid (可选) | String | body(包含在params结构中) | 3.1.0 | ||
| tagUuids (可选) | List | body(包含在params结构中) | 标签UUID列表 | 3.1.0 | |
| systemTags (可选) | List | body | 3.1.0 | ||
| userTags (可选) | List | body | 3.1.0 |
API返回
返回示例
{
"inventory": {
"name": "test-group",
"uuid": "ff296e09f82e3a84af082257ff63d162",
"description": "just for test",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.1.0 |
| inventory | AutoScalingGroupInventory | 详情参考inventory | 3.1.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.1.0 |
| description | String | 错误的概要描述 | 3.1.0 |
| details | String | 错误的详细信息 | 3.1.0 |
| elaboration | String | 保留字段,默认为null | 3.1.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.1.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.1.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| name | String | 资源名称 | 3.1.0 |
| uuid | String | 资源的UUID,唯一标示该资源 | 3.1.0 |
| scalingResourceType | String | 伸缩资源类型:云主机 | 3.1.0 |
| state | String | 伸缩组启用状态 | 3.1.0 |
| defaultCooldown | Long | 伸缩规则默认冷却时间 | 3.1.0 |
| description | String | 资源的详细描述 | 3.1.0 |
| minResourceSize | Integer | 伸缩组里最少云主机数量 | 3.1.0 |
| maxResourceSize | Integer | 伸缩组里最多云主机数量 | 3.1.0 |
| removalPolicy | String | 删除云主机默认策略 | 3.1.0 |
| createDate | Timestamp | 创建时间 | 3.1.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.1.0 |
| attachedTemplates | List | 挂载的伸缩组云主机模板列表 | 3.1.0 |
| systemTags | List | 3.1.0 |
SDK示例
Java
SDK
CreateAutoScalingGroupAction action = new CreateAutoScalingGroupAction();
action.name = "test-group";
action.description = "just for test";
action.scalingResourceType = "VmInstance";
action.minResourceSize = 2.0;
action.maxResourceSize = 10.0;
action.defaultCooldown = 60.0;
action.removalPolicy = "OldestInstance";
action.defaultEnable = false;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateAutoScalingGroupAction.Result res = action.call();Python
SDK
CreateAutoScalingGroupAction action = CreateAutoScalingGroupAction()
action.name = "test-group"
action.description = "just for test"
action.scalingResourceType = "VmInstance"
action.minResourceSize = 2.0
action.maxResourceSize = 10.0
action.defaultCooldown = 60.0
action.removalPolicy = "OldestInstance"
action.defaultEnable = false
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateAutoScalingGroupAction.Result res = action.call()删除弹性伸缩组(DeleteAutoScalingGroup)
API请求
URLs
DELETE zstack/v1/autoscaling/groups/{uuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/autoscaling/groups/09121b25fdf330538288d1ac81025563参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 资源的UUID,唯一标示该资源 | 3.1.0 | |
| systemTags (可选) | List | body | 3.1.0 | ||
| userTags (可选) | List | body | 3.1.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
DeleteAutoScalingGroupAction action = new DeleteAutoScalingGroupAction();
action.uuid = "09121b25fdf330538288d1ac81025563";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteAutoScalingGroupAction.Result res = action.call();Python
SDK
DeleteAutoScalingGroupAction action = DeleteAutoScalingGroupAction()
action.uuid = "09121b25fdf330538288d1ac81025563"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteAutoScalingGroupAction.Result res = action.call()修改弹性伸缩组(UpdateAutoScalingGroup)
API请求
URLs
PUT zstack/v1/autoscaling/groups/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"updateAutoScalingGroup": {
"name": "test-group2"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateAutoScalingGroup":{"name":"test-group2"}}' http://localhost:8080/zstack/v1/autoscaling/groups/17a8d07735b631a688d6f95f3323fe91/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 资源的UUID,唯一标示该资源 | 3.1.0 | |
| name (可选) | String | body(包含在updateAutoScalingGroup结构中) | 资源名称 | 3.1.0 | |
| description (可选) | String | body(包含在updateAutoScalingGroup结构中) | 资源的详细描述 | 3.1.0 | |
| minResourceSize (可选) | Integer | body(包含在updateAutoScalingGroup结构中) | 伸缩组内最少云主机数量 | 3.1.0 | |
| maxResourceSize (可选) | Integer | body(包含在updateAutoScalingGroup结构中) | 伸缩组内最大云主机数量 | 3.1.0 | |
| removalPolicy (可选) | String | body(包含在updateAutoScalingGroup结构中) | 删除云主机策略:创建时间最久的主机优先,新创建的云主机优先 |
|
3.1.0 |
| systemTags (可选) | List | body | 3.1.0 | ||
| userTags (可选) | List | body | 3.1.0 |
API返回
返回示例
{
"inventory": {
"name": "test-load-balance-profile",
"uuid": "95f4b920e6b63e318940a44c0f47788e",
"description": "just for test",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.1.0 |
| inventory | AutoScalingGroupInventory | 详情参考inventory | 3.1.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.1.0 |
| description | String | 错误的概要描述 | 3.1.0 |
| details | String | 错误的详细信息 | 3.1.0 |
| elaboration | String | 保留字段,默认为null | 3.1.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.1.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.1.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| name | String | 资源名称 | 3.1.0 |
| uuid | String | 资源的UUID,唯一标示该资源 | 3.1.0 |
| scalingResourceType | String | 伸缩资源类型:云主机 | 3.1.0 |
| state | String | 伸缩组启用状态 | 3.1.0 |
| defaultCooldown | Long | 伸缩规则默认冷却时间 | 3.1.0 |
| description | String | 资源的详细描述 | 3.1.0 |
| minResourceSize | Integer | 伸缩组里最少云主机数量 | 3.1.0 |
| maxResourceSize | Integer | 伸缩组里最多云主机数量 | 3.1.0 |
| removalPolicy | String | 删除云主机默认策略 | 3.1.0 |
| createDate | Timestamp | 创建时间 | 3.1.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.1.0 |
| attachedTemplates | List | 挂载的伸缩组云主机模板列表 | 3.1.0 |
| systemTags | List | 3.1.0 |
SDK示例
Java
SDK
UpdateAutoScalingGroupAction action = new UpdateAutoScalingGroupAction();
action.uuid = "17a8d07735b631a688d6f95f3323fe91";
action.name = "test-group2";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateAutoScalingGroupAction.Result res = action.call();Python
SDK
UpdateAutoScalingGroupAction action = UpdateAutoScalingGroupAction()
action.uuid = "17a8d07735b631a688d6f95f3323fe91"
action.name = "test-group2"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateAutoScalingGroupAction.Result res = action.call()查询弹性伸缩组(QueryAutoScalingGroup)
API请求
URLs
GET /v1/autoscaling/groupsGET /v1/autoscaling/groups/{uuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/autoscaling/groupscurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/autoscaling/groups/88dbb881575e37c78e11e988c6db5f64可查询字段
运行CLI命令行工具,输入QueryAutoScalingGroup并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"name": "test-group2",
"uuid": "ed73d20804873d48bddee627a58ca71a",
"description": "just for test",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.1.0 |
| inventories | List | 详情参考inventories | 3.1.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.1.0 |
| description | String | 错误的概要描述 | 3.1.0 |
| details | String | 错误的详细信息 | 3.1.0 |
| elaboration | String | 保留字段,默认为null | 3.1.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.1.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.1.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| name | String | 资源名称 | 3.1.0 |
| uuid | String | 资源的UUID,唯一标示该资源 | 3.1.0 |
| scalingResourceType | String | 伸缩资源类型:云主机 | 3.1.0 |
| state | String | 伸缩组启用状态 | 3.1.0 |
| defaultCooldown | Long | 伸缩规则默认冷却时间 | 3.1.0 |
| description | String | 资源的详细描述 | 3.1.0 |
| minResourceSize | Integer | 伸缩组里最少云主机数量 | 3.1.0 |
| maxResourceSize | Integer | 伸缩组里最多云主机数量 | 3.1.0 |
| removalPolicy | String | 删除云主机默认策略 | 3.1.0 |
| createDate | Timestamp | 创建时间 | 3.1.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.1.0 |
| attachedTemplates | List | 挂载的伸缩组云主机模板列表 | 3.1.0 |
| systemTags | List | 3.1.0 |
SDK示例
Java
SDK
QueryAutoScalingGroupAction action = new QueryAutoScalingGroupAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryAutoScalingGroupAction.Result res = action.call();Python
SDK
QueryAutoScalingGroupAction action = QueryAutoScalingGroupAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryAutoScalingGroupAction.Result res = action.call()查询弹性伸缩组活动列表(QueryAutoScalingGroupActivity)
API请求
URLs
GET zstack/v1/autoscaling/groups/activitiesGET zstack/v1/autoscaling/groups/activities/{uuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/autoscaling/groups/activitiescurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/autoscaling/groups/activities/e075eb1434203006861a4bd00453f69f可查询字段
运行CLI命令行工具,输入QueryAutoScalingGroupActivity并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"uuid": "036f189a51633ec5bfa2f7e77ec1f5ac",
"description": "just for test",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.1.0 |
| inventories | List | 详情参考inventories | 3.1.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.1.0 |
| description | String | 错误的概要描述 | 3.1.0 |
| details | String | 错误的详细信息 | 3.1.0 |
| elaboration | String | 保留字段,默认为null | 3.1.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.1.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.1.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.1.0 |
| name | String | 资源名称 | 3.1.0 |
| scalingGroupUuid | String | 伸缩组UUID | 3.1.0 |
| activityAction | String | 伸缩活动类型 | 3.1.0 |
| scalingGroupRuleUuid | String | 伸缩规则UUID | 3.1.0 |
| cause | String | 触发伸缩活动的原因 | 3.1.0 |
| description | String | 活动详细描述 | 3.1.0 |
| status | String | 伸缩活动状态 | 3.1.0 |
| activityActionResultMessage | String | 伸缩活动执行结果 | 3.1.0 |
| endDate | Timestamp | 伸缩活动执行结束时间 | 3.1.0 |
| createDate | Timestamp | 伸缩活动创建时间 | 3.1.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.1.0 |
SDK示例
Java
SDK
QueryAutoScalingGroupActivityAction action = new QueryAutoScalingGroupActivityAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryAutoScalingGroupActivityAction.Result res = action.call();Python
SDK
QueryAutoScalingGroupActivityAction action = QueryAutoScalingGroupActivityAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryAutoScalingGroupActivityAction.Result res = action.call()创建伸缩组云主机扩容规则(CreateAutoScalingGroupAddingNewInstanceRule)
API请求
URLs
POST zstack/v1/autoscaling/rules/adding-new-instanceHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"adjustmentType": "PercentChangeInCapacity",
"adjustmentValue": 1.0,
"name": "addingNewInstance",
"description": "just for test",
"autoScalingGroupUuid": "9e5900b0682d3eb8868637b455567cbd",
"cooldown": 10.0
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"adjustmentType":"PercentChangeInCapacity","adjustmentValue":1.0,"name":"addingNewInstance","description":"just for test","autoScalingGroupUuid":"9e5900b0682d3eb8868637b455567cbd","cooldown":10.0}}' http://localhost:8080/zstack/v1/autoscaling/rules/adding-new-instance参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| adjustmentType | String | body(包含在params结构中) | 扩容方式:增加指定数量云主机,按百分比增加云主机,增加云主机数量到指定值 |
|
3.1.0 |
| adjustmentValue | Integer | body(包含在params结构中) | 增加大小 | 3.1.0 | |
| name | String | body(包含在params结构中) | 资源名称 | 3.1.0 | |
| description (可选) | String | body(包含在params结构中) | 资源的详细描述 | 3.1.0 | |
| autoScalingGroupUuid | String | body(包含在params结构中) | 伸缩组UUID | 3.1.0 | |
| type (可选) | String | body(包含在params结构中) | 伸缩规则类型 | 3.1.0 | |
| cooldown (可选) | Long | body(包含在params结构中) | 伸缩规则触发后的冷却时间 | 3.1.0 | |
| resourceUuid (可选) | String | body(包含在params结构中) | 3.1.0 | ||
| tagUuids (可选) | List | body(包含在params结构中) | 标签UUID列表 | 3.1.0 | |
| systemTags (可选) | List | body | 3.1.0 | ||
| userTags (可选) | List | body | 3.1.0 |
API返回
返回示例
{
"inventory": {
"type": "HealthProfile",
"description": "just for test",
"cooldown": 10.0,
"state": "Enabled",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM",
"name": "test-health-policy",
"uuid": "f41b2b0ae44637a2af1985e362dc52d4"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.1.0 |
| inventory | AutoScalingRuleInventory | 详情参考inventory | 3.1.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.1.0 |
| description | String | 错误的概要描述 | 3.1.0 |
| details | String | 错误的详细信息 | 3.1.0 |
| elaboration | String | 保留字段,默认为null | 3.1.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.1.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.1.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| type | String | 伸缩组规则类型 | 3.1.0 |
| description | String | 资源的详细描述 | 3.1.0 |
| cooldown | Long | 冷却时间 | 3.1.0 |
| systemTags | List | 3.1.0 | |
| createDate | Timestamp | 创建时间 | 3.1.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.1.0 |
| name | String | 资源名称 | 3.1.0 |
| uuid | String | 资源的UUID,唯一标示该资源 | 3.1.0 |
| scalingGroupUuid | String | 3.1.0 | |
| state | AutoScalingRuleState | 详情参考state | 3.1.0 |
| status | AutoScalingRuleStatus | 详情参考status | 3.1.0 |
| ruleTriggers | List | 详情参考ruleTriggers | 3.1.0 |
#state
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| Enabled | AutoScalingRuleState | 启用状态 | 3.1.0 |
| Disabled | AutoScalingRuleState | 关闭状态 | 3.1.0 |
#status
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| Created | AutoScalingRuleStatus | 已创建 | 3.1.0 |
| WaitingForTrigger | AutoScalingRuleStatus | 等待触发 | 3.1.0 |
| Triggering | AutoScalingRuleStatus | 已触发 | 3.1.0 |
| Error | AutoScalingRuleStatus | 3.1.0 |
#ruleTriggers
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| name | String | 资源名称 | 3.1.0 |
| uuid | String | 资源的UUID,唯一标示该资源 | 3.1.0 |
| type | String | 触发器类型 | 3.1.0 |
| ruleUuid | String | 伸缩规则UUID | 3.1.0 |
| description | String | 资源的详细描述 | 3.1.0 |
| state | String | 触发器状态 | 3.1.0 |
| createDate | Timestamp | 创建时间 | 3.1.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.1.0 |
SDK示例
Java
SDK
CreateAutoScalingGroupAddingNewInstanceRuleAction action = new CreateAutoScalingGroupAddingNewInstanceRuleAction();
action.adjustmentType = "PercentChangeInCapacity";
action.adjustmentValue = 1.0;
action.name = "addingNewInstance";
action.description = "just for test";
action.autoScalingGroupUuid = "9e5900b0682d3eb8868637b455567cbd";
action.cooldown = 10.0;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateAutoScalingGroupAddingNewInstanceRuleAction.Result res = action.call();Python
SDK
CreateAutoScalingGroupAddingNewInstanceRuleAction action = CreateAutoScalingGroupAddingNewInstanceRuleAction()
action.adjustmentType = "PercentChangeInCapacity"
action.adjustmentValue = 1.0
action.name = "addingNewInstance"
action.description = "just for test"
action.autoScalingGroupUuid = "9e5900b0682d3eb8868637b455567cbd"
action.cooldown = 10.0
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateAutoScalingGroupAddingNewInstanceRuleAction.Result res = action.call()创建伸缩组云主机缩容规则(CreateAutoScalingGroupRemovalInstanceRule)
API请求
URLs
POST zstack/v1/autoscaling/rules/removal-instanceHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"adjustmentType": "PercentChangeInCapacity",
"adjustmentValue": 1.0,
"removalPolicy": "MinimumMemoryUsageInstance",
"name": "removalInstance",
"description": "just for test",
"autoScalingGroupUuid": "8a8070f9926733478acad7bf0ba60a63",
"cooldown": 10.0
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"adjustmentType":"PercentChangeInCapacity","adjustmentValue":1.0,"removalPolicy":"MinimumMemoryUsageInstance","name":"removalInstance","description":"just for test","autoScalingGroupUuid":"8a8070f9926733478acad7bf0ba60a63","cooldown":10.0}}' http://localhost:8080/zstack/v1/autoscaling/rules/removal-instance参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| adjustmentType | String | body(包含在params结构中) | 缩容方式:减少指定数量云主机,按百分比减少云主机,减少云主机数量到指定值 |
|
3.1.0 |
| adjustmentValue | Integer | body(包含在params结构中) | 减少数值 | 3.1.0 | |
| removalPolicy | String | body(包含在params结构中) | 删除云主机策略 |
|
3.1.0 |
| name | String | body(包含在params结构中) | 资源名称 | 3.1.0 | |
| description (可选) | String | body(包含在params结构中) | 资源的详细描述 | 3.1.0 | |
| autoScalingGroupUuid | String | body(包含在params结构中) | 伸缩组UUID | 3.1.0 | |
| type (可选) | String | body(包含在params结构中) | 伸缩规则类型 | 3.1.0 | |
| cooldown (可选) | Long | body(包含在params结构中) | 伸缩规则触发后的冷却时间 | 3.1.0 | |
| resourceUuid (可选) | String | body(包含在params结构中) | 3.1.0 | ||
| tagUuids (可选) | List | body(包含在params结构中) | 标签UUID列表 | 3.1.0 | |
| systemTags (可选) | List | body | 3.1.0 | ||
| userTags (可选) | List | body | 3.1.0 |
API返回
返回示例
{
"inventory": {
"type": "HealthProfile",
"description": "just for test",
"cooldown": 10.0,
"state": "Enabled",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM",
"name": "test-health-policy",
"uuid": "f41b2b0ae44637a2af1985e362dc52d4"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.1.0 |
| inventory | AutoScalingRuleInventory | 详情参考inventory | 3.1.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.1.0 |
| description | String | 错误的概要描述 | 3.1.0 |
| details | String | 错误的详细信息 | 3.1.0 |
| elaboration | String | 保留字段,默认为null | 3.1.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.1.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.1.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| type | String | 伸缩组规则类型 | 3.1.0 |
| description | String | 资源的详细描述 | 3.1.0 |
| cooldown | Long | 冷却时间 | 3.1.0 |
| systemTags | List | 3.1.0 | |
| createDate | Timestamp | 创建时间 | 3.1.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.1.0 |
| name | String | 资源名称 | 3.1.0 |
| uuid | String | 资源的UUID,唯一标示该资源 | 3.1.0 |
| scalingGroupUuid | String | 3.1.0 | |
| state | AutoScalingRuleState | 详情参考state | 3.1.0 |
| status | AutoScalingRuleStatus | 详情参考status | 3.1.0 |
| ruleTriggers | List | 详情参考ruleTriggers | 3.1.0 |
#state
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| Enabled | AutoScalingRuleState | 启用状态 | 3.1.0 |
| Disabled | AutoScalingRuleState | 关闭状态 | 3.1.0 |
#status
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| Created | AutoScalingRuleStatus | 已创建 | 3.1.0 |
| WaitingForTrigger | AutoScalingRuleStatus | 等待触发 | 3.1.0 |
| Triggering | AutoScalingRuleStatus | 已触发 | 3.1.0 |
| Error | AutoScalingRuleStatus | 3.1.0 |
#ruleTriggers
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| name | String | 资源名称 | 3.1.0 |
| uuid | String | 资源的UUID,唯一标示该资源 | 3.1.0 |
| type | String | 触发器类型 | 3.1.0 |
| ruleUuid | String | 伸缩规则UUID | 3.1.0 |
| description | String | 资源的详细描述 | 3.1.0 |
| state | String | 触发器状态 | 3.1.0 |
| createDate | Timestamp | 创建时间 | 3.1.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.1.0 |
SDK示例
Java
SDK
CreateAutoScalingGroupRemovalInstanceRuleAction action = new CreateAutoScalingGroupRemovalInstanceRuleAction();
action.adjustmentType = "PercentChangeInCapacity";
action.adjustmentValue = 1.0;
action.removalPolicy = "MinimumMemoryUsageInstance";
action.name = "removalInstance";
action.description = "just for test";
action.autoScalingGroupUuid = "8a8070f9926733478acad7bf0ba60a63";
action.cooldown = 10.0;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateAutoScalingGroupRemovalInstanceRuleAction.Result res = action.call();Python
SDK
CreateAutoScalingGroupRemovalInstanceRuleAction action = CreateAutoScalingGroupRemovalInstanceRuleAction()
action.adjustmentType = "PercentChangeInCapacity"
action.adjustmentValue = 1.0
action.removalPolicy = "MinimumMemoryUsageInstance"
action.name = "removalInstance"
action.description = "just for test"
action.autoScalingGroupUuid = "8a8070f9926733478acad7bf0ba60a63"
action.cooldown = 10.0
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateAutoScalingGroupRemovalInstanceRuleAction.Result res = action.call()删除伸缩规则(DeleteAutoScalingRule)
API请求
URLs
DELETE zstack/v1/autoscaling/rules/{uuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/autoscaling/rules/55774c4baaea33c4a47b16c772446077参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 伸缩规则UUID | 3.1.0 | |
| systemTags (可选) | List | body | 3.1.0 | ||
| userTags (可选) | List | body | 3.1.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
DeleteAutoScalingRuleAction action = new DeleteAutoScalingRuleAction();
action.uuid = "55774c4baaea33c4a47b16c772446077";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteAutoScalingRuleAction.Result res = action.call();Python
SDK
DeleteAutoScalingRuleAction action = DeleteAutoScalingRuleAction()
action.uuid = "55774c4baaea33c4a47b16c772446077"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteAutoScalingRuleAction.Result res = action.call()修改弹性伸缩组规则(UpdateAutoScalingRule)
API请求
URLs
PUT zstack/v1/autoscaling/rules/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"updateAutoScalingRule": {
"name": "test name2"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateAutoScalingRule":{"name":"test name2"}}' http://localhost:8080/zstack/v1/autoscaling/rules/4e8be98cd3a93176b9d38f3f934f1c2a/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 资源的UUID,唯一标示该资源 | 3.1.0 | |
| name (可选) | String | body(包含在updateAutoScalingRule结构中) | 资源名称 | 3.1.0 | |
| description (可选) | String | body(包含在updateAutoScalingRule结构中) | 资源的详细描述 | 3.1.0 | |
| cooldown (可选) | Long | body(包含在updateAutoScalingRule结构中) | 冷却时间 | 3.1.0 | |
| systemTags (可选) | List | body | 3.1.0 | ||
| userTags (可选) | List | body | 3.1.0 |
API返回
返回示例
{
"inventory": {
"type": "HealthProfile",
"description": "just for test",
"cooldown": 10.0,
"state": "Enabled",
"status": "Created",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM",
"name": "test name2",
"uuid": "39009f21b4a035c08db6cbff4ebe276c"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.1.0 |
| inventory | AutoScalingRuleInventory | 详情参考inventory | 3.1.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.1.0 |
| description | String | 错误的概要描述 | 3.1.0 |
| details | String | 错误的详细信息 | 3.1.0 |
| elaboration | String | 保留字段,默认为null | 3.1.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.1.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.1.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| type | String | 伸缩组规则类型 | 3.1.0 |
| description | String | 资源的详细描述 | 3.1.0 |
| cooldown | Long | 冷却时间 | 3.1.0 |
| systemTags | List | 3.1.0 | |
| createDate | Timestamp | 创建时间 | 3.1.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.1.0 |
| name | String | 资源名称 | 3.1.0 |
| uuid | String | 资源的UUID,唯一标示该资源 | 3.1.0 |
| scalingGroupUuid | String | 3.1.0 | |
| state | AutoScalingRuleState | 详情参考state | 3.1.0 |
| status | AutoScalingRuleStatus | 详情参考status | 3.1.0 |
| ruleTriggers | List | 详情参考ruleTriggers | 3.1.0 |
#state
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| Enabled | AutoScalingRuleState | 启用状态 | 3.1.0 |
| Disabled | AutoScalingRuleState | 关闭状态 | 3.1.0 |
#status
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| Created | AutoScalingRuleStatus | 已创建 | 3.1.0 |
| WaitingForTrigger | AutoScalingRuleStatus | 等待触发 | 3.1.0 |
| Triggering | AutoScalingRuleStatus | 已触发 | 3.1.0 |
| Error | AutoScalingRuleStatus | 3.1.0 |
#ruleTriggers
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| name | String | 资源名称 | 3.1.0 |
| uuid | String | 资源的UUID,唯一标示该资源 | 3.1.0 |
| type | String | 触发器类型 | 3.1.0 |
| ruleUuid | String | 伸缩规则UUID | 3.1.0 |
| description | String | 资源的详细描述 | 3.1.0 |
| state | String | 触发器状态 | 3.1.0 |
| createDate | Timestamp | 创建时间 | 3.1.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.1.0 |
SDK示例
Java
SDK
UpdateAutoScalingRuleAction action = new UpdateAutoScalingRuleAction();
action.uuid = "4e8be98cd3a93176b9d38f3f934f1c2a";
action.name = "test name2";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateAutoScalingRuleAction.Result res = action.call();Python
SDK
UpdateAutoScalingRuleAction action = UpdateAutoScalingRuleAction()
action.uuid = "4e8be98cd3a93176b9d38f3f934f1c2a"
action.name = "test name2"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateAutoScalingRuleAction.Result res = action.call()修改伸缩组扩容规则(UpdateAutoScalingGroupAddingNewInstanceRule)
API请求
URLs
PUT zstack/v1/autoscaling/rules/adding-new-instance/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"updateAutoScalingGroupAddingNewInstanceRule": {
"name": "test name2"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateAutoScalingGroupAddingNewInstanceRule":{"name":"test name2"}}' http://localhost:8080/zstack/v1/autoscaling/rules/adding-new-instance/e61646c51ac1396fb6d7d413dc5de3f8/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| adjustmentType (可选) | String | body(包含在updateAutoScalingGroupAddingNewInstanceRule结构中) | 扩容方式:减少指定数量云主机,按百分比减少云主机,减少云主机数量到指定值 |
|
3.1.0 |
| adjustmentValue (可选) | Integer | body(包含在updateAutoScalingGroupAddingNewInstanceRule结构中) | 扩容数值 | 3.1.0 | |
| uuid | String | url | 资源的UUID,唯一标示该资源 | 3.1.0 | |
| name (可选) | String | body(包含在updateAutoScalingGroupAddingNewInstanceRule结构中) | 资源名称 | 3.1.0 | |
| description (可选) | String | body(包含在updateAutoScalingGroupAddingNewInstanceRule结构中) | 资源的详细描述 | 3.1.0 | |
| cooldown (可选) | Long | body(包含在updateAutoScalingGroupAddingNewInstanceRule结构中) | 冷却时间 | 3.1.0 | |
| systemTags (可选) | List | body | 3.1.0 | ||
| userTags (可选) | List | body | 3.1.0 |
API返回
返回示例
{
"inventory": {
"type": "HealthProfile",
"description": "just for test",
"cooldown": 10.0,
"state": "Enabled",
"status": "Created",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM",
"name": "test name2",
"uuid": "39009f21b4a035c08db6cbff4ebe276c"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.1.0 |
| inventory | AutoScalingRuleInventory | 详情参考inventory | 3.1.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.1.0 |
| description | String | 错误的概要描述 | 3.1.0 |
| details | String | 错误的详细信息 | 3.1.0 |
| elaboration | String | 保留字段,默认为null | 3.1.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.1.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.1.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| type | String | 伸缩组规则类型 | 3.1.0 |
| description | String | 资源的详细描述 | 3.1.0 |
| cooldown | Long | 冷却时间 | 3.1.0 |
| systemTags | List | 3.1.0 | |
| createDate | Timestamp | 创建时间 | 3.1.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.1.0 |
| name | String | 资源名称 | 3.1.0 |
| uuid | String | 资源的UUID,唯一标示该资源 | 3.1.0 |
| scalingGroupUuid | String | 3.1.0 | |
| state | AutoScalingRuleState | 详情参考state | 3.1.0 |
| status | AutoScalingRuleStatus | 详情参考status | 3.1.0 |
| ruleTriggers | List | 详情参考ruleTriggers | 3.1.0 |
#state
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| Enabled | AutoScalingRuleState | 启用状态 | 3.1.0 |
| Disabled | AutoScalingRuleState | 关闭状态 | 3.1.0 |
#status
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| Created | AutoScalingRuleStatus | 已创建 | 3.1.0 |
| WaitingForTrigger | AutoScalingRuleStatus | 等待触发 | 3.1.0 |
| Triggering | AutoScalingRuleStatus | 已触发 | 3.1.0 |
| Error | AutoScalingRuleStatus | 3.1.0 |
#ruleTriggers
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| name | String | 资源名称 | 3.1.0 |
| uuid | String | 资源的UUID,唯一标示该资源 | 3.1.0 |
| type | String | 触发器类型 | 3.1.0 |
| ruleUuid | String | 伸缩规则UUID | 3.1.0 |
| description | String | 资源的详细描述 | 3.1.0 |
| state | String | 触发器状态 | 3.1.0 |
| createDate | Timestamp | 创建时间 | 3.1.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.1.0 |
SDK示例
Java
SDK
UpdateAutoScalingGroupAddingNewInstanceRuleAction action = new UpdateAutoScalingGroupAddingNewInstanceRuleAction();
action.uuid = "e61646c51ac1396fb6d7d413dc5de3f8";
action.name = "test name2";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateAutoScalingGroupAddingNewInstanceRuleAction.Result res = action.call();Python
SDK
UpdateAutoScalingGroupAddingNewInstanceRuleAction action = UpdateAutoScalingGroupAddingNewInstanceRuleAction()
action.uuid = "e61646c51ac1396fb6d7d413dc5de3f8"
action.name = "test name2"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateAutoScalingGroupAddingNewInstanceRuleAction.Result res = action.call()修改伸缩组缩容规则(UpdateAutoScalingGroupRemovalInstanceRule)
API请求
URLs
PUT zstack/v1/autoscaling/rules/removal-instance/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"updateAutoScalingGroupRemovalInstanceRule": {
"name": "test name2"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateAutoScalingGroupRemovalInstanceRule":{"name":"test name2"}}' http://localhost:8080/zstack/v1/autoscaling/rules/removal-instance/66d7d0b81f1c399bb98063dfb0d3beaf/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| adjustmentType (可选) | String | body(包含在updateAutoScalingGroupRemovalInstanceRule结构中) | 缩容方式:减少指定数量云主机,按百分比减少云主机,减少云主机数量到指定值 |
|
3.1.0 |
| adjustmentValue (可选) | Integer | body(包含在updateAutoScalingGroupRemovalInstanceRule结构中) | 缩容数值 | 3.1.0 | |
| removalPolicy (可选) | String | body(包含在updateAutoScalingGroupRemovalInstanceRule结构中) | 删除云主机策略 |
|
3.1.0 |
| uuid | String | url | 资源的UUID,唯一标示该资源 | 3.1.0 | |
| name (可选) | String | body(包含在updateAutoScalingGroupRemovalInstanceRule结构中) | 资源名称 | 3.1.0 | |
| description (可选) | String | body(包含在updateAutoScalingGroupRemovalInstanceRule结构中) | 资源的详细描述 | 3.1.0 | |
| cooldown (可选) | Long | body(包含在updateAutoScalingGroupRemovalInstanceRule结构中) | 冷却时间 | 3.1.0 | |
| systemTags (可选) | List | body | 3.1.0 | ||
| userTags (可选) | List | body | 3.1.0 |
API返回
返回示例
{
"inventory": {
"type": "HealthProfile",
"description": "just for test",
"cooldown": 10.0,
"state": "Enabled",
"status": "Created",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM",
"name": "test name2",
"uuid": "39009f21b4a035c08db6cbff4ebe276c"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.1.0 |
| inventory | AutoScalingRuleInventory | 详情参考inventory | 3.1.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.1.0 |
| description | String | 错误的概要描述 | 3.1.0 |
| details | String | 错误的详细信息 | 3.1.0 |
| elaboration | String | 保留字段,默认为null | 3.1.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.1.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.1.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| type | String | 伸缩组规则类型 | 3.1.0 |
| description | String | 资源的详细描述 | 3.1.0 |
| cooldown | Long | 冷却时间 | 3.1.0 |
| systemTags | List | 3.1.0 | |
| createDate | Timestamp | 创建时间 | 3.1.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.1.0 |
| name | String | 资源名称 | 3.1.0 |
| uuid | String | 资源的UUID,唯一标示该资源 | 3.1.0 |
| scalingGroupUuid | String | 3.1.0 | |
| state | AutoScalingRuleState | 详情参考state | 3.1.0 |
| status | AutoScalingRuleStatus | 详情参考status | 3.1.0 |
| ruleTriggers | List | 详情参考ruleTriggers | 3.1.0 |
#state
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| Enabled | AutoScalingRuleState | 启用状态 | 3.1.0 |
| Disabled | AutoScalingRuleState | 关闭状态 | 3.1.0 |
#status
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| Created | AutoScalingRuleStatus | 已创建 | 3.1.0 |
| WaitingForTrigger | AutoScalingRuleStatus | 等待触发 | 3.1.0 |
| Triggering | AutoScalingRuleStatus | 已触发 | 3.1.0 |
| Error | AutoScalingRuleStatus | 3.1.0 |
#ruleTriggers
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| name | String | 资源名称 | 3.1.0 |
| uuid | String | 资源的UUID,唯一标示该资源 | 3.1.0 |
| type | String | 触发器类型 | 3.1.0 |
| ruleUuid | String | 伸缩规则UUID | 3.1.0 |
| description | String | 资源的详细描述 | 3.1.0 |
| state | String | 触发器状态 | 3.1.0 |
| createDate | Timestamp | 创建时间 | 3.1.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.1.0 |
SDK示例
Java
SDK
UpdateAutoScalingGroupRemovalInstanceRuleAction action = new UpdateAutoScalingGroupRemovalInstanceRuleAction();
action.uuid = "66d7d0b81f1c399bb98063dfb0d3beaf";
action.name = "test name2";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateAutoScalingGroupRemovalInstanceRuleAction.Result res = action.call();Python
SDK
UpdateAutoScalingGroupRemovalInstanceRuleAction action = UpdateAutoScalingGroupRemovalInstanceRuleAction()
action.uuid = "66d7d0b81f1c399bb98063dfb0d3beaf"
action.name = "test name2"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateAutoScalingGroupRemovalInstanceRuleAction.Result res = action.call()查询伸缩规则(QueryAutoScalingRule)
API请求
URLs
GET zstack/v1/autoscaling/groups/rulesGET zstack/v1/autoscaling/groups/rules/{uuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/autoscaling/groups/rulescurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/autoscaling/groups/rules/404fe677c3213e4bbb39d91a2efb3595可查询字段
运行CLI命令行工具,输入QueryAutoScalingRule并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"type": "LoadBalanceProfile",
"description": "just for test",
"cooldown": 100.0,
"state": "Enabled",
"status": "Created",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM",
"name": "test-load-balance-profile",
"uuid": "a0d075cd82c13084b29f93325651fc65"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.1.0 |
| inventories | List | 详情参考inventories | 3.1.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.1.0 |
| description | String | 错误的概要描述 | 3.1.0 |
| details | String | 错误的详细信息 | 3.1.0 |
| elaboration | String | 保留字段,默认为null | 3.1.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.1.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.1.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| type | String | 伸缩组规则类型 | 3.1.0 |
| description | String | 资源的详细描述 | 3.1.0 |
| cooldown | Long | 冷却时间 | 3.1.0 |
| systemTags | List | 3.1.0 | |
| createDate | Timestamp | 创建时间 | 3.1.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.1.0 |
| name | String | 资源名称 | 3.1.0 |
| uuid | String | 资源的UUID,唯一标示该资源 | 3.1.0 |
| scalingGroupUuid | String | 3.1.0 | |
| state | AutoScalingRuleState | 详情参考state | 3.1.0 |
| status | AutoScalingRuleStatus | 详情参考status | 3.1.0 |
| ruleTriggers | List | 详情参考ruleTriggers | 3.1.0 |
#state
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| Enabled | AutoScalingRuleState | 启用状态 | 3.1.0 |
| Disabled | AutoScalingRuleState | 关闭状态 | 3.1.0 |
#status
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| Created | AutoScalingRuleStatus | 已创建 | 3.1.0 |
| WaitingForTrigger | AutoScalingRuleStatus | 等待触发 | 3.1.0 |
| Triggering | AutoScalingRuleStatus | 已触发 | 3.1.0 |
| Error | AutoScalingRuleStatus | 3.1.0 |
#ruleTriggers
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| name | String | 资源名称 | 3.1.0 |
| uuid | String | 资源的UUID,唯一标示该资源 | 3.1.0 |
| type | String | 触发器类型 | 3.1.0 |
| ruleUuid | String | 伸缩规则UUID | 3.1.0 |
| description | String | 资源的详细描述 | 3.1.0 |
| state | String | 触发器状态 | 3.1.0 |
| createDate | Timestamp | 创建时间 | 3.1.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.1.0 |
SDK示例
Java
SDK
QueryAutoScalingRuleAction action = new QueryAutoScalingRuleAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryAutoScalingRuleAction.Result res = action.call();Python
SDK
QueryAutoScalingRuleAction action = QueryAutoScalingRuleAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryAutoScalingRuleAction.Result res = action.call()创建伸缩规则报警触发器(CreateAutoScalingRuleAlarmTrigger)
API请求
URLs
POST zstack/v1/zwatch/alarms/{alarmUuid}/autoscaling/rules/{ruleUuid}Headers
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "createAlarmTrigger"
},
"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":"createAlarmTrigger"}}' http://localhost:8080/zstack/v1/zwatch/alarms/00f142f73b633bf0ab4a1e34aa84062b/autoscaling/rules/14b74127a20634c6b6d3566ef33b0600参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| alarmUuid | String | url | 报警UUID | 3.1.0 | |
| triggerType (可选) | String | body(包含在params结构中) | 触发器类型 | 3.1.0 | |
| name | String | body(包含在params结构中) | 触发器名称 | 3.1.0 | |
| description (可选) | String | body(包含在params结构中) | 资源的详细描述 | 3.1.0 | |
| ruleUuid | String | url | 伸缩规则UUID | 3.1.0 | |
| resourceUuid (可选) | String | body(包含在params结构中) | 3.1.0 | ||
| tagUuids (可选) | List | body(包含在params结构中) | 标签UUID列表 | 3.1.0 | |
| systemTags (可选) | List | body | 3.1.0 | ||
| userTags (可选) | List | body | 3.1.0 |
API返回
返回示例
{
"inventory": {
"name": "test-group",
"uuid": "d09cd777bb863d6bbfe1267b590e947e",
"description": "just for test",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.1.0 |
| inventory | AutoScalingRuleTriggerInventory | 详情参考inventory | 3.1.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.1.0 |
| description | String | 错误的概要描述 | 3.1.0 |
| details | String | 错误的详细信息 | 3.1.0 |
| elaboration | String | 保留字段,默认为null | 3.1.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.1.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.1.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| name | String | 资源名称 | 3.1.0 |
| uuid | String | 资源的UUID,唯一标示该资源 | 3.1.0 |
| type | String | 触发器类型 | 3.1.0 |
| ruleUuid | String | 伸缩规则UUID | 3.1.0 |
| description | String | 资源的详细描述 | 3.1.0 |
| state | String | 触发器状态 | 3.1.0 |
| createDate | Timestamp | 创建时间 | 3.1.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.1.0 |
SDK示例
Java
SDK
CreateAutoScalingRuleAlarmTriggerAction action = new CreateAutoScalingRuleAlarmTriggerAction();
action.alarmUuid = "00f142f73b633bf0ab4a1e34aa84062b";
action.name = "createAlarmTrigger";
action.ruleUuid = "14b74127a20634c6b6d3566ef33b0600";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateAutoScalingRuleAlarmTriggerAction.Result res = action.call();Python
SDK
CreateAutoScalingRuleAlarmTriggerAction action = CreateAutoScalingRuleAlarmTriggerAction()
action.alarmUuid = "00f142f73b633bf0ab4a1e34aa84062b"
action.name = "createAlarmTrigger"
action.ruleUuid = "14b74127a20634c6b6d3566ef33b0600"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateAutoScalingRuleAlarmTriggerAction.Result res = action.call()创建伸缩规则定时任务触发器(CreateAutoScalingRuleSchedulerJobTrigger)
API请求
URLs
POST zstack/v1/scheduler/jobs/{schedulerJobUuid}/autoscaling/rules/{ruleUuid}Headers
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "createAlarmTrigger"
},
"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":"createAlarmTrigger"}}' http://localhost:8080/zstack/v1/scheduler/jobs/2f194775b8ab3e2b912f92a74501a7ea/autoscaling/rules/852f6e9199c439d0861eec939c5fbbe1参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| schedulerJobUuid | String | url | 定时任务Uuid | 4.1.0 | |
| triggerType (可选) | String | body(包含在params结构中) |
触发器类型 | 4.1.0 | |
| name | String | body(包含在params结构中) |
触发器名称 | 4.1.0 | |
| description (可选) | String | body(包含在params结构中) |
资源的详细描述 | 4.1.0 | |
| ruleUuid | String | url | 伸缩规则UUID | 4.1.0 | |
| resourceUuid (可选) | String | body(包含在params结构中) |
资源UUID | 4.1.0 | |
| tagUuids (可选) | List | body(包含在params结构中) |
标签UUID列表 | 4.1.0 | |
| systemTags (可选) | List | body | 系统标签 | 4.1.0 | |
| userTags (可选) | List | body | 用户标签 | 4.1.0 |
API返回
返回示例
{
"inventory": {
"name": "test-group",
"uuid": "d09cd777bb863d6bbfe1267b590e947e",
"description": "just for test",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 4.1.0 |
| inventory | AutoScalingRuleTriggerInventory | 详情参考inventory | 4.1.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 4.1.0 |
| description | String | 错误的概要描述 | 4.1.0 |
| details | String | 错误的详细信息 | 4.1.0 |
| elaboration | String | 保留字段,默认为null | 4.1.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 4.1.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 4.1.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| name | String | 资源名称 | 4.1.0 |
| uuid | String | 资源的UUID,唯一标示该资源 | 4.1.0 |
| type | String | 触发器类型 | 4.1.0 |
| ruleUuid | String | 伸缩规则UUID | 4.1.0 |
| description | String | 资源的详细描述 | 4.1.0 |
| state | String | 触发器状态 | 4.1.0 |
| createDate | Timestamp | 创建时间 | 4.1.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.1.0 |
SDK示例
Java
SDK
CreateAutoScalingRuleSchedulerJobTriggerAction action = new CreateAutoScalingRuleSchedulerJobTriggerAction();
action.schedulerJobUuid = "2f194775b8ab3e2b912f92a74501a7ea";
action.name = "createAlarmTrigger";
action.ruleUuid = "852f6e9199c439d0861eec939c5fbbe1";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateAutoScalingRuleSchedulerJobTriggerAction.Result res = action.call();Python
SDK
CreateAutoScalingRuleSchedulerJobTriggerAction action = CreateAutoScalingRuleSchedulerJobTriggerAction()
action.schedulerJobUuid = "2f194775b8ab3e2b912f92a74501a7ea"
action.name = "createAlarmTrigger"
action.ruleUuid = "852f6e9199c439d0861eec939c5fbbe1"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateAutoScalingRuleSchedulerJobTriggerAction.Result res = action.call()删除伸缩规则触发器(DeleteAutoScalingRuleTrigger)
API请求
URLs
DELETE zstack/v1/autoscaling/groups/rules/triggers/{uuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/autoscaling/groups/rules/triggers/c81896a39caf320d988503625feb5a84参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 资源的UUID,唯一标示该资源 | 3.1.0 | |
| systemTags (可选) | List | body | 3.1.0 | ||
| userTags (可选) | List | body | 3.1.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
DeleteAutoScalingRuleTriggerAction action = new DeleteAutoScalingRuleTriggerAction();
action.uuid = "c81896a39caf320d988503625feb5a84";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteAutoScalingRuleTriggerAction.Result res = action.call();Python
SDK
DeleteAutoScalingRuleTriggerAction action = DeleteAutoScalingRuleTriggerAction()
action.uuid = "c81896a39caf320d988503625feb5a84"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteAutoScalingRuleTriggerAction.Result res = action.call()查询伸缩规则触发器列表(QueryAutoScalingRuleTrigger)
API请求
URLs
GET zstack/v1/autoscaling/groups/rules/triggerGET zstack/v1/autoscaling/groups/rules/trigger/{uuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/autoscaling/groups/rules/triggercurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/autoscaling/groups/rules/trigger/7af20bc1523536289223a7410ca04abd可查询字段
运行CLI命令行工具,输入QueryAutoScalingRuleTrigger并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"name": "test-load-balance-profile",
"uuid": "cf762471646230209faee02b6423625c",
"type": "Alarm",
"description": "just for test",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.1.0 |
| inventories | List | 详情参考inventories | 3.1.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.1.0 |
| description | String | 错误的概要描述 | 3.1.0 |
| details | String | 错误的详细信息 | 3.1.0 |
| elaboration | String | 保留字段,默认为null | 3.1.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.1.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.1.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| name | String | 资源名称 | 3.1.0 |
| uuid | String | 资源的UUID,唯一标示该资源 | 3.1.0 |
| type | String | 触发器类型 | 3.1.0 |
| ruleUuid | String | 伸缩规则UUID | 3.1.0 |
| description | String | 资源的详细描述 | 3.1.0 |
| state | String | 触发器状态 | 3.1.0 |
| createDate | Timestamp | 创建时间 | 3.1.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.1.0 |
SDK示例
Java
SDK
QueryAutoScalingRuleTriggerAction action = new QueryAutoScalingRuleTriggerAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryAutoScalingRuleTriggerAction.Result res = action.call();Python
SDK
QueryAutoScalingRuleTriggerAction action = QueryAutoScalingRuleTriggerAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryAutoScalingRuleTriggerAction.Result res = action.call()创建伸缩组云主机模块(CreateAutoScalingVmTemplate)
API请求
URLs
POST zstack/v1/autoscaling/vmtemplateHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"vmInstanceName": "vm1",
"vmInstanceDescription": "vm1 desc",
"vmInstanceOfferingUuid": "07e435acb1c230d5b328f23e5a840da2",
"imageUuid": "77407eb341e732b2a45ad5bad4a2c76e",
"l3NetworkUuids": [
"93edf15377e233a291fe1ab1c4190241"
],
"vmInstanceType": "UserVm",
"rootDiskOfferingUuid": "85f44fe072733d90becb4ddd8a9867de",
"dataDiskOfferingUuids": [
"22247b0705a43af7a47ed6428c537934"
],
"vmInstanceZoneUuid": "04e22fb60516363a94c93e7f299a1eb3",
"vmInstanceClusterUuid": "792ec8d3dac83f10b29f0924e0787cef",
"hostUuid": "41782afc684036c092a803b58413420e",
"primaryStorageUuidForRootVolume": "8e3de0904fd937bdaaf2d29ea510a434",
"defaultL3NetworkUuid": "f7a50ab3ffb038ddb1f366e6f87db083",
"strategy": "InstantStart",
"name": "template1",
"description": "for new vm"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"vmInstanceName":"vm1","vmInstanceDescription":"vm1 desc","vmInstanceOfferingUuid":"07e435acb1c230d5b328f23e5a840da2","imageUuid":"77407eb341e732b2a45ad5bad4a2c76e","l3NetworkUuids":["93edf15377e233a291fe1ab1c4190241"],"vmInstanceType":"UserVm","rootDiskOfferingUuid":"85f44fe072733d90becb4ddd8a9867de","dataDiskOfferingUuids":["22247b0705a43af7a47ed6428c537934"],"vmInstanceZoneUuid":"04e22fb60516363a94c93e7f299a1eb3","vmInstanceClusterUuid":"792ec8d3dac83f10b29f0924e0787cef","hostUuid":"41782afc684036c092a803b58413420e","primaryStorageUuidForRootVolume":"8e3de0904fd937bdaaf2d29ea510a434","defaultL3NetworkUuid":"f7a50ab3ffb038ddb1f366e6f87db083","strategy":"InstantStart","name":"template1","description":"for new vm"}}' http://localhost:8080/zstack/v1/autoscaling/vmtemplate参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| vmInstanceName | String | body(包含在params结构中) | 云主机名称 | 3.1.0 | |
| vmInstanceDescription (可选) | String | body(包含在params结构中) | 云主机描述 | 3.1.0 | |
| vmInstanceOfferingUuid | String | body(包含在params结构中) | 云主机实例规则 | 3.1.0 | |
| imageUuid | String | body(包含在params结构中) | 云主机镜像UUID | 3.1.0 | |
| l3NetworkUuids | List | body(包含在params结构中) |
云主机三层网络列表 | 3.1.0 | |
| rootDiskOfferingUuid (可选) | String | body(包含在params结构中) | 云主机根云盘规格 | 3.1.0 | |
| dataDiskOfferingUuids (可选) | List | body(包含在params结构中) | 数据盘规格列表 | 3.1.0 | |
| vmInstanceZoneUuid (可选) | String | body(包含在params结构中) | 云主机所属地区 | 3.1.0 | |
| vmInstanceClusterUuid (可选) | String | body(包含在params结构中) | 云主机所属集群 | 3.1.0 | |
| hostUuid (可选) | String | body(包含在params结构中) | 物理机UUID | 3.1.0 | |
| primaryStorageUuidForRootVolume (可选) | String | body(包含在params结构中) | 根云盘主存储UUID | 3.1.0 | |
| defaultL3NetworkUuid | String | body(包含在params结构中) | 云主机默认三层网络 | 3.1.0 | |
| name | String | body(包含在params结构中) | 资源名称 | 3.1.0 | |
| description (可选) | String | body(包含在params结构中) | 资源的详细描述 | 3.1.0 | |
| type (可选) | String | body(包含在params结构中) | 模板类型 | 3.1.0 | |
| resourceUuid (可选) | String | body(包含在params结构中) | 3.1.0 | ||
| tagUuids (可选) | List | body(包含在params结构中) | 标签UUID列表 | 3.1.0 | |
| systemTags (可选) | List | body | 3.1.0 | ||
| userTags (可选) | List | body | 3.1.0 |
Note:
- ZStack Cloud支持弹性伸缩组绑定亲和组功能,SystemTags增加affinityGroupUuid选项。
- 选项格式为:
affinityGroupUuid::亲合组uuid。 - 例如:
affinityGroupUuid::ade3ccc31fc63ac2937b2210c21c39b1
- 选项格式为:
API返回
返回示例
{
"inventory": {
"name": "template",
"description": "desc",
"state": "Enabled"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.1.0 |
| inventory | AutoScalingTemplateInventory | 详情参考inventory | 3.1.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.1.0 |
| description | String | 错误的概要描述 | 3.1.0 |
| details | String | 错误的详细信息 | 3.1.0 |
| elaboration | String | 保留字段,默认为null | 3.1.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.1.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.1.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.1.0 |
| name | String | 资源名称 | 3.1.0 |
| description | String | 资源的详细描述 | 3.1.0 |
| type | String | 模板类型 | 3.1.0 |
| state | String | 模板启用状态 | 3.1.0 |
| systemTags | List | 3.1.0 | |
| createDate | Timestamp | 创建时间 | 3.1.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.1.0 |
SDK示例
Java
SDK
CreateAutoScalingVmTemplateAction action = new CreateAutoScalingVmTemplateAction();
action.vmInstanceName = "vm1";
action.vmInstanceDescription = "vm1 desc";
action.vmInstanceOfferingUuid = "07e435acb1c230d5b328f23e5a840da2";
action.imageUuid = "77407eb341e732b2a45ad5bad4a2c76e";
action.l3NetworkUuids = asList("93edf15377e233a291fe1ab1c4190241");
action.vmInstanceType = "UserVm";
action.rootDiskOfferingUuid = "85f44fe072733d90becb4ddd8a9867de";
action.dataDiskOfferingUuids = asList("22247b0705a43af7a47ed6428c537934");
action.vmInstanceZoneUuid = "04e22fb60516363a94c93e7f299a1eb3";
action.vmInstanceClusterUuid = "792ec8d3dac83f10b29f0924e0787cef";
action.hostUuid = "41782afc684036c092a803b58413420e";
action.primaryStorageUuidForRootVolume = "8e3de0904fd937bdaaf2d29ea510a434";
action.defaultL3NetworkUuid = "f7a50ab3ffb038ddb1f366e6f87db083";
action.strategy = "InstantStart";
action.name = "template1";
action.description = "for new vm";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateAutoScalingVmTemplateAction.Result res = action.call();Python
SDK
CreateAutoScalingVmTemplateAction action = CreateAutoScalingVmTemplateAction()
action.vmInstanceName = "vm1"
action.vmInstanceDescription = "vm1 desc"
action.vmInstanceOfferingUuid = "07e435acb1c230d5b328f23e5a840da2"
action.imageUuid = "77407eb341e732b2a45ad5bad4a2c76e"
action.l3NetworkUuids = [93edf15377e233a291fe1ab1c4190241]
action.vmInstanceType = "UserVm"
action.rootDiskOfferingUuid = "85f44fe072733d90becb4ddd8a9867de"
action.dataDiskOfferingUuids = [22247b0705a43af7a47ed6428c537934]
action.vmInstanceZoneUuid = "04e22fb60516363a94c93e7f299a1eb3"
action.vmInstanceClusterUuid = "792ec8d3dac83f10b29f0924e0787cef"
action.hostUuid = "41782afc684036c092a803b58413420e"
action.primaryStorageUuidForRootVolume = "8e3de0904fd937bdaaf2d29ea510a434"
action.defaultL3NetworkUuid = "f7a50ab3ffb038ddb1f366e6f87db083"
action.strategy = "InstantStart"
action.name = "template1"
action.description = "for new vm"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateAutoScalingVmTemplateAction.Result res = action.call()将云主机模块添加到弹性伸缩组(AttachAutoScalingTemplateToGroup)
API请求
URLs
POST zstack/v1/autoscaling/template/{uuid}/groups/{groupUuid}Headers
Authorization: OAuth the-session-uuidBody
{
"params": {},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{}}' http://localhost:8080/zstack/v1/autoscaling/template/a53e0f84df15313bba8560f6567da2d9/groups/284172349b50324a9c2b8a09a28b3294参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 模板UUID | 3.1.0 | |
| groupUuid | String | url | 伸缩组UUID | 3.1.0 | |
| systemTags (可选) | List | body | 3.1.0 | ||
| userTags (可选) | List | body | 3.1.0 |
API返回
返回示例
{
"inventory": {
"name": "test-group",
"uuid": "32d1739bb918364a840d0ff0130eda61",
"description": "just for test",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM",
"attachedTemplates": [
"e54e8d9e51113de2b6742ace7bfee306"
]
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.1.0 |
| inventory | AutoScalingGroupInventory | 详情参考inventory | 3.1.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.1.0 |
| description | String | 错误的概要描述 | 3.1.0 |
| details | String | 错误的详细信息 | 3.1.0 |
| elaboration | String | 保留字段,默认为null | 3.1.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.1.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.1.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| name | String | 资源名称 | 3.1.0 |
| uuid | String | 资源的UUID,唯一标示该资源 | 3.1.0 |
| scalingResourceType | String | 伸缩资源类型:云主机 | 3.1.0 |
| state | String | 伸缩组启用状态 | 3.1.0 |
| defaultCooldown | Long | 伸缩规则默认冷却时间 | 3.1.0 |
| description | String | 资源的详细描述 | 3.1.0 |
| minResourceSize | Integer | 伸缩组里最少云主机数量 | 3.1.0 |
| maxResourceSize | Integer | 伸缩组里最多云主机数量 | 3.1.0 |
| removalPolicy | String | 删除云主机默认策略 | 3.1.0 |
| createDate | Timestamp | 创建时间 | 3.1.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.1.0 |
| attachedTemplates | List | 挂载的伸缩组云主机模板列表 | 3.1.0 |
| systemTags | List | 3.1.0 |
SDK示例
Java
SDK
AttachAutoScalingTemplateToGroupAction action = new AttachAutoScalingTemplateToGroupAction();
action.uuid = "a53e0f84df15313bba8560f6567da2d9";
action.groupUuid = "284172349b50324a9c2b8a09a28b3294";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AttachAutoScalingTemplateToGroupAction.Result res = action.call();Python
SDK
AttachAutoScalingTemplateToGroupAction action = AttachAutoScalingTemplateToGroupAction()
action.uuid = "a53e0f84df15313bba8560f6567da2d9"
action.groupUuid = "284172349b50324a9c2b8a09a28b3294"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AttachAutoScalingTemplateToGroupAction.Result res = action.call()删除伸缩组模板(DeleteAutoScalingTemplate)
API请求
URLs
DELETE zstack/v1/autoscaling/template/{uuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/autoscaling/template/5c9e41a7d5c9335f99d639e75c294392参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 资源的UUID,唯一标示该资源 | 3.1.0 | |
| systemTags (可选) | List | body | 3.1.0 | ||
| userTags (可选) | List | body | 3.1.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
DeleteAutoScalingTemplateAction action = new DeleteAutoScalingTemplateAction();
action.uuid = "5c9e41a7d5c9335f99d639e75c294392";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteAutoScalingTemplateAction.Result res = action.call();Python
SDK
DeleteAutoScalingTemplateAction action = DeleteAutoScalingTemplateAction()
action.uuid = "5c9e41a7d5c9335f99d639e75c294392"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteAutoScalingTemplateAction.Result res = action.call()卸载伸缩组模板(DetachAutoScalingTemplateFromGroup)
API请求
URLs
DELETE zstack/v1/autoscaling/template/{uuid}/groups/{groupUuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/autoscaling/template/801a456fff0a355f9159d74af32026b9/groups/bdbbb1d168023ec7b9331bddd1b55b88参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| templateUuid | String | body | 模板UUID | 3.1.0 | |
| groupUuid | String | url | 伸缩组UUID | 3.1.0 | |
| systemTags (可选) | List | body | 3.1.0 | ||
| userTags (可选) | List | body | 3.1.0 |
API返回
返回示例
{
"inventory": {
"name": "test-group",
"uuid": "33cebe4b8d0b3e34bf2f9c517234bac9",
"description": "just for test",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.1.0 |
| inventory | AutoScalingGroupInventory | 详情参考inventory | 3.1.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.1.0 |
| description | String | 错误的概要描述 | 3.1.0 |
| details | String | 错误的详细信息 | 3.1.0 |
| elaboration | String | 保留字段,默认为null | 3.1.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.1.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.1.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| name | String | 资源名称 | 3.1.0 |
| uuid | String | 资源的UUID,唯一标示该资源 | 3.1.0 |
| scalingResourceType | String | 伸缩资源类型:云主机 | 3.1.0 |
| state | String | 伸缩组启用状态 | 3.1.0 |
| defaultCooldown | Long | 伸缩规则默认冷却时间 | 3.1.0 |
| description | String | 资源的详细描述 | 3.1.0 |
| minResourceSize | Integer | 伸缩组里最少云主机数量 | 3.1.0 |
| maxResourceSize | Integer | 伸缩组里最多云主机数量 | 3.1.0 |
| removalPolicy | String | 删除云主机默认策略 | 3.1.0 |
| createDate | Timestamp | 创建时间 | 3.1.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.1.0 |
| attachedTemplates | List | 挂载的伸缩组云主机模板列表 | 3.1.0 |
| systemTags | List | 3.1.0 |
SDK示例
Java
SDK
DetachAutoScalingTemplateFromGroupAction action = new DetachAutoScalingTemplateFromGroupAction();
action.templateUuid = "801a456fff0a355f9159d74af32026b9";
action.groupUuid = "bdbbb1d168023ec7b9331bddd1b55b88";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DetachAutoScalingTemplateFromGroupAction.Result res = action.call();Python
SDK
DetachAutoScalingTemplateFromGroupAction action = DetachAutoScalingTemplateFromGroupAction()
action.templateUuid = "801a456fff0a355f9159d74af32026b9"
action.groupUuid = "bdbbb1d168023ec7b9331bddd1b55b88"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DetachAutoScalingTemplateFromGroupAction.Result res = action.call()查询伸缩组云主机模板(QueryAutoScalingVmTemplate)
API请求
URLs
GET zstack/v1/autoscaling/vmtemplateGET zstack/v1/autoscaling/vmtemplate/{uuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/autoscaling/vmtemplatecurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/autoscaling/vmtemplate/8b6b502328bc3755a237f9a67980dd32可查询字段
运行CLI命令行工具,输入QueryAutoScalingVmTemplate并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"l3NetworkUuids": [
"9f56c162374d382f9ddb7c383bce6887",
"8e07df171471330c83306d78063fba69"
],
"rootDiskOfferingUuid": "57fb695d2d033c1e849dac6fb87cebb5",
"dataDiskOfferingUuids": [
"52bfe290f5363130a1452e2ca1c57783",
"8022018c7f6834d4a7a62a02128672ed"
],
"vmInstanceZoneUuid": "cefa21204105347a82148c099c09a0cb",
"vmInstanceClusterUuid": "ad7fcc77266f34e8a64fd208a9b7ed38",
"hostUuid": "975ceb93de173b22a2b073ee856166e3",
"primaryStorageUuidForRootVolume": "87cf45bf5a37364d85ae9968af7d2bd1",
"defaultL3NetworkUuid": "8e07df171471330c83306d78063fba69",
"uuid": "785259bf48303b0d9a4a34ddc3774da5",
"name": "test-template",
"description": "just for test",
"type": "VmInstance",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.1.0 |
| inventories | List | 详情参考inventories | 3.1.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.1.0 |
| description | String | 错误的概要描述 | 3.1.0 |
| details | String | 错误的详细信息 | 3.1.0 |
| elaboration | String | 保留字段,默认为null | 3.1.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.1.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.1.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| vmInstanceName | String | 云主机名称 | 3.1.0 |
| vmInstanceType | String | 云主机类型 | 3.1.0 |
| vmInstanceDescription | String | 云主机描述 | 3.1.0 |
| vmInstanceOfferingUuid | String | 云主机实例规格 | 3.1.0 |
| imageUuid | String | 云主机镜像UUID | 3.1.0 |
| l3NetworkUuids | List | 云主机三层网络列表 | 3.1.0 |
| rootDiskOfferingUuid | String | 云主机根云盘规格 | 3.1.0 |
| dataDiskOfferingUuids | List | 云主机数据盘规格列表 | 3.1.0 |
| vmInstanceZoneUuid | String | 云主机所属区域 | 3.1.0 |
| vmInstanceClusterUuid | String | 云主机所属集群 | 3.1.0 |
| hostUuid | String | 云主机物理机UUID | 3.1.0 |
| primaryStorageUuidForRootVolume | String | 云主机根云盘所在主存储 | 3.1.0 |
| defaultL3NetworkUuid | String | 云主机默认三层网络 | 3.1.0 |
| uuid | String | 资源的UUID,唯一标示该资源 | 3.1.0 |
| name | String | 资源名称 | 3.1.0 |
| description | String | 资源的详细描述 | 3.1.0 |
| type | String | 模板类型 | 3.1.0 |
| state | String | 模板启用状态 | 3.1.0 |
| systemTags | List | 3.1.0 | |
| createDate | Timestamp | 创建时间 | 3.1.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.1.0 |
SDK示例
Java
SDK
QueryAutoScalingVmTemplateAction action = new QueryAutoScalingVmTemplateAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryAutoScalingVmTemplateAction.Result res = action.call();Python
SDK
QueryAutoScalingVmTemplateAction action = QueryAutoScalingVmTemplateAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryAutoScalingVmTemplateAction.Result res = action.call()手动删除弹性伸缩组内云主机(DeleteAutoScalingGroupInstance)
API请求
URLs
DELETE zstack/v1/autoscaling/groups/instances/{instanceUuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/autoscaling/groups/instances/3f55b1b15c273122b6b815218282efe5参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| instanceUuid | String | url | 云主机UUID | 3.1.0 | |
| systemTags (可选) | List | body | 3.1.0 | ||
| userTags (可选) | List | body | 3.1.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
DeleteAutoScalingGroupInstanceAction action = new DeleteAutoScalingGroupInstanceAction();
action.instanceUuid = "3f55b1b15c273122b6b815218282efe5";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteAutoScalingGroupInstanceAction.Result res = action.call();Python
SDK
DeleteAutoScalingGroupInstanceAction action = DeleteAutoScalingGroupInstanceAction()
action.instanceUuid = "3f55b1b15c273122b6b815218282efe5"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteAutoScalingGroupInstanceAction.Result res = action.call()查询弹性伸缩组内云主机列表(QueryAutoScalingGroupInstance)
API请求
URLs
GET zstack/v1/autoscaling/groups/instancesGET zstack/v1/autoscaling/groups/instances/{uuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/autoscaling/groups/instancescurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/autoscaling/groups/instances/87d8ab674af337deabc1af2c24bc3733可查询字段
运行CLI命令行工具,输入QueryAutoScalingGroupInstance并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"uuid": "c23dc6fd3dd13436b5d65b0a4d328f2c",
"instanceUuid": "1dcb05b79b2b3a61b74114ff3aa00266",
"description": "just for test",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.1.0 |
| inventories | List | 详情参考inventories | 3.1.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.1.0 |
| description | String | 错误的概要描述 | 3.1.0 |
| details | String | 错误的详细信息 | 3.1.0 |
| elaboration | String | 保留字段,默认为null | 3.1.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.1.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.1.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.1.0 |
| instanceUuid | String | 云主机UUID | 3.1.0 |
| scalingGroupUuid | String | 伸缩组UUID | 3.1.0 |
| templateUuid | String | 伸缩组云主机模块UUID | 3.1.0 |
| scalingGroupActivityUuid | String | 伸缩活动UUID | 3.1.0 |
| status | String | 云主机在伸缩组里的状态 | 3.1.0 |
| healthStatus | String | 云主机在伸缩组里的健康状态 | 3.1.0 |
| description | String | 资源的详细描述 | 3.1.0 |
| createDate | Timestamp | 创建时间 | 3.1.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.1.0 |
| protectionStrategy | String | 实例保护策略 | 0.6 |
SDK示例
Java
SDK
QueryAutoScalingGroupInstanceAction action = new QueryAutoScalingGroupInstanceAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryAutoScalingGroupInstanceAction.Result res = action.call();Python
SDK
QueryAutoScalingGroupInstanceAction action = QueryAutoScalingGroupInstanceAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryAutoScalingGroupInstanceAction.Result res = action.call()修改弹性伸缩组启用状态(ChangeAutoScalingGroupState)
API请求
URLs
PUT zstack/v1/autoscaling/groups/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"changeAutoScalingGroupState": {
"stateEvent": "disable"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"changeAutoScalingGroupState":{"stateEvent":"disable"}}' http://localhost:8080/zstack/v1/autoscaling/groups/384ac055e3113366907f06e8aaefb12d/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 资源的UUID,唯一标示该资源 | 3.1.0 | |
| stateEvent | String | body(包含在changeAutoScalingGroupState结构中) | 设置为开启或者关闭 |
|
3.1.0 |
| systemTags (可选) | List | body | 3.1.0 | ||
| userTags (可选) | List | body | 3.1.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
ChangeAutoScalingGroupStateAction action = new ChangeAutoScalingGroupStateAction();
action.uuid = "384ac055e3113366907f06e8aaefb12d";
action.stateEvent = "disable";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ChangeAutoScalingGroupStateAction.Result res = action.call();Python
SDK
ChangeAutoScalingGroupStateAction action = ChangeAutoScalingGroupStateAction()
action.uuid = "384ac055e3113366907f06e8aaefb12d"
action.stateEvent = "disable"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ChangeAutoScalingGroupStateAction.Result res = action.call()手动执行伸缩组规则(ExecuteAutoScalingRule)
API请求
URLs
PUT zstack/v1/autoscaling/rules/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"executeAutoScalingRule": {},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"executeAutoScalingRule":{}}' http://localhost:8080/zstack/v1/autoscaling/rules/9311aaae28333775b3339b644961c990/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 伸缩组规则UUID | 3.9.0 | |
| systemTags (可选) | List | body | 系统标签 | 3.9.0 | |
| userTags (可选) | List | body | 用户标签 | 3.9.0 |
API返回
返回示例
{
"scalingActivityUuid": "20ba90ed9e1631768fd7b896569fae62"
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| scalingActivityUuid | String | 伸缩活动UUID | 3.9.0 |
| success | boolean | 3.9.0 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.9.0 |
| error | ErrorCode | 详情参考error | 3.9.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.9.0 |
| description | String | 错误的概要描述 | 3.9.0 |
| details | String | 错误的详细信息 | 3.9.0 |
| elaboration | String | 保留字段,默认为null | 3.9.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.9.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.9.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.9.0 |
| description | String | 错误的概要描述 | 3.9.0 |
| details | String | 错误的详细信息 | 3.9.0 |
| elaboration | String | 保留字段,默认为null | 3.9.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.9.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.9.0 |
SDK示例
Java
SDK
ExecuteAutoScalingRuleAction action = new ExecuteAutoScalingRuleAction();
action.uuid = "9311aaae28333775b3339b644961c990";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ExecuteAutoScalingRuleAction.Result res = action.call();Python
SDK
ExecuteAutoScalingRuleAction action = ExecuteAutoScalingRuleAction()
action.uuid = "9311aaae28333775b3339b644961c990"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ExecuteAutoScalingRuleAction.Result res = action.call()更新伸缩组实例信息(UpdateAutoScalingGroupInstance)
API请求
URLs
PUT zstack/v1/autoscaling/groups/instances/{instanceUuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"updateAutoScalingGroupInstance": {
"groupUuid": "a3b7616d6e6a3ed6bdf5dd5a640a4548",
"protectionStrategy": "Protected"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateAutoScalingGroupInstance":{"groupUuid":"a3b7616d6e6a3ed6bdf5dd5a640a4548","protectionStrategy":"Protected"}}' http://localhost:8080/zstack/v1/autoscaling/groups/instances/a6dcd12ee95e345787a34175327df816/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| groupUuid | String | body(包含在updateAutoScalingGroupInstance结构中) | 伸缩组UUID | 3.9.0 | |
| instanceUuid | String | url | 伸缩组内实例UUID | 3.9.0 | |
| protectionStrategy (可选) | String | body(包含在updateAutoScalingGroupInstance结构中) | 伸缩组内实例保护策略 |
|
3.9.0 |
| systemTags (可选) | List | body | 系统标签 | 3.9.0 | |
| userTags (可选) | List | body | 用户标签 | 3.9.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
UpdateAutoScalingGroupInstanceAction action = new UpdateAutoScalingGroupInstanceAction();
action.groupUuid = "a3b7616d6e6a3ed6bdf5dd5a640a4548";
action.instanceUuid = "a6dcd12ee95e345787a34175327df816";
action.protectionStrategy = "Protected";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateAutoScalingGroupInstanceAction.Result res = action.call();Python
SDK
UpdateAutoScalingGroupInstanceAction action = UpdateAutoScalingGroupInstanceAction()
action.groupUuid = "a3b7616d6e6a3ed6bdf5dd5a640a4548"
action.instanceUuid = "a6dcd12ee95e345787a34175327df816"
action.protectionStrategy = "Protected"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateAutoScalingGroupInstanceAction.Result res = action.call()更新伸缩组云主机模板(UpdateAutoScalingVmTemplate)
API请求
URLs
PUT zstack/v1/autoscaling/vmtemplate/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"updateAutoScalingVmTemplate": {
"name": "template",
"description": "for new vm",
"vmInstanceName": "vm",
"vmInstanceDescription": "vm desc",
"vmInstanceOfferingUuid": "af0462e292513725aa228476d0f08ac3",
"imageUuid": "9dc29a7b3e603a7cb26bc1d16eccc1f1"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateAutoScalingVmTemplate":{"name":"template","description":"for new vm","vmInstanceName":"vm","vmInstanceDescription":"vm desc","vmInstanceOfferingUuid":"af0462e292513725aa228476d0f08ac3","imageUuid":"9dc29a7b3e603a7cb26bc1d16eccc1f1"}}' http://localhost:8080/zstack/v1/autoscaling/vmtemplate/dfb4e8245e32361db57b92c95c84c01b/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 云主机模板UUID | 3.9.0 | |
| name (可选) | String | body(包含在updateAutoScalingVmTemplate结构中) | 模板名称 | 3.9.0 | |
| description (可选) | String | body(包含在updateAutoScalingVmTemplate结构中) | 详细描述 | 3.9.0 | |
| vmInstanceName (可选) | String | body(包含在updateAutoScalingVmTemplate结构中) | 云主机名称 | 3.9.0 | |
| vmInstanceDescription (可选) | String | body(包含在updateAutoScalingVmTemplate结构中) | 云主机描述 | 3.9.0 | |
| vmInstanceOfferingUuid (可选) | String | body(包含在updateAutoScalingVmTemplate结构中) | 云主机实例规格UUID | 3.9.0 | |
| imageUuid (可选) | String | body(包含在updateAutoScalingVmTemplate结构中) | 云主机镜像UUID | 3.9.0 | |
| systemTags (可选) | List | body | 系统标签 | 3.9.0 | |
| userTags (可选) | List | body | 用户标签 | 3.9.0 |
API返回
返回示例
{
"inventory": {
"name": "template",
"description": "desc",
"state": "Enabled"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.9.0 |
| inventory | AutoScalingTemplateInventory | 详情参考inventory | 3.9.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.9.0 |
| description | String | 错误的概要描述 | 3.9.0 |
| details | String | 错误的详细信息 | 3.9.0 |
| elaboration | String | 保留字段,默认为null | 3.9.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.9.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.9.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.9.0 |
| name | String | 资源名称 | 3.9.0 |
| description | String | 资源的详细描述 | 3.9.0 |
| type | String | 模板类型 | 3.9.0 |
| state | String | 模板启用状态 | 3.9.0 |
| systemTags | List | 3.9.0 | |
| createDate | Timestamp | 创建时间 | 3.9.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.9.0 |
SDK示例
Java
SDK
UpdateAutoScalingVmTemplateAction action = new UpdateAutoScalingVmTemplateAction();
action.uuid = "dfb4e8245e32361db57b92c95c84c01b";
action.name = "template";
action.description = "for new vm";
action.vmInstanceName = "vm";
action.vmInstanceDescription = "vm desc";
action.vmInstanceOfferingUuid = "af0462e292513725aa228476d0f08ac3";
action.imageUuid = "9dc29a7b3e603a7cb26bc1d16eccc1f1";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateAutoScalingVmTemplateAction.Result res = action.call();Python
SDK
UpdateAutoScalingVmTemplateAction action = UpdateAutoScalingVmTemplateAction()
action.uuid = "dfb4e8245e32361db57b92c95c84c01b"
action.name = "template"
action.description = "for new vm"
action.vmInstanceName = "vm"
action.vmInstanceDescription = "vm desc"
action.vmInstanceOfferingUuid = "af0462e292513725aa228476d0f08ac3"
action.imageUuid = "9dc29a7b3e603a7cb26bc1d16eccc1f1"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateAutoScalingVmTemplateAction.Result res = action.call()