系统设置相关接口
日志服务器相关接口
添加日志服务器配置(AddLogConfiguration)
添加日志服务器配置
API请求
URLs
POST zstack/v1/log/configurationsHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "syslog",
"type": "log4j2",
"level": "ERROR",
"configuration": "{\n\"appenderType\": \"Syslog\",\n\"configuration\": {\n\"hostname\": \"192.168.0.11\",\n\"port\": \"514\",\n\"protocol\": \"UDP\",\n\"facility\": \"LOCAL5\"\n}\n}"
},
"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":"syslog","type":"log4j2","level":"ERROR","configuration":"{\n\"appenderType\": \"Syslog\",\n\"configuration\": {\n\"hostname\": \"192.168.0.11\",\n\"port\": \"514\",\n\"protocol\": \"UDP\",\n\"facility\": \"LOCAL5\"\n}\n}"}}' http://localhost:8080/zstack/v1/log/configurations参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| name | String | body(包含在params结构中) |
资源名称 | 3.7.0 | |
| description (可选) | String | body(包含在params结构中) |
资源的详细描述 | 3.7.0 | |
| type | String | body(包含在params结构中) |
3.7.0 | ||
| configuration | String | body(包含在params结构中) |
3.7.0 | ||
| resourceUuid (可选) | String | body(包含在params结构中) |
资源UUID | 3.7.0 | |
| level (可选) | String | body(包含在params结构中) |
日志级别 | 5.1.0 | |
| tagUuids (可选) | List | body(包含在params结构中) |
标签UUID列表 | 3.7.0 | |
| systemTags (可选) | List | body | 系统标签 | 3.7.0 | |
| userTags (可选) | List | body | 用户标签 | 3.7.0 |
API返回
SDK示例
Java SDK
AddLogConfigurationAction action = new AddLogConfigurationAction();
action.name = "syslog";
action.type = "log4j2";
action.level = "ERROR";
action.configuration = "{
"appenderType": "Syslog",
"configuration": {
"hostname": "192.168.0.11",
"port": "514",
"protocol": "UDP",
"facility": "LOCAL5"
}
}";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AddLogConfigurationAction.Result res = action.call();Python SDK
action = AddLogConfigurationAction()
action.name = "syslog"
action.type = "log4j2"
action.level = "ERROR"
action.configuration = "{
"appenderType": "Syslog",
"configuration": {
"hostname": "192.168.0.11",
"port": "514",
"protocol": "UDP",
"facility": "LOCAL5"
}
}"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()删除日志服务器配置(DeleteLogConfiguration)
API请求
URLs
DELETE zstack/v1/log/configurations/log4j2Headers
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/log/configurations/log4j2?deleteMode=Permissive参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| configId | Long | body | 配置id | 3.10.0 | |
| deleteMode (可选) | String | body | 删除模式,默认为Permissive |
|
3.10.0 |
| systemTags (可选) | List | body | 系统标签 | 3.10.0 | |
| userTags (可选) | List | body | 用户标签 | 3.10.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
DeleteLogConfigurationAction action = new DeleteLogConfigurationAction();
action.configId = 0.0;
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteLogConfigurationAction.Result res = action.call();Python
SDK
DeleteLogConfigurationAction action = DeleteLogConfigurationAction()
action.configId = 0.0
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteLogConfigurationAction.Result res = action.call()获取日志服务器配置(GetLogConfiguration)
API请求
URLs
GET zstack/v1/log/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/log/configurations参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| systemTags (可选) | List | query | 3.10.0 | ||
| userTags (可选) | List | query | 3.10.0 |
API返回
返回示例
{
"inventories": [
{
"id": 0.0,
"labelKey": "log4j2-0201c1784c6e48d2ba26954d4c688fae",
"labelValue": "{\n\"appenderType\": \"Syslog\",\n\"configuration\": {\n\"hostname\": \"192.168.0.13\",\n\"port\": \"514\",\n\"protocol\": \"UDP\",\n\"facility\": \"LOCAL5\"\n}\n}"
},
{
"id": 0.0,
"labelKey": "log4j2-ba2cf0a6945d4267bfdc1994776b509d",
"labelValue": "{\n\"appenderType\": \"Syslog\",\n\"configuration\": {\n\"hostname\": \"192.168.0.11\",\n\"port\": \"514\",\n\"protocol\": \"UDP\",\n\"facility\": \"LOCAL5\"\n}\n}"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.10.0 |
| inventories | List | 详情参考inventories | 3.10.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.10.0 |
| description | String | 错误的概要描述 | 3.10.0 |
| details | String | 错误的详细信息 | 3.10.0 |
| elaboration | String | 保留字段,默认为null | 3.10.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.10.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.10.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| id | long | 3.10.0 | |
| labelKey | String | 3.10.0 | |
| labelValue | String | 3.10.0 | |
| resourceUuid | String | 资源UUID | 3.10.0 |
| createDate | Timestamp | 创建时间 | 3.10.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.10.0 |
SDK示例
Java
SDK
GetLogConfigurationAction action = new GetLogConfigurationAction();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetLogConfigurationAction.Result res = action.call();Python
SDK
GetLogConfigurationAction action = GetLogConfigurationAction()
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetLogConfigurationAction.Result res = action.call()修改日志服务器配置(UpdateLogConfiguration)
API请求
URLs
PUT zstack/v1/log/configurationsHeaders
Authorization: OAuth the-session-uuidBody
{
"updateLogConfiguration": {
"configId": 1.0
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateLogConfiguration":{"configId":1.0}}' http://localhost:8080/zstack/v1/log/configurations参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| configId | long | body(包含在updateLogConfiguration结构中) | 配置的id | 3.10.0 | |
| name (可选) | String | body(包含在updateLogConfiguration结构中) | 资源名称 | 3.10.0 | |
| description (可选) | String | body(包含在updateLogConfiguration结构中) | 资源的详细描述 | 3.10.0 | |
| systemTags (可选) | List | body | 系统标签 | 3.10.0 | |
| userTags (可选) | List | body | 用户标签 | 3.10.0 |
API返回
返回示例
{
"inventory": {
"id": 0.0,
"labelKey": "log4j2-848dd6e5712e4227ae40447753871ba8",
"labelValue": "{\n\"appenderType\": \"Syslog\",\n\"configuration\": {\n\"hostname\": \"192.168.0.11\",\n\"port\": \"514\",\n\"protocol\": \"UDP\",\n\"facility\": \"LOCAL5\"\n}\n}"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.10.0 |
| inventory | VmNicInventory | 详情参考inventory | 3.10.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.10.0 |
| description | String | 错误的概要描述 | 3.10.0 |
| details | String | 错误的详细信息 | 3.10.0 |
| elaboration | String | 保留字段,默认为null | 3.10.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.10.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.10.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| id | long | 3.10.0 | |
| labelKey | String | 3.10.0 | |
| labelValue | String | 3.10.0 | |
| resourceUuid | String | 资源UUID | 3.10.0 |
| createDate | Timestamp | 创建时间 | 3.10.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.10.0 |
SDK示例
Java
SDK
UpdateLogConfigurationAction action = new UpdateLogConfigurationAction();
action.configId = 1.0;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateLogConfigurationAction.Result res = action.call();Python
SDK
UpdateLogConfigurationAction action = UpdateLogConfigurationAction()
action.configId = 1.0
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateLogConfigurationAction.Result res = action.call()添加日志服务器(AddLogServer)
添加日志服务器
API请求
URLs
POST zstack/v1/log/serversHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "log-server",
"description": "log server",
"category": "ManagementNodeLog",
"type": "Log4j2",
"level": "ALL",
"configuration": "{\n\"type\": \"Syslog\",\n\"configuration\": {\n\"hostname\": \"192.168.0.11\",\n\"port\": \"514\",\n\"protocol\": \"UDP\",\n\"facility\": \"LOCAL5\"\n}\n}"
},
"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":"log-server","description":"log server","category":"ManagementNodeLog","type":"Log4j2","level":"ALL","configuration":"{\n\"type\": \"Syslog\",\n\"configuration\": {\n\"hostname\": \"192.168.0.11\",\n\"port\": \"514\",\n\"protocol\": \"UDP\",\n\"facility\": \"LOCAL5\"\n}\n}"}}' http://localhost:8080/zstack/v1/log/servers参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| name | String | body(包含在params结构中) |
资源名称 | 5.1.0 | |
| description (可选) | String | body(包含在params结构中) |
资源的详细描述 | 5.1.0 | |
| category | String | body(包含在params结构中) |
日志类别(管理节点日志、平台操作日志) |
|
5.1.0 |
| type | String | body(包含在params结构中) |
日志类型 |
|
5.1.0 |
| level (可选) | String | body(包含在params结构中) |
级别 |
|
5.1.0 |
| configuration | String | body(包含在params结构中) |
日志具体配置 | 5.1.0 | |
| resourceUuid (可选) | String | body(包含在params结构中) |
资源UUID | 5.1.0 | |
| tagUuids (可选) | List | body(包含在params结构中) |
标签UUID列表 | 5.1.0 | |
| systemTags (可选) | List | body | 系统标签 | 5.1.0 | |
| userTags (可选) | List | body | 用户标签 | 5.1.0 |
API返回
返回示例
{
"inventory": {}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 5.1.0 | |
| inventory | LogServerInventory | 详情参考inventory | 5.1.0 |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 5.1.0 |
#inventory
#category
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| ManagementNodeLog | LogCategory | 5.1.0 | |
| PlatformOperationLog | LogCategory | 5.1.0 |
#type
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| Log4j2 | LogType | 5.1.0 | |
| FluentBit | LogType | 5.1.0 |
#level
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| OFF | LogLevel | 5.1.0 | |
| FATAL | LogLevel | 5.1.0 | |
| ERROR | LogLevel | 5.1.0 | |
| WARN | LogLevel | 5.1.0 | |
| INFO | LogLevel | 5.1.0 | |
| DEBUG | LogLevel | 5.1.0 | |
| TRACE | LogLevel | 5.1.0 | |
| ALL | LogLevel | 5.1.0 |
#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 |
SDK示例
Java SDK
AddLogServerAction action = new AddLogServerAction();
action.name = "log-server";
action.description = "log server";
action.category = "ManagementNodeLog";
action.type = "Log4j2";
action.level = "ALL";
action.configuration = "{
"type": "Syslog",
"configuration": {
"hostname": "192.168.0.11",
"port": "514",
"protocol": "UDP",
"facility": "LOCAL5"
}
}";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AddLogServerAction.Result res = action.call();Python SDK
action = AddLogServerAction()
action.name = "log-server"
action.description = "log server"
action.category = "ManagementNodeLog"
action.type = "Log4j2"
action.level = "ALL"
action.configuration = "{
"type": "Syslog",
"configuration": {
"hostname": "192.168.0.11",
"port": "514",
"protocol": "UDP",
"facility": "LOCAL5"
}
}"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()删除日志服务器(DeleteLogServer)
删除日志服务器
API请求
URLs
DELETE zstack/v1/log/serversHeaders
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/log/servers?uuid=cdc213d6ba25367ea6c4d201491d900c参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | query | 资源的UUID,唯一标示该资源 | 5.1.0 | |
| systemTags (可选) | List | query | 系统标签 | 5.1.0 | |
| userTags (可选) | List | query | 用户标签 | 5.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
DeleteLogServerAction action = new DeleteLogServerAction();
action.uuid = "cdc213d6ba25367ea6c4d201491d900c";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteLogServerAction.Result res = action.call();Python SDK
action = DeleteLogServerAction()
action.uuid = "cdc213d6ba25367ea6c4d201491d900c"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()查询日志服务器(QueryLogServer)
查询日志服务器
API请求
URLs
GET zstack/v1/log/servers
GET zstack/v1/log/servers/{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/log/servers?q=uuid=xxx&q=name=xxxcurl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X GET http://localhost:8080/zstack/v1/log/servers/9699713cfb583c70b749adca2c01a77b可查询字段
运行CLI命令行工具,输入QueryLogServer并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK示例
Java SDK
QueryLogServerAction action = new QueryLogServerAction();
action.conditions = asList("uuid=xxx","name=xxx");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryLogServerAction.Result res = action.call();Python SDK
action = QueryLogServerAction()
action.conditions = ["uuid=xxx","name=xxx"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()更新日志服务器(UpdateLogServer)
更新日志服务器
API请求
URLs
PUT zstack/v1/log/serversHeaders
Authorization: OAuth the-session-uuidBody
{
"updateLogServer": {
"uuid": "10bf3f837edf37a0be99a84d1edafb6b",
"name": "example"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X PUT -d '{"updateLogServer":{"uuid":"10bf3f837edf37a0be99a84d1edafb6b","name":"example"}}' http://localhost:8080/zstack/v1/log/servers参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | body(包含在updateLogServer结构中) |
资源的UUID,唯一标示该资源 | 5.1.0 | |
| name (可选) | String | body(包含在updateLogServer结构中) |
资源名称 | 5.1.0 | |
| description (可选) | String | body(包含在updateLogServer结构中) |
资源的详细描述 | 5.1.0 | |
| systemTags (可选) | List | body | 系统标签 | 5.1.0 | |
| userTags (可选) | List | body | 用户标签 | 5.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
UpdateLogServerAction action = new UpdateLogServerAction();
action.uuid = "10bf3f837edf37a0be99a84d1edafb6b";
action.name = "example";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateLogServerAction.Result res = action.call();Python SDK
action = UpdateLogServerAction()
action.uuid = "10bf3f837edf37a0be99a84d1edafb6b"
action.name = "example"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()SNMP相关接口
创建SNMP代理(CreateSnmpAgent)
API请求
URLs
POST zstack/v1/snmp/agentHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"version": "v3",
"userName": "zstack",
"authAlgorithm": "SHA512",
"authPassword": "auth_password",
"privacyAlgorithm": "DES",
"privacyPassword": "priv_password",
"port": 161
},
"systemTags": [],
"userTags": []
}
Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"version":"v3","userName":"zstack","authAlgorithm":"SHA512","authPassword":"auth_password","privacyAlgorithm":"DES","privacyPassword":"priv_password","port":161}}' \
http://localhost:8080/zstack/v1/snmp/agent参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| version | String | body(包含在params结构中) | SNMP代理使用协议版本 |
|
4.10.0 |
| readCommunity (可选) | String | body(包含在params结构中) | 读团体字(version为v2c时使用) | 4.10.0 | |
| userName (可选) | String | body(包含在params结构中) | 用户名(version为v3时使用) | 4.10.0 | |
| authAlgorithm (可选) | String | body(包含在params结构中) | 认证算法 |
|
4.10.0 |
| authPassword (可选) | String | body(包含在params结构中) | 认证密码 | 4.10.0 | |
| privacyAlgorithm (可选) | String | body(包含在params结构中) | 隐私算法 |
|
4.10.0 |
| privacyPassword (可选) | String | body(包含在params结构中) | 隐私密码 | 4.10.0 | |
| port | int | body(包含在params结构中) | 端口 | 4.10.0 | |
| resourceUuid (可选) | String | body(包含在params结构中) | 资源UUID | 4.10.0 | |
| tagUuids (可选) | List | body(包含在params结构中) | 标签UUID列表 | 4.10.0 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.0 | |
| userTags (可选) | List | body | 用户标签 | 4.10.0 |
API返回
返回示例
{
"inventory": {
"uuid": "6dac2a94d44c3216acc13286a50416aa",
"version": "v3",
"userName": "zstack",
"authAlgorithm": "SHA512",
"authPassword": "auth_password",
"privacyAlgorithm": "DES",
"privacyPassword": "priv_password",
"port": 161,
"status": "Enable",
"securityLevel": "authPriv"
}
}#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 4.10.0 |
| description | String | 错误的概要描述 | 4.10.0 |
| details | String | 错误的详细信息 | 4.10.0 |
| elaboration | String | 保留字段,默认为null | 4.10.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 4.10.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 4.10.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.10.0 |
| version | String | SNMP代理使用协议版本 | 4.10.0 |
| readCommunity | String | 读团体字(version为v2c时使用) | 4.10.0 |
| userName | String | 用户名(version为v3时使用) | 4.10.0 |
| authAlgorithm | String | 认证算法 | 4.10.0 |
| authPassword | String | 认证密码 | 4.10.0 |
| privacyAlgorithm | String | 隐私算法 | 4.10.0 |
| privacyPassword | String | 隐私密码 | 4.10.0 |
| port | int | 端口 | 4.10.0 |
| status | String | SNMP代理是否启用 | 4.10.0 |
| securityLevel | String | 安全等级 | 4.10.0 |
| createDate | Timestamp | 创建时间 | 4.10.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.10.0 |
SDK示例
Java
SDK
CreateSnmpAgentAction action = new CreateSnmpAgentAction();
action.version = "v3";
action.userName = "zstack";
action.authAlgorithm = "SHA512";
action.authPassword = "auth_password";
action.privacyAlgorithm = "DES";
action.privacyPassword = "priv_password";
action.port = 161;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateSnmpAgentAction.Result res = action.call();Python
SDK
CreateSnmpAgentAction action = CreateSnmpAgentAction()
action.version = "v3"
action.userName = "zstack"
action.authAlgorithm = "SHA512"
action.authPassword = "auth_password"
action.privacyAlgorithm = "DES"
action.privacyPassword = "priv_password"
action.port = 161
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateSnmpAgentAction.Result res = action.call()查询SNMP代理(QuerySnmpAgent)
API请求
URLs
GET zstack/v1/snmp/agent
GET zstack/v1/snmp/agent/{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/snmp/agentcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/snmp/agent/18c89b48e653385f83db6ecffb48763f可查询字段
运行CLI命令行工具,输入QueryLdapServer并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"uuid": "f0ef8d847b573c6b86565e1d9111723b",
"version": "v3",
"userName": "zstack",
"authAlgorithm": "SHA512",
"authPassword": "auth_password",
"privacyAlgorithm": "DES",
"privacyPassword": "priv_password",
"port": 161,
"status": "Enable",
"securityLevel": "authPriv"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 4.10.0 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 4.10.0 |
| inventories | List | 详情参考inventories | 4.10.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 4.10.0 |
| description | String | 错误的概要描述 | 4.10.0 |
| details | String | 错误的详细信息 | 4.10.0 |
| elaboration | String | 保留字段,默认为null | 4.10.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 4.10.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 4.10.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.10.0 |
| version | String | SNMP代理使用协议版本 | 4.10.0 |
| readCommunity | String | 读团体字(version为v2c时使用) | 4.10.0 |
| userName | String | 用户名(version为v3时使用) | 4.10.0 |
| authAlgorithm | String | 认证算法 | 4.10.0 |
| authPassword | String | 认证密码 | 4.10.0 |
| privacyAlgorithm | String | 隐私算法 | 4.10.0 |
| privacyPassword | String | 隐私密码 | 4.10.0 |
| port | int | 端口 | 4.10.0 |
| status | String | SNMP代理是否启用 | 4.10.0 |
| securityLevel | String | 安全等级 | 4.10.0 |
| createDate | Timestamp | 创建时间 | 4.10.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.10.0 |
SDK示例
Java
SDK
QuerySnmpAgentAction action = new QuerySnmpAgentAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QuerySnmpAgentAction.Result res = action.call();Python
SDK
QuerySnmpAgentAction action = QuerySnmpAgentAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QuerySnmpAgentAction.Result res = action.call()启动SNMP代理(StartSnmpAgent)
API请求
URLs
PUT zstack/v1/snmp/agent/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"startSnmpAgent": {
"uuid": "2e5ce17390a843da991411d27b67d775"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"startSnmpAgent":{"uuid":"955799e296a94e4aa2ce063a5b1ea4b8"}}' \
http://localhost:8080/zstack/v1/snmp/agent/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | body(包含在startSnmpAgent结构中) | 资源的UUID,唯一标示该资源 | 4.10.0 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.0 | |
| userTags (可选) | List | body | 用户标签 | 4.10.0 |
API返回
返回示例
{
"inventory": {
"uuid": "eef797ff89d84305b51cc3edcb597909",
"version": "v3",
"userName": "zstack",
"authAlgorithm": "SHA",
"authPassword": "authPassword",
"privacyAlgorithm": "AES128",
"privacyPassword": "privPassword",
"port": 162
}
}#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 4.10.0 |
| description | String | 错误的概要描述 | 4.10.0 |
| details | String | 错误的详细信息 | 4.10.0 |
| elaboration | String | 保留字段,默认为null | 4.10.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 4.10.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 4.10.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.10.0 |
| version | String | SNMP代理使用协议版本 | 4.10.0 |
| readCommunity | String | 读团体字(version为v2c时使用) | 4.10.0 |
| userName | String | 用户名(version为v3时使用) | 4.10.0 |
| authAlgorithm | String | 认证算法 | 4.10.0 |
| authPassword | String | 认证密码 | 4.10.0 |
| privacyAlgorithm | String | 隐私算法 | 4.10.0 |
| privacyPassword | String | 隐私密码 | 4.10.0 |
| port | int | 端口 | 4.10.0 |
| status | String | SNMP代理是否启用 | 4.10.0 |
| securityLevel | String | 安全等级 | 4.10.0 |
| createDate | Timestamp | 创建时间 | 4.10.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.10.0 |
SDK示例
Java
SDK
StartSnmpAgentAction action = new StartSnmpAgentAction();
action.uuid = "a74555a81a4244bb9ce0f8f2b5691ac5";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
StartSnmpAgentAction.Result res = action.call();Python
SDK
StartSnmpAgentAction action = StartSnmpAgentAction()
action.uuid = "56f7b7cc6f764c55bf4016cc2257f456"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
StartSnmpAgentAction.Result res = action.call()停止SNMP代理(StopSnmpAgent)
API请求
URLs
PUT zstack/v1/snmp/agent/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"stopSnmpAgent": {
"uuid": "253c4449901c49f9928d2d7fd2119715"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"stopSnmpAgent":{"uuid":"d3dcbba6129e497480af319ee4e42749"}}' \
http://localhost:8080/zstack/v1/snmp/agent/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | body(包含在stopSnmpAgent结构中) | 资源的UUID,唯一标示该资源 | 4.10.0 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.0 | |
| userTags (可选) | List | body | 用户标签 | 4.10.0 |
API返回
返回示例
{
"inventory": {
"uuid": "b32ac27ffdd03e7ea7857d318d5cfdd8",
"version": "v3",
"userName": "zstack",
"authAlgorithm": "SHA512",
"authPassword": "auth_password",
"privacyAlgorithm": "DES",
"privacyPassword": "priv_password",
"port": 161,
"status": "Enable",
"securityLevel": "authPriv"
}
}#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 4.10.0 |
| description | String | 错误的概要描述 | 4.10.0 |
| details | String | 错误的详细信息 | 4.10.0 |
| elaboration | String | 保留字段,默认为null | 4.10.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 4.10.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 4.10.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.10.0 |
| version | String | SNMP代理使用协议版本 | 4.10.0 |
| readCommunity | String | 读团体字(version为v2c时使用) | 4.10.0 |
| userName | String | 用户名(version为v3时使用) | 4.10.0 |
| authAlgorithm | String | 认证算法 | 4.10.0 |
| authPassword | String | 认证密码 | 4.10.0 |
| privacyAlgorithm | String | 隐私算法 | 4.10.0 |
| privacyPassword | String | 隐私密码 | 4.10.0 |
| port | int | 端口 | 4.10.0 |
| status | String | SNMP代理是否启用 | 4.10.0 |
| securityLevel | String | 安全等级 | 4.10.0 |
| createDate | Timestamp | 创建时间 | 4.10.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.10.0 |
SDK示例
Java
SDK
StopSnmpAgentAction action = new StopSnmpAgentAction();
action.uuid = "5b470e397e794dff84efa29375d9cef8";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
StopSnmpAgentAction.Result res = action.call();Python
SDK
StopSnmpAgentAction action = StopSnmpAgentAction()
action.uuid = "e48db055707445d3b70e8e52f7ee0ca3"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
StopSnmpAgentAction.Result res = action.call()更新SNMP代理(UpdateSnmpAgent)
API请求
URLs
PUT zstack/v1/snmp/agent/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"updateSnmpAgent": {
"version": "v2c",
"readCommunity": "zstack",
"port": 1161
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateSnmpAgent":{"version":"v2c","readCommunity":"zstack","port":1161}}' \
http://localhost:8080/zstack/v1/snmp/agent/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | body(包含在updateSnmpAgent结构中) | 资源的UUID,唯一标示该资源 | 4.10.0 | |
| version | String | body(包含在updateSnmpAgent结构中) | SNMP代理使用协议版本 |
|
4.10.0 |
| readCommunity (可选) | String | body(包含在updateSnmpAgent结构中) | 读团体字(version为v2c时使用) | 4.10.0 | |
| userName (可选) | String | body(包含在updateSnmpAgent结构中) | 用户名(version为v3时使用) | 4.10.0 | |
| authAlgorithm (可选) | String | body(包含在updateSnmpAgent结构中) | 认证算法 |
|
4.10.0 |
| authPassword (可选) | String | body(包含在updateSnmpAgent结构中) | 认证密码 | 4.10.0 | |
| privacyAlgorithm (可选) | String | body(包含在updateSnmpAgent结构中) | 隐私算法 |
|
4.10.0 |
| privacyPassword (可选) | String | body(包含在updateSnmpAgent结构中) | 隐私密码 | 4.10.0 | |
| port | int | body(包含在updateSnmpAgent结构中) | 端口 | 4.10.0 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.0 | |
| userTags (可选) | List | body | 用户标签 | 4.10.0 |
API返回
返回示例
{
"inventory": {
"uuid": "cad9965ebedd495aa1f5718f31da1aa8",
"version": "v3",
"userName": "zstack",
"authAlgorithm": "SHA",
"authPassword": "authPassword",
"privacyAlgorithm": "AES128",
"privacyPassword": "privPassword",
"port": 162
}
}#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 4.10.0 |
| description | String | 错误的概要描述 | 4.10.0 |
| details | String | 错误的详细信息 | 4.10.0 |
| elaboration | String | 保留字段,默认为null | 4.10.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 4.10.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 4.10.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.10.0 |
| version | String | SNMP代理使用协议版本 | 4.10.0 |
| readCommunity | String | 读团体字(version为v2c时使用) | 4.10.0 |
| userName | String | 用户名(version为v3时使用) | 4.10.0 |
| authAlgorithm | String | 认证算法 | 4.10.0 |
| authPassword | String | 认证密码 | 4.10.0 |
| privacyAlgorithm | String | 隐私算法 | 4.10.0 |
| privacyPassword | String | 隐私密码 | 4.10.0 |
| port | int | 端口 | 4.10.0 |
| status | String | SNMP代理是否启用 | 4.10.0 |
| securityLevel | String | 安全等级 | 4.10.0 |
| createDate | Timestamp | 创建时间 | 4.10.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.10.0 |
SDK示例
Java
SDK
UpdateSnmpAgentAction action = new UpdateSnmpAgentAction();
action.version = "v2c";
action.readCommunity = "zstack";
action.port = 1161;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateSnmpAgentAction.Result res = action.call();Python
SDK
UpdateSnmpAgentAction action = UpdateSnmpAgentAction()
action.version = "v2c"
action.readCommunity = "zstack"
action.port = 1161
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateSnmpAgentAction.Result res = action.call()时间管理相关接口
检查多个主机之间的网络连通性(CheckNetworkReachable)
API请求
URLs
GET zstack/v1/zops/check/networkHeaders
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/zops/check/network?sourceHostnames=172.0.0.1&targetHostnames=test1.com&targetHostnames=test2.com参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| sourceHostnames (可选) | List | query | 源指定ip地址或域名集合 | 4.7.21 | |
| targetHostnames | List | query | 目标ip地址或域名集合 | 4.7.21 | |
| systemTags (可选) | List | query | 系统标签 | 4.7.21 | |
| userTags (可选) | List | query | 用户标签 | 4.7.21 |
API返回
返回示例
{
"results": [
{
"sourceHostname": "172.0.0.1",
"targetHostname": "test2.com",
"status": "Disconnected"
},
{}
]
}#results
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| sourceHostname | String | 源地址 | 4.7.21 |
| targetHostname | String | 目标地址 | 4.7.21 |
| status | HostConnectedStatus | 详情参考status | 4.7.21 |
#status
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| Connected | HostConnectedStatus | 网络可达 | 4.7.21 |
| Disconnected | HostConnectedStatus | 网络不可达 | 4.7.21 |
| Unknown | HostConnectedStatus | 网络连接状态未知 | 4.7.21 |
#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 |
SDK示例
Java
SDK
CheckNetworkReachableAction action = new CheckNetworkReachableAction();
action.sourceHostnames = asList("172.0.0.1");
action.targetHostnames = asList("test1.com","test2.com");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CheckNetworkReachableAction.Result res = action.call();Python
SDK
CheckNetworkReachableAction action = CheckNetworkReachableAction()
action.sourceHostnames = [172.0.0.1]
action.targetHostnames = [test1.com, test2.com]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CheckNetworkReachableAction.Result res = action.call()获取当前chrony时间源服务器(GetChronyServers)
API请求
URLs
GET zstack/v1/zops/chrony/serversHeaders
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/zops/chrony/servers参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| systemTags (可选) | List | query | 系统标签 | 4.7.21 | |
| userTags (可选) | List | query | 用户标签 | 4.7.21 |
API返回
返回示例
{
"servers": [
{
"internal": {
"hostname": "172.0.0.1",
"status": "Connected"
},
"external": {
"hostname": "ntp.test.com",
"status": "Connected"
}
}
]
}#servers
#internal
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| hostname | String | 地址 | 4.7.21 |
| status | HostConnectedStatus | 详情参考status | 4.7.21 |
#status
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| Connected | HostConnectedStatus | 网络可达 | 4.7.21 |
| Disconnected | HostConnectedStatus | 网络不可达 | 4.7.21 |
| Unknown | HostConnectedStatus | 网络连接状态未知 | 4.7.21 |
#external
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| hostname | String | 地址 | 4.7.21 |
| status | HostConnectedStatus | 详情参考status | 4.7.21 |
#status
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| Connected | HostConnectedStatus | 网络可达 | 4.7.21 |
| Disconnected | HostConnectedStatus | 网络不可达 | 4.7.21 |
| Unknown | HostConnectedStatus | 网络连接状态未知 | 4.7.21 |
#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 |
SDK示例
Java
SDK
GetChronyServersAction action = new GetChronyServersAction();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetChronyServersAction.Result res = action.call();Python
SDK
GetChronyServersAction action = GetChronyServersAction()
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetChronyServersAction.Result res = action.call()同步chrony时间源返回(SyncChronyServers)
API请求
URLs
PUT zstack/v1/zops/chrony/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"syncChronyServers": {},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"syncChronyServers":{}}' \
http://localhost:8080/zstack/v1/zops/chrony/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| systemTags (可选) | List | body | 系统标签 | 4.7.21 | |
| userTags (可选) | List | body | 用户标签 | 4.7.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
SyncChronyServersAction action = new SyncChronyServersAction();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
SyncChronyServersAction.Result res = action.call();Python
SDK
SyncChronyServersAction action = SyncChronyServersAction()
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
SyncChronyServersAction.Result res = action.call()ss修改chrony时间源服务器(UpdateChronyServers)
API请求
URLs
PUT zstack/v1/zops/chrony/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"updateChronyServers": {
"internalHostnames": [
"172.0.0.1",
"172.0.0.2"
],
"externalHostnames": [
"test1.ntp.com"
]
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateChronyServers":{"internalHostnames":["172.0.0.1","172.0.0.2"],"externalHostnames":["test1.ntp.com"]}}' \
http://localhost:8080/zstack/v1/zops/chrony/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| internalHostnames (可选) | List | body(包含在updateChronyServers结构中) |
内部时间源集合 | 4.7.21 | |
| externalHostnames (可选) | List | body(包含在updateChronyServers结构中) |
外部时间源集合 | 4.7.21 | |
| systemTags (可选) | List | body | 系统标签 | 0.6 | |
| userTags (可选) | List | body | 用户标签 | 0.6 |
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
UpdateChronyServersAction action = new UpdateChronyServersAction();
action.internalHostnames = asList("172.0.0.1","172.0.0.2");
action.externalHostnames = asList("test1.ntp.com");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateChronyServersAction.Result res = action.call();Python
SDK
UpdateChronyServersAction action = UpdateChronyServersAction()
action.internalHostnames = [172.0.0.1, 172.0.0.2]
action.externalHostnames = [test1.ntp.com]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateChronyServersAction.Result res = action.call()系统参数相关接口
查询系统参数(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()获取系统参数选项(GetGlobalConfigOptions)
API请求
URLs
GET zstack/v1/global-configurations/{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/global-configurations/kvm/vm.cpuMode参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| category | String | url | 4.4.0 | ||
| name | String | url | 资源名称 | 4.4.0 | |
| systemTags (可选) | List | query | 系统标签 | 4.4.0 | |
| userTags (可选) | List | query | 用户标签 | 4.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
GetGlobalConfigOptionsAction action = new GetGlobalConfigOptionsAction();
action.category = "kvm";
action.name = "vm.cpuMode";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetGlobalConfigOptionsAction.Result res = action.call();Python
SDK
GetGlobalConfigOptionsAction action = GetGlobalConfigOptionsAction()
action.category = "kvm"
action.name = "vm.cpuMode"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetGlobalConfigOptionsAction.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()批量更新资源高级设置(UpdateResourceConfigs)
API请求
URLs
POST zstack/v1/resource-configurations/{resourceUuid}/resource-configs/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"resourceConfigs": [
{
"category": "vm",
"name": "cleanTraffic",
"value": "true"
}
]
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"resourceConfigs":[{"category":"vm","name":"cleanTraffic","value":"true"}]}}' \
http://localhost:8080/zstack/v1/resource-configurations/f4f8970eba3536a69fc2139456f383ae/resource-configs/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| resourceUuid | String | url | 设置的资源UUID | 4.7.0 | |
| resourceConfigs | List | body(包含在params结构中) |
资源的高级配置列表 | 4.7.0 | |
| systemTags (可选) | List | body | 系统标签 | 4.7.0 | |
| userTags (可选) | List | body | 用户标签 | 4.7.0 |
API返回
返回示例
{
"inventories": [
{
"value": "10",
"effectiveConfigs": [
{
"uuid": "9d7aeba3ff604f46b419475c0ade1538",
"resourceUuid": "378c6a50c9ee415baa4688fcd19f023a",
"resourceType": "ClusterVO",
"name": "cpu.overProvisioning.ratio",
"category": "host",
"value": "10",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
],
"name": "cpu.overProvisioning.ratio"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 4.7.0 | |
| inventories | List | 详情参考inventories | 4.7.0 |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 4.7.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| value | String | 4.7.0 | |
| name | String | 4.7.0 | |
| effectiveConfigs | List | 详情参考effectiveConfigs | 4.7.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
UpdateResourceConfigsAction action = new UpdateResourceConfigsAction();
action.resourceUuid = "f4f8970eba3536a69fc2139456f383ae";
action.resourceConfigs = asList([category:vm, name:cleanTraffic, value:true]);
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateResourceConfigsAction.Result res = action.call();Python
SDK
UpdateResourceConfigsAction action = UpdateResourceConfigsAction()
action.resourceUuid = "f4f8970eba3536a69fc2139456f383ae"
action.resourceConfigs = [[category:vm, name:cleanTraffic, value:true]]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateResourceConfigsAction.Result res = action.call()