设置相关接口
全局设置相关接口
查询全局设置(QueryGlobalConfig)
API请求
URLs
GET zstack/v1/global-configurationsHeaders
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 036d9a68cd8243e99e8d740eaf8b4baf" \
-X GET http://localhost:8080/zstack/v1/global-configurations可查询字段
运行CLI命令行工具,输入QueryGlobalConfig并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"name": "reservedCapacity",
"category": "backupStorage",
"description": "Reserved capcacity on every backup storage",
"defaultValue": "1G",
"value": "2G"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 0.6 |
| inventories | List | 详情参考inventories | 0.6 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| name | String | 资源名称 | 0.6 |
| category | String | 0.6 | |
| description | String | 资源的详细描述 | 0.6 |
| defaultValue | String | 0.6 | |
| value | String | 0.6 |
SDK示例
Java
SDK
QueryGlobalConfigAction action = new QueryGlobalConfigAction();
action.conditions = asList();
action.sessionId = "8509eaa6301b4935a4b100a05f1fe2ba";
QueryGlobalConfigAction.Result res = action.call();Python
SDK
QueryGlobalConfigAction action = QueryGlobalConfigAction()
action.conditions = []
action.sessionId = "e085fdf6aa354291b71ae8dc5fa880fe"
QueryGlobalConfigAction.Result res = action.call()更新全局设置(UpdateGlobalConfig)
API请求
URLs
PUT zstack/v1/global-configurations/{category}/{name}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"updateGlobalConfig": {
"value": "90"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateGlobalConfig":{"value":"90"}}' \
http://localhost:8080/zstack/v1/global-configurations/quota/scheduler.num/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| category | String | url | 类型 | 0.6 | |
| name | String | url | 资源名称 | 0.6 | |
| value (可选) | String | body(包含在updateGlobalConfig结构中) | 值 | 0.6 | |
| systemTags (可选) | List | body | 系统标签 | 0.6 | |
| userTags (可选) | List | body | 用户标签 | 0.6 |
API返回
返回示例
{
"inventory": {
"name": "scheduler.num",
"category": "quota",
"description": "default quota for scheduler.num",
"defaultValue": "80",
"value": "90"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 0.6 |
| inventory | GlobalConfigInventory | 详情参考inventory | 0.6 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| name | String | 资源名称 | 0.6 |
| category | String | 0.6 | |
| description | String | 资源的详细描述 | 0.6 |
| defaultValue | String | 0.6 | |
| value | String | 0.6 |
SDK示例
Java
SDK
UpdateGlobalConfigAction action = new UpdateGlobalConfigAction();
action.category = "quota";
action.name = "scheduler.num";
action.value = "90";
action.sessionId = "84a1a9ed2d54449db13e01f7d6face7e";
UpdateGlobalConfigAction.Result res = action.call();Python
SDK
UpdateGlobalConfigAction action = UpdateGlobalConfigAction()
action.category = "quota"
action.name = "scheduler.num"
action.value = "90"
action.sessionId = "b077cfa8599a4ff1ac4fd7ba67b20a82"
UpdateGlobalConfigAction.Result res = action.call()重置全局设置(ResetGlobalConfig)
API请求
URLs
PUT zstack/v1/global-configurations/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"resetGlobalConfig": {},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"resetGlobalConfig":{}}' http://localhost:8080/zstack/v1/global-configurations/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| 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
ResetGlobalConfigAction action = new ResetGlobalConfigAction();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ResetGlobalConfigAction.Result res = action.call();Python
SDK
ResetGlobalConfigAction action = ResetGlobalConfigAction()
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ResetGlobalConfigAction.Result res = action.call()资源高级设置相关接口
获取资源的资源高级设置(GetResourceConfig)
API请求
URLs
GET zstack/v1/resource-configurations/{resourceUuid}/{category}/{name}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/resource-configurations/77663dd5ff84460bbf1817aa3c59d125/host/cpu.overProvisioning.ratio参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| category | String | url | 设置类型 | 3.4.0 | |
| name | String | url | 设置名称 | 3.4.0 | |
| resourceUuid | String | url | 资源UUID | 3.4.0 | |
| systemTags (可选) | List | query | 3.4.0 | ||
| userTags (可选) | List | query | 3.4.0 |
API返回
返回示例
{
"value": "5",
"effectiveConfigs": [
{
"uuid": "dae9aeb6d74e4f44823f2e0c4f1cc79f",
"resourceUuid": "46597de31eac41539c4e6eda52885769",
"resourceType": "HostVO",
"name": "cpu.overProvisioning.ratio",
"category": "host",
"value": "5",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
},
{
"uuid": "5c3c94a73d7b4a95a1818241f2e427ae",
"resourceUuid": "371519310f344695854de27bb9743121",
"resourceType": "ClusterVO",
"name": "cpu.overProvisioning.ratio",
"category": "host",
"value": "10",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| value | String | 配置的值 | 3.4.0 |
| success | boolean | 3.4.0 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.4.0 |
| effectiveConfigs | List | 生效的设置列表,按优先级从高到低排序,详情参考effectiveConfigs | 3.4.0 |
| error | ErrorCode | 详情参考error | 3.4.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.4.0 |
| description | String | 错误的概要描述 | 3.4.0 |
| details | String | 错误的详细信息 | 3.4.0 |
| elaboration | String | 保留字段,默认为null | 3.4.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.4.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.4.0 |
#effectiveConfigs
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.4.0 |
| resourceUuid | String | 配置对应的资源UUID | 3.4.0 |
| resourceType | String | 配置对应的资源类型 | 3.4.0 |
| name | String | 配置名称 | 3.4.0 |
| description | String | 配置的详细描述 | 3.4.0 |
| category | String | 配置类别 | 3.4.0 |
| value | String | 配置的值 | 3.4.0 |
| createDate | Timestamp | 创建时间 | 3.4.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.4.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.4.0 |
| description | String | 错误的概要描述 | 3.4.0 |
| details | String | 错误的详细信息 | 3.4.0 |
| elaboration | String | 保留字段,默认为null | 3.4.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.4.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.4.0 |
SDK示例
Java
SDK
GetResourceConfigAction action = new GetResourceConfigAction();
action.category = "host";
action.name = "cpu.overProvisioning.ratio";
action.resourceUuid = "70fdcc564f564c29af98e48e78be56e4";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetResourceConfigAction.Result res = action.call();Python
SDK
GetResourceConfigAction action = GetResourceConfigAction()
action.category = "host"
action.name = "cpu.overProvisioning.ratio"
action.resourceUuid = "b1ea1d424bf04a50b15b33bcd0f8a80d"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetResourceConfigAction.Result res = action.call()获取可配置的资源高级设置(GetResourceBindableConfig)
API请求
URLs
GET zstack/v1/resource-configurations/bindable
GET zstack/v1/resource-configurations/bindable/{category}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/resource-configurations/bindable?category=hostcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/resource-configurations/bindable/host?category=host参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| category (可选) | String | query | 设置类型 | 3.4.0 | |
| systemTags (可选) | List | query | 3.4.0 | ||
| userTags (可选) | List | query | 3.4.0 |
API返回
返回示例
{
"bindableConfigs": [
{
"name": "cpu.overProvisioning.ratio",
"category": "host",
"bindResourceTypes": [
"HostVO",
"ClusterVO",
"ZoneVO"
]
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.4.0 |
| bindableConfigs | List | 详情参考bindableConfigs | 3.4.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.4.0 |
| description | String | 错误的概要描述 | 3.4.0 |
| details | String | 错误的详细信息 | 3.4.0 |
| elaboration | String | 保留字段,默认为null | 3.4.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.4.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.4.0 |
#bindableConfigs
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| name | String | 设置名称 | 3.4.0 |
| category | String | 设置类型 | 3.4.0 |
| description | String | 设置的详细描述 | 3.4.0 |
| bindResourceTypes | List | 设置可绑定的资源类型 | 3.4.0 |
SDK示例
Java
SDK
GetResourceBindableConfigAction action = new GetResourceBindableConfigAction();
action.category = "host";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetResourceBindableConfigAction.Result res = action.call();Python
SDK
GetResourceBindableConfigAction action = GetResourceBindableConfigAction()
action.category = "host"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetResourceBindableConfigAction.Result res = action.call()删除资源的资源高级设置(DeleteResourceConfig)
API请求
URLs
DELETE zstack/v1/resource-configurations/{category}/{name}/{resourceUuid}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/resource-configurations/host/cpu.overProvisioning.ratio/02bcf0b045e247e59bfd51630064443f参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| category | String | url | 设置类型 | 3.4.0 | |
| name | String | url | 设置名称 | 3.4.0 | |
| resourceUuid | String | url | 资源UUID | 3.4.0 | |
| deleteMode (可选) | String | body | 3.4.0 | ||
| systemTags (可选) | List | body | 3.4.0 | ||
| userTags (可选) | List | body | 3.4.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
DeleteResourceConfigAction action = new DeleteResourceConfigAction();
action.category = "host";
action.name = "cpu.overProvisioning.ratio";
action.resourceUuid = "763612d48d514b35a7df506cf1a23f57";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteResourceConfigAction.Result res = action.call();Python
SDK
DeleteResourceConfigAction action = DeleteResourceConfigAction()
action.category = "host"
action.name = "cpu.overProvisioning.ratio"
action.resourceUuid = "4ac85edbee2c489ea58e3f26b53182de"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteResourceConfigAction.Result res = action.call()查询资源高级设置(QueryResourceConfig)
API请求
URLs
GET zstack/v1/resource-configurationsHeaders
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/resource-configurations可查询字段
运行CLI命令行工具,输入QueryResourceConfig并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"uuid": "4944c2599c394bd5be5ccc1099dfdb4b",
"resourceUuid": "45a511dfef1b474dbef3c1ff88275465",
"resourceType": "ClusterVO",
"name": "cpu.overProvisioning.ratio",
"category": "host",
"value": "10",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.4.0 |
| inventories | List | 详情参考inventories | 3.4.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.4.0 |
| description | String | 错误的概要描述 | 3.4.0 |
| details | String | 错误的详细信息 | 3.4.0 |
| elaboration | String | 保留字段,默认为null | 3.4.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.4.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.4.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.4.0 |
| resourceUuid | String | 配置对应的资源UUID | 3.4.0 |
| resourceType | String | 配置对应的资源类型 | 3.4.0 |
| name | String | 配置名称 | 3.4.0 |
| description | String | 配置的详细描述 | 3.4.0 |
| category | String | 配置类别 | 3.4.0 |
| value | String | 配置的值 | 3.4.0 |
| createDate | Timestamp | 创建时间 | 3.4.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.4.0 |
SDK示例
Java
SDK
QueryResourceConfigAction action = new QueryResourceConfigAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryResourceConfigAction.Result res = action.call();Python
SDK
QueryResourceConfigAction action = QueryResourceConfigAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryResourceConfigAction.Result res = action.call()更新资源高级设置(UpdateResourceConfig)
API请求
URLs
PUT zstack/v1/resource-configurations/{category}/{name}/{resourceUuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"updateResourceConfig": {
"value": "10"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateResourceConfig":{"value":"10"}}' http://localhost:8080/zstack/v1/resource-configurations/host/cpu.overProvisioning.ratio/afd5f67a253b4990b9e8160672357eed/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| category | String | url | 设置类型 | 3.4.0 | |
| name | String | url | 设置名称 | 3.4.0 | |
| resourceUuid | String | url | 设置的资源UUID | 3.4.0 | |
| value | String | body(包含在updateResourceConfig结构中) | 设置的值 | 3.4.0 | |
| systemTags (可选) | List | body | 3.4.0 | ||
| userTags (可选) | List | body | 3.4.0 |
API返回
返回示例
{
"inventory": {
"uuid": "ce61962673574ff689e2e6cb6f8cf558",
"resourceUuid": "435a7c71c82b4b0b971f4674ab346822",
"resourceType": "ClusterVO",
"name": "cpu.overProvisioning.ratio",
"category": "host",
"value": "10",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.4.0 |
| inventory | ResourceConfigInventory | 详情参考inventory | 3.4.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.4.0 |
| description | String | 错误的概要描述 | 3.4.0 |
| details | String | 错误的详细信息 | 3.4.0 |
| elaboration | String | 保留字段,默认为null | 3.4.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.4.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.4.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.4.0 |
| resourceUuid | String | 配置对应的资源UUID | 3.4.0 |
| resourceType | String | 配置对应的资源类型 | 3.4.0 |
| name | String | 配置名称 | 3.4.0 |
| description | String | 配置的详细描述 | 3.4.0 |
| category | String | 配置类别 | 3.4.0 |
| value | String | 配置的值 | 3.4.0 |
| createDate | Timestamp | 创建时间 | 3.4.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.4.0 |
SDK示例
Java
SDK
UpdateResourceConfigAction action = new UpdateResourceConfigAction();
action.category = "host";
action.name = "cpu.overProvisioning.ratio";
action.resourceUuid = "5fa296dff4f04c96b29f38bef93e9e15";
action.value = "10";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateResourceConfigAction.Result res = action.call();Python
SDK
UpdateResourceConfigAction action = UpdateResourceConfigAction()
action.category = "host"
action.name = "cpu.overProvisioning.ratio"
action.resourceUuid = "1e0f389aca364a1f94929bb4f39597b3"
action.value = "10"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateResourceConfigAction.Result res = action.call()场景封装相关接口
应用模板(ApplyTemplateConfig)
API请求
URLs
PUT zstack/v1/template-configurations/{templateUuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"applyTemplateConfig": {},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"applyTemplateConfig":{}}' http://localhost:8080/zstack/v1/template-configurations/00000000/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| templateUuid | String | url | 模板Uuid | 3.6.0 | |
| systemTags (可选) | List | body | 系统标签 | 3.6.0 | |
| userTags (可选) | List | body | 用户标签 | 3.6.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
ApplyTemplateConfigAction action = new ApplyTemplateConfigAction();
action.templateUuid = "00000000";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ApplyTemplateConfigAction.Result res = action.call();Python
SDK
ApplyTemplateConfigAction action = ApplyTemplateConfigAction()
action.templateUuid = "00000000"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ApplyTemplateConfigAction.Result res = action.call()查询所有模板信息(QueryGlobalConfigTemplate)
API请求
URLs
GET zstack/v1/template-configurations/templates
GET zstack/v1/template-configurations/templates/{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/template-configurations/templates?curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/template-configurations/templates/8bca97cf1b2030f7b0872191260a4dc5可查询字段
运行CLI命令行工具,输入QueryGlobalConfigTemplate并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"uuid": "reservedCapacity",
"name": "scenes1",
"type": "System",
"description": "For scenes1"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.6.0 |
| inventories | List | 详情参考inventories | 3.6.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.6.0 |
| description | String | 错误的概要描述 | 3.6.0 |
| details | String | 错误的详细信息 | 3.6.0 |
| elaboration | String | 保留字段,默认为null | 3.6.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.6.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.6.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.6.0 |
| name | String | 模板名称 | 3.6.0 |
| type | String | 模板类型 | 3.6.0 |
| description | String | 该模板的描述信息及推荐场景 | 3.6.0 |
SDK示例
Java
SDK
QueryGlobalConfigTemplateAction action = new QueryGlobalConfigTemplateAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryGlobalConfigTemplateAction.Result res = action.call();Python
SDK
QueryGlobalConfigTemplateAction action = QueryGlobalConfigTemplateAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryGlobalConfigTemplateAction.Result res = action.call()查询模板具体配置(QueryTemplateConfig)
API请求
URLs
GET zstack/v1/template-configurations/configs
GET zstack/v1/template-configurations/configs/{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/template-configurations/configs?curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/template-configurations/configs/8d81b083dd0b3374af2454ab8d3fb0ef可查询字段
运行CLI命令行工具,输入QueryTemplateConfig并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"templateUuid": "0000111122223333",
"category": "backupStorage",
"name": "reservedCapacity",
"defaultValue": "1G",
"value": "2G"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.6.0 |
| inventories | List | 详情参考inventories | 3.6.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.6.0 |
| description | String | 错误的概要描述 | 3.6.0 |
| details | String | 错误的详细信息 | 3.6.0 |
| elaboration | String | 保留字段,默认为null | 3.6.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.6.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.6.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| templateUuid | String | 所属模板Uuid | 3.6.0 |
| category | String | 配置类型 | 3.6.0 |
| name | String | 配置名称 | 3.6.0 |
| defaultValue | String | 模板默认值 | 3.6.0 |
| value | String | 模板值 | 3.6.0 |
SDK示例
Java
SDK
QueryTemplateConfigAction action = new QueryTemplateConfigAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryTemplateConfigAction.Result res = action.call();Python
SDK
QueryTemplateConfigAction action = QueryTemplateConfigAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryTemplateConfigAction.Result res = action.call()更新模板值(UpdateTemplateConfig)
API请求
URLs
PUT zstack/v1/template-configurations/{templateUuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"updateTemplateConfig": {
"category": "quota",
"name": "scheduler.num",
"value": "90"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateTemplateConfig":{"category":"quota","name":"scheduler.num","value":"90"}}' http://localhost:8080/zstack/v1/template-configurations/0000/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| templateUuid | String | url | 模板Uuid | 3.6.0 | |
| category | String | body(包含在updateTemplateConfig结构中) | 对应的GlobalConfig配置类型 | 3.6.0 | |
| name | String | body(包含在updateTemplateConfig结构中) | 对应的GlobalConfig配置名称 | 3.6.0 | |
| value | String | body(包含在updateTemplateConfig结构中) | 模板值 | 3.6.0 | |
| systemTags (可选) | List | body | 系统标签 | 3.6.0 | |
| userTags (可选) | List | body | 用户标签 | 3.6.0 |
API返回
返回示例
{
"inventory": {
"templateUuid": "000011112222",
"category": "vm",
"name": "emulateHyperV",
"defaultValue": "true",
"value": "true"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.6.0 |
| inventory | TemplateConfigInventory | 详情参考inventory | 3.6.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.6.0 |
| description | String | 错误的概要描述 | 3.6.0 |
| details | String | 错误的详细信息 | 3.6.0 |
| elaboration | String | 保留字段,默认为null | 3.6.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.6.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.6.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| templateUuid | String | 所属模板Uuid | 3.6.0 |
| category | String | 配置类型 | 3.6.0 |
| name | String | 配置名称 | 3.6.0 |
| defaultValue | String | 模板默认值 | 3.6.0 |
| value | String | 模板值 | 3.6.0 |
SDK示例
Java
SDK
UpdateTemplateConfigAction action = new UpdateTemplateConfigAction();
action.templateUuid = "0000";
action.category = "quota";
action.name = "scheduler.num";
action.value = "90";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateTemplateConfigAction.Result res = action.call();Python
SDK
UpdateTemplateConfigAction action = UpdateTemplateConfigAction()
action.templateUuid = "0000"
action.category = "quota"
action.name = "scheduler.num"
action.value = "90"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateTemplateConfigAction.Result res = action.call()重置模板到初始状态(ResetTemplateConfig)
API请求
URLs
PUT zstack/v1/template-configurations/{templateUuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"resetTemplateConfig": {},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"resetTemplateConfig":{}}' http://localhost:8080/zstack/v1/template-configurations/00000000/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| templateUuid | String | url | 模板Uuid | 3.6.0 | |
| systemTags (可选) | List | body | 系统标签 | 3.6.0 | |
| userTags (可选) | List | body | 用户标签 | 3.6.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
ResetTemplateConfigAction action = new ResetTemplateConfigAction();
action.templateUuid = "00000000";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ResetTemplateConfigAction.Result res = action.call();Python
SDK
ResetTemplateConfigAction action = ResetTemplateConfigAction()
action.templateUuid = "00000000"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ResetTemplateConfigAction.Result res = action.call()重置模板配置到默认值(RevertTemplateConfig)
API请求
URLs
PUT zstack/v1/template-configurations/{templateUuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"resetTemplateConfig": {},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \-X PUT -d '{"revertTemplateConfig":{}}' http://localhost:8080/zstack/v1/template-configurations/fd5ae067a0b037d2af3a6ec060c4be86/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| templateUuid | String | url | 模板UUID | 4.6.21 | |
| systemTags (可选) | List | body | 系统标签 | 4.6.21 | |
| userTags (可选) | List | body | 用户标签 | 4.6.21 |
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
RevertTemplateConfigAction action = new RevertTemplateConfigAction();
action.templateUuid = "fd5ae067a0b037d2af3a6ec060c4be86";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
RevertTemplateConfigAction.Result res = action.call();Python
SDK
RevertTemplateConfigAction action = RevertTemplateConfigAction()
action.templateUuid = "fd5ae067a0b037d2af3a6ec060c4be86"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
RevertTemplateConfigAction.Result res = action.call()高可用策略相关接口
更新高可用策略(UpdateHaStrategyCondition)
API请求
URLs
PUT zstack/v1/ha-strategy-condition/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"updateHaStrategyCondition": {
"name": "new ha strategycondition name",
"state": "Enable"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateHaStrategyCondition":{"name":"new ha strategycondition name","state":"Enable"}}' http://localhost:8080/zstack/v1/ha-strategy-condition/bf798f9ae94f3007a293f090ec555d57/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 资源的UUID,唯一标示该资源 | 4.7.0 | |
| name (可选) | String | body(包含在updateHaStrategyCondition结构中) | 资源名称 | 4.7.0 | |
| state (可选) | String | body(包含在updateHaStrategyCondition结构中) | 状态 | 4.7.0 | |
| systemTags (可选) | List | body | 系统标签 | 4.7.0 | |
| userTags (可选) | List | body | 用户标签 | 4.7.0 |
API返回
返回示例
{
"inventory": {
"uuid": "9a01c1cea2793814b8b1bf228a2ff601",
"name": "test",
"fencerName": "hostStorageState"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 4.7.0 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 4.7.0 |
| inventory | HaStrategyConditionInventory | 详情参考inventory | 4.7.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 4.7.0 |
| description | String | 错误的概要描述 | 4.7.0 |
| details | String | 错误的详细信息 | 4.7.0 |
| elaboration | String | 保留字段,默认为null | 4.7.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 4.7.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 4.7.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.7.0 |
| name | String | 资源名称 | 4.7.0 |
| fencerName | String | fencer 名字 | 4.7.0 |
| state | String | 状态 | 4.7.0 |
| createDate | Timestamp | 创建时间 | 4.7.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.7.0 |
SDK示例
Java
SDK
UpdateHaStrategyConditionAction action = new UpdateHaStrategyConditionAction();
action.uuid = "bf798f9ae94f3007a293f090ec555d57";
action.name = "new ha strategycondition name";
action.state = "Enable";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateHaStrategyConditionAction.Result res = action.call();Python
SDK
UpdateHaStrategyConditionAction action = UpdateHaStrategyConditionAction()
action.uuid = "bf798f9ae94f3007a293f090ec555d57"
action.name = "new ha strategycondition name"
action.state = "Enable"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateHaStrategyConditionAction.Result res = action.call()