存储服务
添加 ZStone(AddZStoneStorage)
API请求
URLs
POST zstack/v1/zstone-pluginHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "zstone-storage",
"username": "admin",
"managementIp": "172.0.0.1",
"logInPort": 4000,
"apiPort": 4010,
"logInUrl": "/sso/v1/accounts/login"
},
"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":"zstone-storage","username":"admin","managementIp":"172.0.0.1","logInPort":4000,"apiPort":4010,"logInUrl":"/sso/v1/accounts/login"}}' \
http://localhost:8080/zstack/v1/zstone-plugin参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| name | String | body(包含在params结构中) |
在 ZSphere 中这个 ZStone-Storage 的名称 | 4.10.6 | |
| username (可选) | String | body(包含在params结构中) |
登录使用的用户名,一般是 admin | 4.10.6 | |
| password (可选) | String | body(包含在params结构中) |
登录使用的密码 | 4.10.6 | |
| managementIp | String | body(包含在params结构中) |
ZStone 的管理节点 IP | 4.10.6 | |
| logInPort (可选) | int | body(包含在params结构中) |
ZStone 登录服务端口 | 4.10.6 | |
| apiPort (可选) | int | body(包含在params结构中) |
ZStone API 服务端口 | 4.10.6 | |
| logInUrl (可选) | String | body(包含在params结构中) |
ZStone 登录使用 URL | 4.10.6 | |
| resourceUuid (可选) | String | body(包含在params结构中) |
资源UUID | 4.10.6 | |
| tagUuids (可选) | List | body(包含在params结构中) |
标签UUID列表 | 4.10.6 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.6 | |
| userTags (可选) | List | body | 用户标签 | 4.10.6 |
API返回
返回示例
{
"inventory": {
"uuid": "53c0433a817349f89f66532addeb8b6c",
"name": "zstone-plugin",
"username": "admin",
"managementIp": "127.0.0.1",
"authorizationServer": "Local",
"logInPort": 4000,
"apiPort": 4010,
"logInUrl": "/sso/v1/accounts/login",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 创建是否成功 | 4.10.6 |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 4.10.6 |
#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 |
SDK示例
Java
SDK
AddZStoneAction action = new AddZStoneAction();
action.name = "zstone-storage";
action.username = "admin";
action.managementIp = "172.0.0.1";
action.logInPort = 4000;
action.apiPort = 4010;
action.logInUrl = "/sso/v1/accounts/login";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AddZStoneAction.Result res = action.call();Python
SDK
AddZStoneAction action = AddZStoneAction()
action.name = "zstone-storage"
action.username = "admin"
action.managementIp = "172.0.0.1"
action.logInPort = 4000
action.apiPort = 4010
action.logInUrl = "/sso/v1/accounts/login"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AddZStoneAction.Result res = action.call()移除 ZStone(RemoveZStone)
API请求
URLs
DELETE zstack/v1/zstone-plugin/{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/zstone-plugin/53c0433a817349f89f66532addeb8b6c参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | ZStone 的 UUID,唯一标示该资源 | 4.10.6 | |
| deleteMode (可选) | String | body | 删除模式(Permissive / Enforcing,Permissive) | 4.10.6 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.6 | |
| userTags (可选) | List | body | 用户标签 | 4.10.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
RemoveZStoneAction action = new RemoveZStoneAction();
action.uuid = "53c0433a817349f89f66532addeb8b6c";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
RemoveZStoneAction.Result res = action.call();Python
SDK
RemoveZStoneAction action = RemoveZStoneAction()
action.uuid = "53c0433a817349f89f66532addeb8b6c"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
RemoveZStoneAction.Result res = action.call()配置ZStone集群(UpdateZStoneClusterConfig)
API请求
URLs
PUT zstack/v1/zstone-plugin/config/clusterHeaders
Authorization: OAuth the-session-uuidBody
{
"updateZStoneClusterConfig": {
"uuid": "53c0433a817349f89f66532addeb8b6c",
"clusterName": "zstone-test",
"chronyIp": "172.26.30.113",
"publicNetworkCidr": "172.26.0.1/16",
"clusterNetworkCidr": "172.26.0.1/16",
"managementNetworkCidr": "172.26.0.1/16",
"force": false
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateZStoneClusterConfig":{"uuid":"53c0433a817349f89f66532addeb8b6c","clusterName":"zstone-test","chronyIp":"172.26.30.113","publicNetworkCidr":"172.26.0.1/16","clusterNetworkCidr":"172.26.0.1/16","managementNetworkCidr":"172.26.0.1/16","force":false}}' \
http://localhost:8080/zstack/v1/zstone-plugin/config/cluster参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | body(包含在updateZStoneClusterConfig结构中) |
ZStone 的 UUID,唯一标示该资源 | 4.10.6 | |
| clusterName | String | body(包含在updateZStoneClusterConfig结构中) |
ZStone 的集群名称 | 4.10.6 | |
| managementIp (可选) | String | body(包含在updateZStoneClusterConfig结构中) |
ZStone 的管理节点 IP | 4.10.6 | |
| chronyIp | String | body(包含在updateZStoneClusterConfig结构中) |
ZStone 的时间同步服务器 IP | 4.10.6 | |
| publicNetworkCidr | String | body(包含在updateZStoneClusterConfig结构中) |
ZStone 的公有网络 IP CIDR | 4.10.6 | |
| clusterNetworkCidr | String | body(包含在updateZStoneClusterConfig结构中) |
ZStone 的集群使用网络 IP CIDR | 4.10.6 | |
| managementNetworkCidrv | String | body(包含在updateZStoneClusterConfig结构中) |
ZStone 的管理网络 IP CIDR | 4.10.6 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.6 | |
| userTags (可选) | List | body | 用户标签 | 4.10.6 | |
| force (可选) | boolean | body(包含在updateZStoneClusterConfig结构中) |
是否强制添加 ZStone 集群. 一般情况下, ZStone 已有集群后再添加集群会出现意想不到的问题, 因此这里做了防呆 | 4.10.7 | |
| softwarePackageUuid | String | body(包含在updateZStoneClusterConfig结构中) |
分布式软件包UUID | 4.10.20 |
Note:
- 初始化软件包的参数。
- SystemTag格式:
initConfig::{%s} - SystemTag示例:
APIUpdateZStoneClusterConfigMsg转为json字符串
- SystemTag格式:
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
UpdateZStoneClusterConfigAction action = new UpdateZStoneClusterConfigAction();
action.uuid = "53c0433a817349f89f66532addeb8b6c";
action.clusterName = "zstone-test";
action.chronyIp = "172.26.30.113";
action.publicNetworkCidr = "172.26.0.1/16";
action.clusterNetworkCidr = "172.26.0.1/16";
action.managementNetworkCidr = "172.26.0.1/16";
action.force = false;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateZStoneClusterConfigAction.Result res = action.call();Python SDK
action = UpdateZStoneClusterConfigAction()
action.uuid = "53c0433a817349f89f66532addeb8b6c"
action.clusterName = "zstone-test"
action.chronyIp = "172.26.30.113"
action.publicNetworkCidr = "172.26.0.1/16"
action.clusterNetworkCidr = "172.26.0.1/16"
action.managementNetworkCidr = "172.26.0.1/16"
action.force = false
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()配置 ZStone 主机(UpdateZStoneHostConfig)
API请求
URLs
PUT zstack/v1/zstone-plugin/config/hostHeaders
Authorization: OAuth the-session-uuidBody
{
"updateZStoneHostConfig": {
"uuid": "53c0433a817349f89f66532addeb8b6c",
"hostPort": 22,
"hosts": [
{
"uuid": "11045d20c4ae4d079b68d9aa9bd93e45",
"managementIp": "172.30.3.21",
"publicIp": "192.168.4.21"
},
{
"uuid": "f76c6667db6a4c0bb220b895478effcc",
"managementIp": "172.30.3.22",
"publicIp": "192.168.4.22"
},
{
"uuid": "0f7f889aebf0575bb223fc4f547854ef",
"managementIp": "172.30.3.23",
"publicIp": "192.168.4.23"
}
],
"deployChrony": false,
"copySshKey": true,
"installWatch": true,
"updateHostname": true
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateZStoneHostConfig":{"uuid":"53c0433a817349f89f66532addeb8b6c","hostPort":22,"hosts":[{"uuid":"11045d20c4ae4d079b68d9aa9bd93e45","managementIp":"172.30.3.21","publicIp":"192.168.4.21"},{"uuid":"f76c6667db6a4c0bb220b895478effcc","managementIp":"172.30.3.22","publicIp":"192.168.4.22"},{"uuid":"0f7f889aebf0575bb223fc4f547854ef","managementIp":"172.30.3.23","publicIp":"192.168.4.23"}],"deployChrony":false,"copySshKey":true,"installWatch":true,"updateHostname":true}}' \
http://localhost:8080/zstack/v1/zstone-plugin/config/host参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | body(包含在updateZStoneHostConfig结构中) |
ZStone 的 UUID,唯一标示该资源 | 4.10.6 | |
| hostUsername | String | body(包含在updateZStoneHostConfig结构中) |
登录主机使用的用户名 | 4.10.6 | |
| hostPassword | String | body(包含在updateZStoneHostConfig结构中) |
登录主机使用的密码 | 4.10.6 | |
| hostPort (可选) | int | body(包含在updateZStoneHostConfig结构中) |
ZStone 主机 SSH 端口 | 4.10.6 | |
| hosts | List | body(包含在updateZStoneHostConfig结构中) |
ZStone 主机配置列表 | 4.10.6 | |
| deployChrony (可选) | boolean | body(包含在updateZStoneHostConfig结构中) |
是否配置时间同步服务 | 4.10.6 | |
| copySshKey (可选) | boolean | body(包含在updateZStoneHostConfig结构中) |
是否复制 SSH KEY | 4.10.6 | |
| installWatch (可选) | boolean | body(包含在updateZStoneHostConfig结构中) |
是否安装 Watch | 4.10.6 | |
| updateHostname (可选) | boolean | body(包含在updateZStoneHostConfig结构中) |
是否更新主机名 | 4.10.6 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.6 | |
| userTags (可选) | List | body | 用户标签 | 4.10.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
UpdateZStoneHostConfigAction action = new UpdateZStoneHostConfigAction();
action.uuid = "53c0433a817349f89f66532addeb8b6c";
action.hostPort = 22;
action.hosts = asList([uuid:11045d20c4ae4d079b68d9aa9bd93e45, managementIp:172.30.3.21, publicIp:192.168.4.21],[uuid:f76c6667db6a4c0bb220b895478effcc, managementIp:172.30.3.22, publicIp:192.168.4.22],[uuid:0f7f889aebf0575bb223fc4f547854ef, managementIp:172.30.3.23, publicIp:192.168.4.23]);
action.deployChrony = false;
action.copySshKey = true;
action.installWatch = true;
action.updateHostname = true;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateZStoneHostConfigAction.Result res = action.call();Python
SDK
UpdateZStoneHostConfigAction action = UpdateZStoneHostConfigAction()
action.uuid = "53c0433a817349f89f66532addeb8b6c"
action.hostPort = 22
action.hosts = [[uuid:11045d20c4ae4d079b68d9aa9bd93e45, managementIp:172.30.3.21, publicIp:192.168.4.21], [uuid:f76c6667db6a4c0bb220b895478effcc, managementIp:172.30.3.22, publicIp:192.168.4.22], [uuid:0f7f889aebf0575bb223fc4f547854ef, managementIp:172.30.3.23, publicIp:192.168.4.23]]
action.deployChrony = false
action.copySshKey = true
action.installWatch = true
action.updateHostname = true
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateZStoneHostConfigAction.Result res = action.call()测试 ZStone 连接性(ZStoneTestConnection)
API请求
URLs
PUT zstack/v1/zstone-plugin/test-connectionHeaders
Authorization: OAuth the-session-uuidBody
{
"zStoneTestConnection": {
"managementIp": "172.0.0.1",
"port": 4010,
"url": "/open/ping"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"zStoneTestConnection":{"managementIp":"172.0.0.1","port":4010,"url":"/open/ping"}}' \
http://localhost:8080/zstack/v1/zstone-plugin/test-connection参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| managementIp | String | body(包含在zStoneTestConnection结构中) |
ZStone 的管理节点 IP | 4.10.6 | |
| port (可选) | Integer | body(包含在zStoneTestConnection结构中) |
ZStone API 服务端口 | 4.10.6 | |
| url (可选) | String | body(包含在zStoneTestConnection结构中) |
ZStone 测试连接使用 URL | 4.10.6 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.6 | |
| userTags (可选) | List | body | 用户标签 | 4.10.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
ZStoneTestConnectionAction action = new ZStoneTestConnectionAction();
action.managementIp = "172.0.0.1";
action.port = 4010;
action.url = "/open/ping";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ZStoneTestConnectionAction.Result res = action.call();Python
SDK
ZStoneTestConnectionAction action = ZStoneTestConnectionAction()
action.managementIp = "172.0.0.1"
action.port = 4010
action.url = "/open/ping"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ZStoneTestConnectionAction.Result res = action.call()测试 ZCE-X 连接性(ZceXTestConnection)
API请求
URLs
PUT zstack/v1/zce-x-plugin/test-connectionHeaders
Authorization: OAuth the-session-uuidBody
{
"zceXTestConnection": {
"managementIp": "172.0.0.1",
"port": 8056,
"url": "/api/v1/cluster/time"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"zceXTestConnection":{"managementIp":"172.0.0.1","port":8056,"url":"/api/v1/cluster/time"}}' \
http://localhost:8080/zstack/v1/zce-x-plugin/test-connection参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| managementIp (可选) | String | body(包含在zceXTestConnection结构中) |
ZCE-X 的管理节点 IP | 4.10.7 | |
| port (可选) | Integer | body(包含在zceXTestConnection结构中) |
ZCE-X API 服务端口 | 4.10.7 | |
| uuid (可选) | String | body(包含在zceXTestConnection结构中) |
ZCE-X VO 的 UUID | 4.10.16 | |
| url (可选) | String | body(包含在zceXTestConnection结构中) |
ZCE-X 测试连接使用 URL | 4.10.7 | |
| adminToken (可选) | String | body(包含在zceXTestConnection结构中) |
ZCE-X 的 access-token, 如果要检查 access-token 是否可用的话可以填入 | 4.10.16 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.7 | |
| userTags (可选) | List | body | 用户标签 | 4.10.7 |
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
ZceXTestConnectionAction action = new ZceXTestConnectionAction();
action.managementIp = "172.0.0.1";
action.port = 8056;
action.url = "/api/v1/cluster/time";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ZceXTestConnectionAction.Result res = action.call();Python SDK
action = ZceXTestConnectionAction()
action.managementIp = "172.0.0.1"
action.port = 8056
action.url = "/api/v1/cluster/time"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()添加 ZCE-X(AddZceX)
API请求
URLs
POST zstack/v1/zce-x-pluginHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "zce-x-storage",
"managementIp": "172.0.0.1",
"apiPort": 8056
},
"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":"zce-x-storage","managementIp":"172.0.0.1","apiPort":8056}}' \
http://localhost:8080/zstack/v1/zce-x-plugin参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| name | String | body(包含在params结构中) |
ZCE-X 的名称 | 4.10.6 | |
| adminToken (可选) | String | body(包含在params结构中) |
接管 ZCE-X 使用的访问令牌。接管时必填,初始化前则不需要填写 | 4.10.6 | |
| managementIp (可选) | String | body(包含在params结构中) |
ZCE-X 的管理网 IP | 4.10.6 | |
| apiPort (可选) | int | body(包含在params结构中) |
ZCE-X 的 API 端口 | 4.10.6 | |
| resourceUuid (可选) | String | body(包含在params结构中) |
资源 UUID | 4.10.6 | |
| tagUuids (可选) | List | body(包含在params结构中) |
标签 UUID 列表 | 4.10.6 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.6 | |
| userTags (可选) | List | body | 用户标签 | 4.10.6 |
API返回
返回示例
{
"inventory": {
"uuid": "77e1393bf5aa4536a018b4c0c4e29c72",
"name": "zce-x-plugin",
"managementIp": "127.0.0.1",
"apiPort": 8056,
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
}#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.10.6 |
| name | String | 资源名称 | 4.10.6 |
| managementIp | String | 访问 ZCE-X 的 IP 地址 | 4.10.6 |
| apiPort | int | 访问 ZCE-X 的 API 端口 | 4.10.6 |
| createDate | Timestamp | 创建时间 | 4.10.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.10.6 |
#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 |
SDK示例
Java
SDK
AddZceXAction action = new AddZceXAction();
action.name = "zce-x-storage";
action.managementIp = "172.0.0.1";
action.apiPort = 8056;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AddZceXAction.Result res = action.call();Python
SDK
AddZceXAction action = AddZceXAction()
action.name = "zce-x-storage"
action.managementIp = "172.0.0.1"
action.apiPort = 8056
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AddZceXAction.Result res = action.call()创建 ZCE-X 报警平台(CreateZceXAlertPlatform)
API请求
URLs
POST zstack/v1/zce-x-plugin/{uuid}/alert-platformHeaders
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/zce-x-plugin/77e1393bf5aa4536a018b4c0c4e29c72/alert-platform参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | ZCE-X 信息的 UUID,唯一标示该资源 | 4.10.6 | |
| resourceUuid (可选) | String | body(包含在params结构中) |
资源 UUID | 4.10.6 | |
| tagUuids (可选) | List | body(包含在params结构中) |
标签 UUID 列表 | 4.10.6 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.6 | |
| userTags (可选) | List | body | 用户标签 | 4.10.6 |
API返回
返回示例
{
"thirdPartyPlatform": {
"uuid": "eec32b6fe11a464790641439f1d7c754",
"name": "xsky-172.20.11.24",
"type": "XSKY",
"url": "http://172.20.11.24:8086/alerts/?token\u003d001adb2ef25e41b7bd01b28651fcfa6a",
"template": "{\n \"product\":\"XSKY\",\n \"service\":\"XSKY\",\n \"message\":\"${resource_type + \u0027[\u0027 + resource_name+\u0027] \u0027 + group + \u0027 \u0027 + alert_value}\",\n \"metric\":\"${resource_type + \u0027::\u0027 + group}\",\n \"alertLevel\":\"${level \u003d\u003d \u0027info\u0027 ? \u0027Normal\u0027 : level \u003d\u003d \u0027warning\u0027 ? \u0027Important\u0027 : \u0027Emergent\u0027}\",\n \"alertTime\":\"${create}\",\n \"dimensions\":\"{\u0027resource_name\u0027:\u0027${resource_name}\u0027}\",\n \"dataSource\":\"xsky-172.20.196.185\"\n}",
"description": "desc",
"lastSyncDate": "Feb 18, 2025 7:52:39 AM",
"lastOpDate": "Feb 18, 2025 7:52:39 AM",
"createDate": "Feb 18, 2025 7:52:39 AM"
},
"inventory": {
"zceXUuid": "77e1393bf5aa4536a018b4c0c4e29c72",
"thirdPartyPlatformUuid": "eec32b6fe11a464790641439f1d7c754",
"createDate": "Nov 14, 2017 2:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 添加是否成功 | 4.10.6 |
| thirdPartyPlatform | ThirdpartyPlatformInventory | 详情参考thirdPartyPlatform | 4.10.6 |
| inventory | ZceXThirdPartyPlatformAlertRefInventory | 详情参考inventory | 4.10.6 |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 4.10.6 |
#thirdPartyPlatform
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 平台UUID | 3.10 |
| name | String | 平台名称 | 3.10 |
| type | String | 平台类型 | 3.10 |
| url | String | 平台地址 | 3.10 |
| template | String | 消息转换模板 | 3.10 |
| state | String | 平台状态 | 3.10 |
| description | String | 平台详细描述 | 3.10 |
| lastSyncDate | Timestamp | 上一次同步消息时间 | 3.10 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.10 |
| createDate | Timestamp | 创建时间 | 3.10 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| zceXUuid | String | ZCE-X 资源 UUID | 4.10.6 |
| thirdPartyPlatformUuid | String | 关联的第三方报警平台 UUID | 4.10.6 |
| createDate | Timestamp | 创建时间 | 4.10.6 |
#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 |
SDK示例
Java
SDK
CreateZceXAlertPlatformAction action = new CreateZceXAlertPlatformAction();
action.uuid = "77e1393bf5aa4536a018b4c0c4e29c72";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateZceXAlertPlatformAction.Result res = action.call();Python
SDK
CreateZceXAlertPlatformAction action = CreateZceXAlertPlatformAction()
action.uuid = "77e1393bf5aa4536a018b4c0c4e29c72"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateZceXAlertPlatformAction.Result res = action.call()删除 ZCE-X 报警平台(DeleteZceXAlertPlatform)
API请求
URLs
DELETE zstack/v1/zce-x-plugin/{uuid}/alert-platformHeaders
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/zce-x-plugin/77e1393bf5aa4536a018b4c0c4e29c72/alert-platform参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | ZCE-X 信息的 UUID,唯一标示该资源 | 4.10.6 | |
| deleteMode (可选) | String | body | 删除模式(Permissive / Enforcing,Permissive) | 4.10.6 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.6 | |
| userTags (可选) | List | body | 用户标签 | 4.10.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
DeleteZceXAlertPlatformAction action = new DeleteZceXAlertPlatformAction();
action.uuid = "77e1393bf5aa4536a018b4c0c4e29c72";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteZceXAlertPlatformAction.Result res = action.call();Python
SDK
DeleteZceXAlertPlatformAction action = DeleteZceXAlertPlatformAction()
action.uuid = "77e1393bf5aa4536a018b4c0c4e29c72"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteZceXAlertPlatformAction.Result res = action.call()获取 ZCE-X 性能和信息数据(GetZceXCapability)
API请求
URLs
GET zstack/v1/zce-x-plugin/capabilityHeaders
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/zce-x-plugin/capability?uuid=77e1393bf5aa4536a018b4c0c4e29c72参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | query | ZCE-X 信息的 UUID,唯一标示该资源 | 4.10.6 | |
| systemTags (可选) | List | query | 系统标签 | 4.10.6 | |
| userTags (可选) | List | query | 用户标签 | 4.10.6 |
API返回
返回示例
{
"licenses": {
"platform": {
"issuedTime": "2024-12-21T02:00:00Z",
"expiredTime": "2024-12-21T02:00:00Z",
"expired": false
}
},
"cluster": {
"managementNetworkCidr": "172.26.0.0/16",
"gatewayNetworkCidr": "172.26.0.0/16",
"publicNetworkCidr": "172.26.0.0/16",
"clusterNetworkCidr": "192.168.15.0/24",
"hosts": {
"count": 3,
"adminIps": [
"192.168.0.1",
"192.168.0.2",
"192.168.0.3"
]
},
"pools": {
"count": 3,
"totalCapacity": 2199023255552,
"inventories": [
{
"id": 3,
"poolName": "pool-7548ffce72794737b439a9f8e3b2da83"
},
{
"id": 2,
"poolName": "pool-3e9f6251332a433e8d48c2edc95eb142"
},
{
"id": 1,
"poolName": "pool-37194c3c7bd74bdb8594cf768c4e42bd"
}
]
}
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 获取操作是否成功 | 4.10.6 |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 4.10.6 |
#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 |
SDK示例
Java
SDK
GetZceXCapabilityAction action = new GetZceXCapabilityAction();
action.uuid = "77e1393bf5aa4536a018b4c0c4e29c72";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetZceXCapabilityAction.Result res = action.call();Python
SDK
GetZceXCapabilityAction action = GetZceXCapabilityAction()
action.uuid = "77e1393bf5aa4536a018b4c0c4e29c72"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetZceXCapabilityAction.Result res = action.call()查询 ZCE-X(QueryZceX)
API请求
URLs
GET zstack/v1/zce-x-plugin
GET zstack/v1/zce-x-plugin/{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/zce-x-plugin?q=name=zce-xcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/zce-x-plugin/7746a57778193dcd9201c12a6dbc20fb可查询字段
运行CLI命令行工具,输入QueryZceX并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"uuid": "77e1393bf5aa4536a018b4c0c4e29c72",
"name": "zce-x-plugin",
"managementIp": "127.0.0.1",
"apiPort": 8056,
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 查询是否成功 | 4.10.6 |
| inventories | List | 详情参考inventories | 4.10.6 |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 4.10.6 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.10.6 |
| name | String | 资源名称 | 4.10.6 |
| managementIp | String | 访问 ZCE-X 的 IP 地址 | 4.10.6 |
| apiPort | int | 访问 ZCE-X 的 API 端口 | 4.10.6 |
| createDate | Timestamp | 创建时间 | 4.10.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.10.6 |
#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 |
SDK示例
Java
SDK
QueryZceXAction action = new QueryZceXAction();
action.conditions = asList("name=zce-x");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryZceXAction.Result res = action.call();Python
SDK
QueryZceXAction action = QueryZceXAction()
action.conditions = ["name=zce-x"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryZceXAction.Result res = action.call()查询 ZCE-X 和第三方报警平台的关系(QueryZceXThirdPartyPlatformAlertRef)
API请求
URLs
GET zstack/v1/zce-x-plugin/alert-platformHeaders
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/zce-x-plugin/alert-platform?q=zceXUuid=77e1393bf5aa4536a018b4c0c4e29c72可查询字段
运行CLI命令行工具,输入QueryZceX并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"zceXUuid": "77e1393bf5aa4536a018b4c0c4e29c72",
"thirdPartyPlatformUuid": "eec32b6fe11a464790641439f1d7c754",
"createDate": "Nov 14, 2017 2:20:57 PM"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 查询是否成功 | 4.10.6 |
| inventories | List | 详情参考inventories | 4.10.6 |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 4.10.6 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| zceXUuid | String | ZCE-X 资源 UUID | 4.10.6 |
| thirdPartyPlatformUuid | String | 关联的第三方报警平台 UUID | 4.10.6 |
| createDate | Timestamp | 创建时间 | 4.10.6 |
#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 |
SDK示例
Java
SDK
QueryZceXThirdPartyPlatformAlertRefAction action = new QueryZceXThirdPartyPlatformAlertRefAction();
action.conditions = asList("zceXUuid=77e1393bf5aa4536a018b4c0c4e29c72");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryZceXThirdPartyPlatformAlertRefAction.Result res = action.call();Python
SDK
QueryZceXThirdPartyPlatformAlertRefAction action = QueryZceXThirdPartyPlatformAlertRefAction()
action.conditions = ["zceXUuid=77e1393bf5aa4536a018b4c0c4e29c72"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryZceXThirdPartyPlatformAlertRefAction.Result res = action.call()移除 ZCE-X(RemoveZceX)
API请求
URLs
DELETE zstack/v1/zce-x-plugin/{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/zce-x-plugin/77e1393bf5aa4536a018b4c0c4e29c72参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | ZCE-X 的 UUID,唯一标示该资源 | 4.10.6 | |
| deleteMode (可选) | String | body | 删除模式(Permissive / Enforcing,Permissive) | 4.10.6 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.6 | |
| userTags (可选) | List | body | 用户标签 | 4.10.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
RemoveZceXAction action = new RemoveZceXAction();
action.uuid = "77e1393bf5aa4536a018b4c0c4e29c72";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
RemoveZceXAction.Result res = action.call();Python
SDK
RemoveZceXAction action = RemoveZceXAction()
action.uuid = "77e1393bf5aa4536a018b4c0c4e29c72"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
RemoveZceXAction.Result res = action.call()配置 ZCE-X 集群(UpdateZceXClusterConfig)
API请求
URLs
PUT zstack/v1/zce-x-plugin/config/clusterHeaders
Authorization: OAuth the-session-uuidBody
{
"updateZceXClusterConfig": {
"uuid": "77e1393bf5aa4536a018b4c0c4e29c72",
"managementNetworkCidr": "172.26.30.1/24",
"publicNetworkCidr": "172.26.30.1/24",
"clusterNetworkCidr": "172.26.30.1/24",
"otherManagementIp": [
"172.26.30.113",
"172.26.30.202"
],
"username": "admin"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateZceXClusterConfig":{"uuid":"77e1393bf5aa4536a018b4c0c4e29c72","managementNetworkCidr":"172.26.30.1/24","publicNetworkCidr":"172.26.30.1/24","clusterNetworkCidr":"172.26.30.1/24","otherManagementIp":["172.26.30.113","172.26.30.202"],"username":"admin"}}' \
http://localhost:8080/zstack/v1/zce-x-plugin/config/cluster参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | body(包含在updateZceXClusterConfig结构中) |
ZCE-X 的 UUID,唯一标示该资源 | 4.10.6 | |
| managementIp (可选) | String | body(包含在updateZceXClusterConfig结构中) |
ZCE-X 的管理节点 IP。如果不填,默认为 ZceXVO.uuid | 4.10.6 | |
| managementNetworkCidr | String | body(包含在updateZceXClusterConfig结构中) |
ZCE-X 的管理网络 IP CIDR | 4.10.6 | |
| publicNetworkCidr | String | body(包含在updateZceXClusterConfig结构中) |
ZCE-X 的公有网络 IP CIDR | 4.10.6 | |
| clusterNetworkCidr | String | body(包含在updateZceXClusterConfig结构中) |
ZCE-X 的集群使用网络 IP CIDR | 4.10.6 | |
| gatewayNetworkCidr (可选) | String | body(包含在updateZceXClusterConfig结构中) |
ZCE-X 的网关使用网络 IP CIDR,默认使用共有网络 IP CIDR | 4.10.6 | |
| otherManagementIp | List | body(包含在updateZceXClusterConfig结构中) |
ZCE-X 的其它两个管理节点 IP,注意必须写两个,且各不相同。节点间需要做免密 | 4.10.6 | |
| otherStorageIp (可选) | List | body(包含在updateZceXClusterConfig结构中) |
ZCE-X 其它存储节点 IP 列表 | 4.10.6 | |
| username (可选) | String | body(包含在updateZceXClusterConfig结构中) |
ZCE-X 初始化时创建的管理员用户名 | 4.10.6 | |
| password (可选) | String | body(包含在updateZceXClusterConfig结构中) |
ZCE-X 初始化时创建的管理员密码 | 4.10.6 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.6 | |
| userTags (可选) | List | body | 用户标签 | 4.10.6 | |
| softwarePackageUuid | String | body(包含在updateZceXClusterConfig结构中) |
分布式软件包UUID | 4.10.20 |
Note:
- 初始化软件包的参数。
- SystemTag格式:
initConfig::{%s} - SystemTag示例:
APIUpdateZceXClusterConfigMsg转为json字符串
- SystemTag格式:
API返回
返回示例
{
"initSuccess": true,
"tokenCreated": true
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| clusterInitSuccess | boolean | 初始化是否成功 | 4.10.20 |
| tokenCreated | boolean | token生成是否成功 | 4.10.20 |
| success | boolean | 配置是否成功 | 4.10.6 |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 4.10.6 |
#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 |
SDK示例
Java SDK
UpdateZceXClusterConfigAction action = new UpdateZceXClusterConfigAction();
action.uuid = "77e1393bf5aa4536a018b4c0c4e29c72";
action.managementNetworkCidr = "172.26.30.1/24";
action.publicNetworkCidr = "172.26.30.1/24";
action.clusterNetworkCidr = "172.26.30.1/24";
action.otherManagementIp = asList("172.26.30.113","172.26.30.202");
action.username = "admin";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateZceXClusterConfigAction.Result res = action.call();Python SDK
action = UpdateZceXClusterConfigAction()
action.uuid = "77e1393bf5aa4536a018b4c0c4e29c72"
action.managementNetworkCidr = "172.26.30.1/24"
action.publicNetworkCidr = "172.26.30.1/24"
action.clusterNetworkCidr = "172.26.30.1/24"
action.otherManagementIp = [172.26.30.113, 172.26.30.202]
action.username = "admin"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()初始化Mini一体机(BootstrapMiniHost)
API请求
URLs
POST zstack/v1/mini-clusters/hostsHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"local": {
"sn": "RD-BJD-001-07311A",
"ipmi": {
"gw": "172.20.27.1",
"ip": "172.20.27.21/24",
"vlan": "27"
},
"mgmt": {
"gw": "172.20.26.1",
"ip": "172.20.26.21/24",
"vlan": "26",
"bond": "lacp"
}
},
"peer": {
"sn": "RD-BJD-001-07311B",
"mgmt": {
"gw": "172.20.26.1",
"ip": "172.20.26.22/24",
"vlan": "26",
"bond": "ab"
}
}
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"local":{"sn":"RD-BJD-001-07311A","ipmi":{"gw":"172.20.27.1","ip":"172.20.27.21/24","vlan":"27"},"mgmt":{"gw":"172.20.26.1","ip":"172.20.26.21/24","vlan":"26","bond":"lacp"}},"peer":{"sn":"RD-BJD-001-07311B","mgmt":{"gw":"172.20.26.1","ip":"172.20.26.22/24","vlan":"26","bond":"ab"}}}}' \
http://localhost:8080/zstack/v1/mini-clusters/hosts参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| local | MiniHostInfo | body(包含在params结构中) |
3.6.0 | ||
| peer | MiniHostInfo | body(包含在params结构中) |
3.6.0 | ||
| resourceUuid (可选) | String | body(包含在params结构中) |
3.6.0 | ||
| tagUuids (可选) | List | body(包含在params结构中) |
标签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"
}
}获取未添加的Mini主机(GetCandidateMiniHosts)
API请求
URLs
GET zstack/v1/mini-clusters/candidate-hostsHeaders
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/mini-clusters/candidate-hosts?local=false&configure=false参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| local (可选) | boolean | query | 3.6.0 | ||
| systemTags (可选) | List | query | 3.6.0 | ||
| userTags (可选) | List | query | 3.6.0 | ||
| configure (可选) | boolean | query | 0.6 |
API返回
返回示例
{
"hosts": [
{
"hostName": "zstack-mini-07311a",
"ipv4Address": "172.20.26.21",
"ipv6Address": "fe80::ae1f:6bff:fe93:9a72",
"ipv4Interface": "br_bond0_26",
"ipv6Interface": "br_bond0_26",
"manufacturer": "ZStack",
"product": "ZOHCN05",
"sn": "RD-BJD-001-07311A"
},
{
"hostName": "zstack-mini-07311b",
"ipv4Address": "172.20.26.22",
"ipv6Address": "fe80::ae1f:6bff:fe92:8a7a",
"ipv4Interface": "br_bond0_26",
"ipv6Interface": "br_bond0_26",
"manufacturer": "ZStack",
"product": "ZOHCN05",
"sn": "RD-BJD-001-07311B"
}
]
}#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 |
#hosts
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| hostName | String | Hostname | 3.6.0 |
| ipv4Address | String | IPv4地址 | 3.6.0 |
| ipv6Address | String | IPv6地址 | 3.6.0 |
| ipv4Interface | String | IPv4接口 | 3.6.0 |
| ipv6Interface | String | IPv6接口 | 3.6.0 |
| manufacturer | String | 厂商 | 3.6.0 |
| product | String | 型号 | 3.6.0 |
| sn | String | SN码 | 3.6.0 |
SDK示例
Java
SDK
GetCandidateMiniHostsAction action = new GetCandidateMiniHostsAction();
action.local = false;
action.configure = false;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetCandidateMiniHostsAction.Result res = action.call();Python
SDK
GetCandidateMiniHostsAction action = GetCandidateMiniHostsAction()
action.local = false
action.configure = false
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetCandidateMiniHostsAction.Result res = action.call()新建Mini集群(CreateMiniCluster)
API请求
URLs
POST zstack/v1/mini-clustersHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"zoneUuid": "45e31d9d03cc3528bce3a286e2284b2e",
"name": "cluster1",
"username": "root",
"sshPort": 22,
"description": "test",
"hypervisorType": "KVM"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/mini-clusters/candidate-hosts?local=false&configure=false参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| zoneUuid | String | body(包含在params结构中) |
数据中心UUID | 0.6 | |
| name | String | body(包含在params结构中) |
资源名称 | 0.6 | |
| hostManagementIps | List | body(包含在params结构中) |
0.6 | ||
| username (可选) | String | body(包含在params结构中) |
0.6 | ||
| password | String | body(包含在params结构中) |
0.6 | ||
| sshPort (可选) | int | body(包含在params结构中) |
0.6 | ||
| description (可选) | String | body(包含在params结构中) |
资源的详细描述 | 0.6 | |
| hypervisorType | String | body(包含在params结构中) |
|
0.6 | |
| resourceUuid (可选) | String | body(包含在params结构中) |
资源UUID | 0.6 | |
| tagUuids (可选) | List | body(包含在params结构中) |
标签UUID列表 | 3.4.0 | |
| systemTags (可选) | List | body | 系统标签 | 0.6 | |
| userTags (可选) | List | body | 用户标签 | 0.6 |
API返回
返回示例
{
"inventory": {
"name": "mini-cluster1",
"uuid": "7189b28ec2103b8387db01465c23c44d",
"description": "test",
"state": "Enabled",
"hypervisorType": "KVM",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM",
"zoneUuid": "eec8fdc928883758990e16608a50b12a",
"type": "zstack"
}
}#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| name | String | 资源名称 | 0.6 |
| uuid | String | 资源的UUID,唯一标示该资源 | 0.6 |
| description | String | 资源的详细描述 | 0.6 |
| state | String | 集群状态 | 0.6 |
| hypervisorType | String | 虚拟机管理程序类型 | 0.6 |
| createDate | Timestamp | 创建时间 | 0.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 0.6 |
| zoneUuid | String | 数据中心UUID | 0.6 |
| type | String | 保留域 | 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 |
SDK示例
Java
SDK
CreateMiniClusterAction action = new CreateMiniClusterAction();
action.zoneUuid = "45e31d9d03cc3528bce3a286e2284b2e";
action.name = "cluster1";
action.username = "root";
action.sshPort = 22;
action.description = "test";
action.hypervisorType = "KVM";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateMiniClusterAction.Result res = action.call();Python
SDK
CreateMiniClusterAction action = CreateMiniClusterAction()
action.zoneUuid = "45e31d9d03cc3528bce3a286e2284b2e"
action.name = "cluster1"
action.username = "root"
action.sshPort = 22
action.description = "test"
action.hypervisorType = "KVM"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateMiniClusterAction.Result res = action.call()清理软件包(CleanSoftwarePackage)
API请求
URLs
DELETE zstack/v1/software-package/{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/software-package/ff04e1736ec6391f9a1f023b524d0a00?deleteMode=Permissive参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 软件包UUID | 4.10.20 | |
| deleteMode (可选) | String | query | 删除模式(Permissive / Enforcing,Permissive) | 4.10.20 | |
| systemTags (可选) | List | query | 系统标签 | 4.10.20 | |
| userTags (可选) | List | query | 用户标签 | 4.10.20 |
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
CleanSoftwarePackageAction action = new CleanSoftwarePackageAction();
action.uuid = "ff04e1736ec6391f9a1f023b524d0a00";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CleanSoftwarePackageAction.Result res = action.call();Python SDK
action = CleanSoftwarePackageAction()
action.uuid = "ff04e1736ec6391f9a1f023b524d0a00"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()获取目录容量信息(GetDirectoryUsage)
API请求
URLs
GET zstack/v1/software-package/directory/usageHeaders
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/software-package/directory/usage?managementNodeUuid=ff000842a4673ab39dad7a3990df5300&directoryPath=/root/installPath/file参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| managementNodeUuid | String | query | 管理节点UUID | 4.10.20 | |
| directoryPath | String | query | 目录绝对路径 | 4.10.20 | |
| systemTags (可选) | List | query | 系统标签 | 4.10.20 | |
| userTags (可选) | List | query | 用户标签 | 4.10.20 |
API返回
返回示例
{
"totalCapacity": 1024,
"availableCapacity": 512
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| totalCapacity | long | 总容量 | 4.10.20 |
| availableCapacity | long | 可用容量 | 4.10.20 |
| success | boolean | 操作成功时为 true,否则为 false | 4.10.20 |
| error | ErrorCode | 详情参考error | 4.10.20 |
#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
GetDirectoryUsageAction action = new GetDirectoryUsageAction();
action.managementNodeUuid = "ff000842a4673ab39dad7a3990df5300";
action.directoryPath = "/root/installPath/file";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetDirectoryUsageAction.Result res = action.call();Python SDK
action = GetDirectoryUsageAction()
action.managementNodeUuid = "ff000842a4673ab39dad7a3990df5300"
action.directoryPath = "/root/installPath/file"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()获取上传软件包任务详情(GetUploadSoftwarePackageJobDetails)
API请求
URLs
GET zstack/v1/software-package/upload-jobs/details/{softwarePackageId}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/software-package/upload-jobs/details/ff04e1736ec6391f9a1f023b524d0a00参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| softwarePackageId | String | url | 软件包Id(默认为hash值) | 4.10.20 | |
| systemTags (可选) | List | query | 系统标签 | 4.10.20 | |
| userTags (可选) | List | query | 用户标签 | 4.10.20 |
API返回
返回示例
{
"existingJobDetails": [
{
"longJobUuid": "ff05232082b53f4f8e657884f462f600",
"longJobState": "Running",
"softwarePackageUuid": "ff04e1736ec6391f9a1f023b524d0a00",
"softwarePackageUploadUrl": "http://127.0.0.1:8001/host/file/upload",
"offset": 452984832
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 操作成功时为true,否则为false | 4.10.20 |
| existingJobDetails | List | 详情参考existingJobDetails | 4.10.20 |
| error | ErrorCode | 详情参考error | 4.10.20 |
#existingJobDetails
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| longJobUuid | String | 任务UUID | 4.10.20 |
| longJobState | String | 任务状态 | 4.10.20 |
| softwarePackageUuid | String | 软件包UUID | 4.10.20 |
| softwarePackageUploadUrl | String | 软件包上传URL | 4.10.20 |
| offset | long | 上传偏移量 | 4.10.20 |
#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
GetUploadSoftwarePackageJobDetailsAction action = new GetUploadSoftwarePackageJobDetailsAction();
action.softwarePackageId = "ff04e1736ec6391f9a1f023b524d0a00";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetUploadSoftwarePackageJobDetailsAction.Result res = action.call();Python SDK
action = GetUploadSoftwarePackageJobDetailsAction()
action.softwarePackageId = "ff04e1736ec6391f9a1f023b524d0a00"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()安装软件包(InstallSoftwarePackage)
API请求
URLs
PUT zstack/v1/software-package/install/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"installSoftwarePackage": {
"config": "{}"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"installSoftwarePackage":{"config":"{}"}}' \
http://localhost:8080/zstack/v1/software-package/install/ff04e1736ec6391f9a1f023b524d0a00/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 软件包UUID | 4.10.20 | |
| config (可选) | String | body(包含在installSoftwarePackage结构中) |
安装软件包配置 | 4.10.20 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.20 | |
| userTags (可选) | List | body | 用户标签 | 4.10.20 |
Note:
- 安装软件包的参数。
- SystemTag格式:
installConfig::{%s} - SystemTag示例:
APIInstallSoftwarePackageMsg转为json字符串
- SystemTag格式:
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
InstallSoftwarePackageAction action = new InstallSoftwarePackageAction();
action.uuid = "ff04e1736ec6391f9a1f023b524d0a00";
action.config = "{}";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
InstallSoftwarePackageAction.Result res = action.call();Python SDK
action = InstallSoftwarePackageAction()
action.uuid = "ff04e1736ec6391f9a1f023b524d0a00"
action.config = "{}"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()查询软件包(QuerySoftwarePackage)
API请求
URLs
GET zstack/v1/software-package
GET zstack/v1/software-package/{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/software-package?q=uuid=ff04e1736ec6391f9a1f023b524d0a00curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/software-package/dbe8d717b4f7335580774fabc403cc78可查询字段
运行CLI命令行工具,输入QuerySoftwarePackage并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"uuid": "53c0433a817349f89f66532addeb8b6c",
"name": "SoftwarePackage",
"hostUuid": "53c0433a817349f89f66532addeb8b61",
"managementNodeUuid": "53c0433a817349f89f66532addeb8b62",
"installPath": "/root/file/ZStone-common-installer-5.4.18-1932.tar.gz",
"unzipInstallPath": "/root/file/ZStone-common-installer-5.4.18-1932.tar.gz_2c1571fab770b5bab7f411d48aad5029_1762415407323/zstone-installer",
"type": "zstone",
"md5sum": "53c0433a817349f89f66532addeb8b63",
"status": "Uploaded",
"size": 1024,
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 4.10.20 | |
| inventories | List | 详情参考inventories | 4.10.20 |
| error | ErrorCode | 详情参考error | 4.10.20 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.10.20 |
| name | String | 资源名称 | 4.10.20 |
| hostUuid | String | 主机UUID | 4.10.20 |
| managementNodeUuid | String | 上传到管理节点UUID | 4.10.20 |
| installPath | String | 安装路径 | 4.10.20 |
| unzipInstallPath | String | 解压安装路径 | 4.10.20 |
| type | String | 安装包类型 | 4.10.20 |
| md5sum | String | 安装包MD5校验值 | 4.10.20 |
| status | String | 安装包状态 | 4.10.20 |
| size | long | 安装包大小 | 4.10.20 |
| createDate | Timestamp | 创建时间 | 4.10.20 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.10.20 |
#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
QuerySoftwarePackageAction action = new QuerySoftwarePackageAction();
action.conditions = asList("uuid=ff04e1736ec6391f9a1f023b524d0a00");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QuerySoftwarePackageAction.Result res = action.call();Python SDK
action = QuerySoftwarePackageAction()
action.conditions = ["uuid=ff04e1736ec6391f9a1f023b524d0a00"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()卸载软件包(UninstallSoftwarePackage)
API请求
URLs
PUT zstack/v1/software-package/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"uninstallSoftwarePackage": {},
"systemTags": [],
"userTags": []
}
Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"uninstallSoftwarePackage":{}}' \
http://localhost:8080/zstack/v1/software-package/ff04e1736ec6391f9a1f023b524d0a00/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 软件包UUID | 4.10.20 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.20 | |
| userTags (可选) | List | body | 用户标签 | 4.10.20 |
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
UninstallSoftwarePackageAction action = new UninstallSoftwarePackageAction();
action.uuid = "ff04e1736ec6391f9a1f023b524d0a00";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UninstallSoftwarePackageAction.Result res = action.call();Python SDK
action = UninstallSoftwarePackageAction()
action.uuid = "ff04e1736ec6391f9a1f023b524d0a00"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()上传软件包(UploadSoftwarePackage)
API请求
URLs
POST zstack/v1/software-packages/uploadHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "software-package-name",
"type": "storage",
"managementNodeUuid": "ff000842a4673ab39dad7a3990df5300",
"hostUuid": "ff0192fa70113da886101145c084bd00",
"url": "http://192.168.1.1/disk/images/test.qcow2",
"installPath": "/root/sds/storage.tar.gz"
},
"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":"software-package-name","type":"storage","managementNodeUuid":"ff000842a4673ab39dad7a3990df5300","hostUuid":"ff0192fa70113da886101145c084bd00","url":"http://192.168.1.1/disk/images/test.qcow2","installPath":"/root/sds/storage.tar.gz"}}' \
http://localhost:8080/zstack/v1/software-packages/upload参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| name | String | body(包含在params结构中) |
软件包名 | 4.10.20 | |
| type | String | body(包含在params结构中) |
软件包类型 | 4.10.20 | |
| managementNodeUuid | String | body(包含在params结构中) |
上传到管理节点UUID | 4.10.20 | |
| hostUuid | String | body(包含在params结构中) |
上传到主机UUID | 4.10.20 | |
| url | String | body(包含在params结构中) |
软件包URL | 4.10.20 | |
| installPath | String | body(包含在params结构中) |
软件包安装路径 | 4.10.20 | |
| resourceUuid (可选) | String | body(包含在params结构中) |
资源UUID | 4.10.20 | |
| tagUuids (可选) | List | body(包含在params结构中) |
标签UUID列表 | 4.10.20 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.20 | |
| userTags (可选) | List | body | 用户标签 | 4.10.20 |
Note:
- 本地上传软件支持指定软件包的hash。
- SystemTag格式:
uploadSoftwarePackage::{%s} - SystemTag示例:
uploadSoftwarePackage::1271232183768712367812361287
- SystemTag格式:
- 本地上传host返回UI上传软件包切片的URL。
- SystemTag格式:
uploadUrl::{%s} - SystemTag示例:
uploadUrl::http://172.1.1.1:7070/host/file/direct-upload
- SystemTag格式:
- 上传软件包的参数。
- SystemTag格式:
uploadConfig::{%s} - SystemTag示例:
APIUploadSoftwarePackageMsg转为json字符串
- SystemTag格式:
API返回
返回示例
{
"inventory": {
"size": 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 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.10.20 |
| name | String | 资源名称 | 4.10.20 |
| hostUuid | String | 主机UUID | 4.10.20 |
| managementNodeUuid | String | 上传到管理节点UUID | 4.10.20 |
| installPath | String | 安装路径 | 4.10.20 |
| unzipInstallPath | String | 解压安装路径 | 4.10.20 |
| type | String | 安装包类型 | 4.10.20 |
| md5sum | String | 安装包MD5校验值 | 4.10.20 |
| status | String | 安装包状态 | 4.10.20 |
| size | long | 安装包大小 | 4.10.20 |
| createDate | Timestamp | 创建时间 | 4.10.20 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.10.20 |
SDK示例
Java SDK
UploadSoftwarePackageAction action = new UploadSoftwarePackageAction();
action.name = "software-package-name";
action.type = "storage";
action.managementNodeUuid = "ff000842a4673ab39dad7a3990df5300";
action.hostUuid = "ff0192fa70113da886101145c084bd00";
action.url = "http://192.168.1.1/disk/images/test.qcow2";
action.installPath = "/root/sds/storage.tar.gz";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UploadSoftwarePackageAction.Result res = action.call();Python SDK
action = UploadSoftwarePackageAction()
action.name = "software-package-name"
action.type = "storage"
action.managementNodeUuid = "ff000842a4673ab39dad7a3990df5300"
action.hostUuid = "ff0192fa70113da886101145c084bd00"
action.url = "http://192.168.1.1/disk/images/test.qcow2"
action.installPath = "/root/sds/storage.tar.gz"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()上传并更新软件包(UploadAndExecuteSoftwareUpgradePackage)
API请求
URLs
POST zstack/v1/software-packages/backup-storage/{uuid}/upgradeHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"upgradeType": "Normal"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"upgradeType":"Normal"}}' \
http://localhost:8080/zstack/v1/software-packages/backup-storage/ff04e1736ec6391f9a1f023b524d0a00/upgrade参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 软件包资源的UUID | 5.0.0 | |
| backupStorageUuid (可选) | String | body(包含在params结构中) |
镜像存储UUID | 5.0.0 | |
| url (可选) | String | body(包含在params结构中) |
5.0.0 | ||
| installPath (可选) | String | body(包含在params结构中) |
5.0.0 | ||
| upgradeType (可选) | String | body(包含在params结构中) |
|
5.0.0 | |
| systemTags (可选) | List | body | 系统标签 | 5.0.0 | |
| userTags (可选) | List | body | 用户标签 | 5.0.0 |
API返回
该API成功时返回一个空的JSON结构
{},出错时返回的JSON结构包含一个error字段,例如:{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK示例
Java SDK
UploadAndExecuteSoftwareUpgradePackageAction action = new UploadAndExecuteSoftwareUpgradePackageAction();
action.uuid = "ff04e1736ec6391f9a1f023b524d0a00";
action.upgradeType = "Normal";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UploadAndExecuteSoftwareUpgradePackageAction.Result res = action.call();Python SDK
action = UploadAndExecuteSoftwareUpgradePackageAction()
action.uuid = "ff04e1736ec6391f9a1f023b524d0a00"
action.upgradeType = "Normal"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()上传软件包到镜像存储(UploadSoftwarePackageToBackupStorage)
API请求
URLs
POST zstack/v1/software-packages/backup-storage/uploadHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "software-package-name",
"type": "ZMigrate",
"backupStorageUuid": "ff081de062bd338eb907962028e64d00",
"url": "http://192.168.1.1/disk/images/test.qcow2",
"installPath": "/root/zmigrate.tar.gz"
},
"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":"software-package-name","type":"ZMigrate","backupStorageUuid":"ff081de062bd338eb907962028e64d00","url":"http://192.168.1.1/disk/images/test.qcow2","installPath":"/root/zmigrate.tar.gz"}}' \
http://localhost:8080/zstack/v1/software-packages/backup-storage/upload参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| name | String | body(包含在params结构中) |
资源名称 | 5.0.0 | |
| type | String | body(包含在params结构中) |
软件包类型 | 5.0.0 | |
| backupStorageUuid (可选) | String | body(包含在params结构中) |
镜像存储UUID | 5.0.0 | |
| url | String | body(包含在params结构中) |
软件包URL | 5.0.0 | |
| installPath | String | body(包含在params结构中) |
安装路径 | 5.0.0 | |
| resourceUuid (可选) | String | body(包含在params结构中) |
资源UUID | 5.0.0 | |
| tagUuids (可选) | String | body(包含在params结构中) |
标签UUID列表 | 5.0.0 | |
| systemTags (可选) | List | body | 系统标签 | 5.0.0 | |
| userTags (可选) | List | body | 用户标签 | 5.0.0 |
API返回
返回示例
{
"inventory": {
"size": 0
}
}#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.10.20 |
| name | String | 资源名称 | 4.10.20 |
| hostUuid | String | 主机UUID | 4.10.20 |
| managementNodeUuid | String | 上传到管理节点UUID | 4.10.20 |
| installPath | String | 安装路径 | 4.10.20 |
| unzipInstallPath | String | 解压安装路径 | 4.10.20 |
| type | String | 安装包类型 | 4.10.20 |
| md5sum | String | 安装包MD5校验值 | 4.10.20 |
| status | String | 安装包状态 | 4.10.20 |
| size | long | 安装包大小 | 4.10.20 |
| createDate | Timestamp | 创建时间 | 4.10.20 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.10.20 |
#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
UploadSoftwarePackageToBackupStorageAction action = new UploadSoftwarePackageToBackupStorageAction();
action.name = "software-package-name";
action.type = "ZMigrate";
action.backupStorageUuid = "ff081de062bd338eb907962028e64d00";
action.url = "http://192.168.1.1/disk/images/test.qcow2";
action.installPath = "/root/zmigrate.tar.gz";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UploadSoftwarePackageToBackupStorageAction.Result res = action.call();Python SDK
action = UploadSoftwarePackageToBackupStorageAction()
action.name = "software-package-name"
action.type = "ZMigrate"
action.backupStorageUuid = "ff081de062bd338eb907962028e64d00"
action.url = "http://192.168.1.1/disk/images/test.qcow2"
action.installPath = "/root/zmigrate.tar.gz"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()