文档目录

虚拟IP相关接口

创建虚拟IP(CreateVip)

API请求

URLs
POST zstack/v1/vips
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "name": "vip1",
    "l3NetworkUuid": "15788630ef6644af99c5378edf4e54da",
    "ipRangeUuid": "2e6e249189d83883aeb4c0fe79f82967",
    "requiredIp": "10.0.0.2"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"name":"vip1","l3NetworkUuid":"b75e7bddf2803f6c85f8450b01262546","ipRangeUuid":"2e6e249189d83883aeb4c0fe79f82967","requiredIp":"10.0.0.2"}}' http://localhost:8080/zstack/v1/vips
参数列表
名字 类型 位置 描述 可选值 起始版本
name String body(包含在params结构中) 资源名称 0.6
description (可选) String body(包含在params结构中) 资源的详细描述 0.6
l3NetworkUuid String body(包含在params结构中) 使用虚拟IP网络服务的三层网络UUID 0.6
ipRangeUuid (可选) String body(包含在params结构中) IP段UUID 3.9.0
allocatorStrategy (可选) String body(包含在params结构中) 分配策略
  • DefaultHostAllocatorStrategy
  • LastHostPreferredAllocatorStrategy
  • LeastVmPreferredHostAllocatorStrategy
  • MinimumCPUUsageHostAllocatorStrategy
  • MinimumMemoryUsageHostAllocatorStrategy
  • MaxInstancePerHostHostAllocatorStrategy
0.6
requiredIp (可选) String body(包含在params结构中) 请求的IP 0.6
resourceUuid (可选) String body(包含在params结构中) 资源UUID 0.6
systemTags (可选) List body 系统标签 0.6
userTags (可选) List body 用户标签 0.6

API返回

返回示例
 {
  "inventory": {
    "uuid": "45a2700283f039a39f40100505a68609",
    "name": "vip1",
    "ipRangeUuid": "da8d443f5c923c969118721845891d53",
    "l3NetworkUuid": "e43b5613fd8039ee888cca53dae87341",
    "ip": "192.168.0.1",
    "state": "Enabled",
    "gateway": "127.0.0.1",
    "netmask": "255.255.0.0",
    "peerL3NetworkUuids": [
      "1f970d11e2be3b0da5ad65cd4d20a549"
    ],
    "system": false
  }
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 0.6
inventory VipInventory 详情参考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
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 0.6
name String 资源名称 0.6
description String 资源的详细描述 0.6
l3NetworkUuid String 使用虚拟IP网络服务的三层网络UUID 0.6
ip String IPv4类型的IP地址 0.6
state String 状态(启用,禁用) 0.6
gateway String 网关 0.6
netmask String 子网掩码 0.6
prefixLen Integer 掩码长度 3.1.0
serviceProvider String 提供VIP服务的服务提供者 0.6
peerL3NetworkUuids List 提供VIP服务的L3网络UUID 0.6
useFor String 用途,例如:端口转发 0.6
system boolean 是否系统创建 3.9.0
createDate Timestamp 创建时间 0.6
lastOpDate Timestamp 最后一次修改时间 0.6
servicesRefs List 详情参考servicesRefs 0.6
#servicesRefs
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 3.9.0
serviceType String 服务类型 3.9.0
vipUuid String VIP UUID 3.9.0
createDate Timestamp 创建时间 3.9.0
lastOpDate Timestamp 最后一次修改时间 3.9.0

SDK示例

Java SDK
CreateVipAction action = new CreateVipAction();
action.name = "vip1";
action.l3NetworkUuid = "b75e7bddf2803f6c85f8450b01262546";
action.ipRangeUuid = "2e6e249189d83883aeb4c0fe79f82967";
action.requiredIp = "10.0.0.2";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateVipAction.Result res = action.call();
Python SDK
CreateVipAction action = CreateVipAction()
action.name = "vip1"
action.l3NetworkUuid = "b75e7bddf2803f6c85f8450b01262546"
action.ipRangeUuid = "2e6e249189d83883aeb4c0fe79f82967"
action.requiredIp = "10.0.0.2"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateVipAction.Result res = action.call()

删除虚拟IP(DeleteVip)

API请求

URLs
DELETE zstack/v1/vips/{uuid}?deleteMode={deleteMode}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 191031ca5ac34d5e92e1a86cde878edf" \
-X DELETE http://localhost:8080/zstack/v1/vips/38791fa2927b459cbeff033db96c3479?deleteMode=Permissive
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 资源的UUID,唯一标示该资源 0.6
deleteMode (可选) String body 删除模式 0.6
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
DeleteVipAction action = new DeleteVipAction();
action.uuid = "8da4c26b4089423f93cbce8ab804f9e9";
action.deleteMode = "Permissive";
action.sessionId = "772f7846b7c24d9b933deb8b03fc3024";
DeleteVipAction.Result res = action.call();
Python SDK
DeleteVipAction action = DeleteVipAction()
action.uuid = "addc2d7cb578402f9ce1569402338c1b"
action.deleteMode = "Permissive"
action.sessionId = "429360288ef140afaeb86961b638ea62"
DeleteVipAction.Result res = action.call()

查询虚拟IP(QueryVip)

API请求

URLs
GET zstack/v1/vips
GET zstack/v1/vips/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth fbe1443215334b0aa609b5417f5f36ab" \
-X GET http://localhost:8080/zstack/v1/vips?q=uuid=ba1cf7be9f20433fa5091bec091ba22d
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 39036aee2ef641afac5b253aae2377be" \
-X GET http://localhost:8080/zstack/v1/vips/a077653982cb422daa06e6c2d840b140

可查询字段

运行CLI命令行工具,输入QueryVip并按Tab键查看所有可查询字段以及可跨表查询的资源名。

API返回

返回示例
{
  "inventories": [
    {
      "uuid": "8c5eb4938be549218fda4c87de4d8cad",
      "name": "new name",
      "ipRangeUuid": "7d0dda5b1c4f40069ec4cfd6b66bdf48",
      "l3NetworkUuid": "a81054a6807e47a09922473e9ab376cb",
      "ip": "192.168.0.1",
      "state": "Enabled",
      "gateway": "127.0.0.1",
      "netmask": "255.255.0.0",
      "peerL3NetworkUuid": [
        "64ef7a2ea9ec4095b343ea239a7ba344"
      ]
    }
  ]
}
名字 类型 描述 起始版本
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
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 0.6
name String 资源名称 0.6
description String 资源的详细描述 0.6
l3NetworkUuid String 三层网络UUID 0.6
ip String IPv4类型的IP地址 0.6
state String 状态(启用,禁用) 0.6
gateway String 网关 0.6
netmask String 子网掩码 0.6
prefixLen String 掩码长度 3.1.0
serviceProvider String 提供VIP服务的服务提供者 0.6
peerL3NetworkUuid String L3网络UUID 0.6
useFor String 用途,例如:端口转发 0.6
createDate Timestamp 创建时间 0.6
lastOpDate Timestamp 最后一次修改时间 0.6

SDK示例

Java SDK
QueryVipAction action = new QueryVipAction();
action.conditions = asList("uuid=0a573b1c687246ff970c04ef5d0eaf07");
action.sessionId = "bf2f206d12d742d3a9182ea663e12265";
QueryVipAction.Result res = action.call();
Python SDK
QueryVipAction action = QueryVipAction()
action.conditions = ["uuid=5a3bf1e979944ea4a958fdac5a8bcef2"]
action.sessionId = "bc563fd71d014e84a49f1d280ef020ff"
QueryVipAction.Result res = action.call()

检查虚拟IP端口可用性(CheckVipPortAvailability)

API请求

URLs
GET zstack/v1/vips/{vipUuid}/check-port-availability
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json";charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET -d '{"params":{"vipUuid":"b75e7bddf2803f6c85f8450b01262546","protocolType":"TCP","port":5}}' http://localhost:8080/zstack/v1/vips/e6ac71f8cf433c51822bedea67cf4781//check-port-availability
参数列表
名字 类型 位置 描述 可选值 起始版本
vipUuid String body(包含在params结构中) 资源的UUID,唯一标示该资源 4.7.21
protocolType String body(包含在params结构中) 协议名称 4.7.21
port int body(包含在params结构中) 查询端口 4.7.21

API返回

返回示例
{
  "available":true
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.7.21
available boolean Java内置数据类型 4.7.21
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.7.21
description String 错误的概要描述 4.7.21
details String 错误的详细信息 4.7.21
elaboration String 保留字段,默认为null 4.7.21
opaque LinkedHashMap 保留字段,默认为null 4.7.21
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.7.21

SDK示例

Java SDK
CheckVipPortAvailabilityAction action = new CheckVipPortAvailabilityAction();
action.vipUuid = "e6ac71f8cf433c51822bedea67cf4781";
action.protocolType = "TCP";
action.port = 5;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CheckVipPortAvailabilityAction.Result res = action.call();
Python SDK
CheckVipPortAvailabilityAction action = new CheckVipPortAvailabilityAction();
action.vipUuid = "e6ac71f8cf433c51822bedea67cf4781";
action.protocolType = "TCP";
action.port = 5;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CheckVipPortAvailabilityAction.Result res = action.call();

获取虚拟IP可用端口(GetVipAvailablePort)

API请求

URLs
GET zstack/v1/vips/{vipUuid}/get-port-availability
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json";charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \-X GET -d '{"params":{"vipUuid":"b75e7bddf2803f6c85f8450b01262546","protocolType":"TCP","start":5,"limit":20}}' http://localhost:8080/zstack/v1/vips/e6ac71f8cf433c51822bedea67cf4781/get-port-availability
参数列表
名字 类型 位置 描述 可选值 起始版本
vipUuid String body(包含在params结构中) 资源的UUID,唯一标示该资源 4.7.21
protocolType String body(包含在params结构中) 协议名称 4.7.21
start(可选) Integer body(包含在params结构中) 查询开始下标 4.7.21
limit(可选) Integer body(包含在params结构中) 查询长度 4.7.21

API返回

返回示例
{
  "availablePort":[1,2,3]
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.7.21
availablePort List Java内置数据类型 4.7.21
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.7.21
description String 错误的概要描述 4.7.21
details String 错误的详细信息 4.7.21
elaboration String 保留字段,默认为null 4.7.21
opaque LinkedHashMap 保留字段,默认为null 4.7.21
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.7.21

SDK示例

Java SDK
GetVipAvailablePortAction action = new GetVipAvailablePortAction();
action.vipUuid = "e6ac71f8cf433c51822bedea67cf4781";
action.protocolType = "TCP";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetVipAvailablePortAction.Result res = action.call();
Python SDK
GetVipAvailablePortAction action = new GetVipAvailablePortAction();
action.vipUuid = "e6ac71f8cf433c51822bedea67cf4781";
action.protocolType = "TCP";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetVipAvailablePortAction.Result res = action.call();

更新虚拟IP(UpdateVip)

API请求

URLs
PUT zstack/v1/vips/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "updateVip": {
    "name": "new name"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateVip":{"name":"new name"}}' \
http://localhost:8080/zstack/v1/vips/cb7f47adc9e0386d952990c88835048c/actions
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 资源的UUID,唯一标示该资源 0.6
name (可选) String body(包含在updateVip结构中) 资源名称 0.6
description (可选) String body(包含在updateVip结构中) 资源的详细描述 0.6
systemTags (可选) List body 系统标签 0.6
userTags (可选) List body 用户标签 0.6

API返回

返回示例
{
  "inventory": {
    "uuid": "afc62fc544524344804c558156b57938",
    "name": "new name",
    "ipRangeUuid": "cbe101ec40844785ac64f0693e56122a",
    "l3NetworkUuid": "06272fa02c0b4776a0fb1bab6171ba34",
    "ip": "192.168.0.1",
    "state": "Enabled",
    "gateway": "127.0.0.1",
    "netmask": "255.255.0.0",
    "peerL3NetworkUuid": [
      "e35c8f6a65d14e8492e6fb72382dc1b4"
    ]
  }
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 0.6
inventory VipInventory 详情参考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
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 0.6
name String 资源名称 0.6
description String 资源的详细描述 0.6
l3NetworkUuid String 三层网络UUID 0.6
ip String IPv4类型的IP地址 0.6
state String 状态(启用,禁用) 0.6
gateway String 网关 0.6
netmask String 子网掩码 0.6
prefixLen String 掩码长度 3.1.0
serviceProvider String 提供VIP服务的服务提供者 0.6
peerL3NetworkUuid String L3网络UUID 0.6
useFor String 用途,例如:端口转发 0.6
createDate Timestamp 创建时间 0.6
lastOpDate Timestamp 最后一次修改时间 0.6

SDK示例

Java SDK
UpdateVipAction action = new UpdateVipAction();
action.uuid = "dbea243ee5c04eb5b68f8905baec42c6";
action.name = "new name";
action.sessionId = "b9f7110e36c147e7abcfbd0215c56368";
UpdateVipAction.Result res = action.call();
Python SDK
UpdateVipAction action = UpdateVipAction()
action.uuid = "620313f8f6724571addc8ef00959d951"
action.name = "new name"
action.sessionId = "4632313cde0a4cbaa67c7ff2109ebe60"
UpdateVipAction.Result res = action.call()

更改虚拟IP启用状态(ChangeVipState)

API请求

URLs
PUT zstack/v1/vips/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "changeVipState": {
    "stateEvent": "enable"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"changeVipState":{"stateEvent":"enable"}}' \
http://localhost:8080/zstack/v1/vips/5dae8db6e42831a1a219768d1f16abb5/actions
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 资源的UUID,唯一标示该资源 0.6
stateEvent String body(包含在changeVipState结构中) 状态事件
  • enable
  • disable
0.6
systemTags (可选) List body 系统标签 0.6
userTags (可选) List body 用户标签 0.6

API返回

返回示例
{
  "inventory": {
    "uuid": "50be5da2ebcc41b1aa0413b611f2a723",
    "name": "vip1",
    "ipRangeUuid": "6c8c280a596846a3967c1202cc049770",
    "l3NetworkUuid": "df62c1dedde04fffbd591dc737a10772",
    "ip": "192.168.0.1",
    "state": "Enabled",
    "gateway": "127.0.0.1",
    "netmask": "255.255.0.0",
    "peerL3NetworkUuid": [
      "bdb49f66946143538608b8feb6b3c35a"
    ]
  }
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 0.6
inventory VipInventory 详情参考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
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 0.6
name String 资源名称 0.6
description String 资源的详细描述 0.6
l3NetworkUuid String 三层网络UUID 0.6
ip String IPv4类型的IP地址 0.6
state String 状态(启用,禁用) 0.6
gateway String 网关 0.6
netmask String 子网掩码 0.6
prefixLen String 掩码长度 3.1.0
serviceProvider String 提供VIP服务的服务提供者 0.6
peerL3NetworkUuid String L3网络UUID 0.6
useFor String 用途,例如:端口转发 0.6
createDate Timestamp 创建时间 0.6
lastOpDate Timestamp 最后一次修改时间 0.6

SDK示例

Java SDK
ChangeVipStateAction action = new ChangeVipStateAction();
action.uuid = "2165a4d5e45441088244ff4fa3614412";
action.stateEvent = "enable";
action.sessionId = "2e1079fe6f4f45dab2f97f86d5a0fbc8";
ChangeVipStateAction.Result res = action.call();
Python SDK
ChangeVipStateAction action = ChangeVipStateAction()
action.uuid = "0191aa0014ae4b24ac7a87886a6d5527"
action.stateEvent = "enable"
action.sessionId = "1549fc2b0547482fb562020512ad89b6"
ChangeVipStateAction.Result res = action.call()

获取虚拟IP所有业务端口列表(GetVipUsedPorts)

获取虚拟IP上所有业务的端口列表。业务类型包含负载均衡、端口转发、IPsec隧道。

API请求

URLs
GET zstack/v1/vips/{uuid}/usedports
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth e7b86195e5f74c698dc5d0521b0ad25d" \
-X GET http://localhost:8080/zstack/v1/vips/d8474e0dbfe84d47a449bb34979cbcb9/usedports?protocol=TCP
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String query VIP UUID 2.2
protocol String query 协议
  • tcp
  • udp
2.2
systemTags (可选) List query 2.2
userTags (可选) List query 2.2

API返回

返回示例
{
  "inventories": [
    {
      "uuid": "4f5f926580f4452a897b05b8f99e67ec",
      "protcol": "TCP",
      "usedPorts": [
        "100",
        "200",
        "201",
        "202",
        "204",
        "1000"
      ]
    }
  ]
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 2.2
inventories List 详情参考inventories 2.2
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 2.2
description String 错误的概要描述 2.2
details String 错误的详细信息 2.2
elaboration String 保留字段,默认为null 2.2
opaque LinkedHashMap 保留字段,默认为null 2.2
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 2.2
#inventories
名字 类型 描述 起始版本
uuid String VIP UUID 2.2
protcol String 2.2
usedPorts List 2.2

SDK示例

Java SDK
GetVipUsedPortsAction action = new GetVipUsedPortsAction();
action.uuid = "771a6f6fae9d49dca26ae309d137549e";
action.protocol = "TCP";
action.sessionId = "ef2bbc8896fa4368a4da1c4b2e39a9d8";
GetVipUsedPortsAction.Result res = action.call();
Python SDK
GetVipUsedPortsAction action = GetVipUsedPortsAction()
action.uuid = "66313677af4e42fe8926703d89cf0164"
action.protocol = "TCP"
action.sessionId = "62f7ea6470954497966345142873bbfa"
GetVipUsedPortsAction.Result res = action.call()

设置虚拟IP限速(SetVipQos)

API请求

URLs
PUT zstack/v1/vips/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "setVipQos": {
    "port": 22.0,
    "outboundBandwidth": 1048576.0,
    "inboundBandwidth": 1048576.0
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"setVipQos":{"port":22.0,"outboundBandwidth":1048576.0,"inboundBandwidth":1048576.0}}' \
http://localhost:8080/zstack/v1/vips/9b500046ab303d42a8d8a17565b5673b/actions
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 资源的UUID,唯一标示该资源 2.3
port (可选) Integer body(包含在setVipQos结构中) 端口 2.3
outboundBandwidth (可选) Long body(包含在setVipQos结构中) 出流量带宽限制 2.3
inboundBandwidth (可选) Long body(包含在setVipQos结构中) 入流量带宽限制。对于参数inboundBandwidth和outboundBandwidth,两者至少要设置一个。 2.3
systemTags (可选) List body 系统标签 2.3
userTags (可选) List body 用户标签 2.3
Note: 对于参数inboundBandwidthoutboundBandwidth,两者至少要设置一个。

API返回

返回示例
{
  "inventory": {
    "uuid": "dd9459fe90ff4ae0b26ab3cbf1f1e3a2",
    "vipUuid": "e82e583934b441aaaf37039ff5eba877",
    "port": 80.0,
    "inboundBandwidth": 1048576.0,
    "outboundBandwidth": 1048576.0
  }
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 2.3
inventory VipQosInventory 详情参考inventory 2.3
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 2.3
description String 错误的概要描述 2.3
details String 错误的详细信息 2.3
elaboration String 保留字段,默认为null 2.3
opaque LinkedHashMap 保留字段,默认为null 2.3
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 2.3
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 2.3
vipUuid String 虚拟IP UUID 2.3
port Integer 端口 2.3
inboundBandwidth Long 出流量带宽限制 2.3
outboundBandwidth Long 入流量带宽限制 2.3
type String 限速单位类型 2.3
createDate Timestamp 创建时间 2.3
lastOpDate Timestamp 最后一次修改时间 2.3

SDK示例

Java SDK
SetVipQosAction action = new SetVipQosAction();
action.uuid = "9b500046ab303d42a8d8a17565b5673b";
action.port = 22.0;
action.outboundBandwidth = 1048576.0;
action.inboundBandwidth = 1048576.0;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
SetVipQosAction.Result res = action.call();
Python SDK
SetVipQosAction action = SetVipQosAction()
action.uuid = "9b500046ab303d42a8d8a17565b5673b"
action.port = 22.0
action.outboundBandwidth = 1048576.0
action.inboundBandwidth = 1048576.0
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
SetVipQosAction.Result res = action.call()

获取虚拟IP限速(GetVipQos)

API请求

URLs
GET zstack/v1/vip/{uuid}/vip-qos
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/vip/e7bd5b22962e33ba8608533f18f10bd1/vip-qos
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid (可选) String url 资源的UUID,唯一标示该资源 2.3
systemTags (可选) List query 系统标签 2.3
userTags (可选) List query 用户标签 2.3

API返回

返回示例
{
  "inventories": [
    {
      "uuid": "5a0b0e4ab75c4fffa890cf085add862f",
      "vipUuid": "23349810e3874c2dad85042db1ac11dc",
      "port": 80.0,
      "inboundBandwidth": 1048576.0,
      "outboundBandwidth": 1048576.0
    }
  ]
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 2.3
inventories List 详情参考inventories 2.3
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 2.3
description String 错误的概要描述 2.3
details String 错误的详细信息 2.3
elaboration String 保留字段,默认为null 2.3
opaque LinkedHashMap 保留字段,默认为null 2.3
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 2.3
#inventories
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 2.3
vipUuid String 虚拟IP UUID 2.3
port Integer 端口 2.3
inboundBandwidth Long 出流量带宽限制 2.3
outboundBandwidth Long 入流量带宽限制 2.3
type String 限速单位类型 2.3
createDate Timestamp 创建时间 2.3
lastOpDate Timestamp 最后一次修改时间 2.3

SDK示例

Java SDK
GetVipQosAction action = new GetVipQosAction();
action.uuid = "e7bd5b22962e33ba8608533f18f10bd1";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetVipQosAction.Result res = action.call();
Python SDK
GetVipQosAction action = GetVipQosAction()
action.uuid = "e7bd5b22962e33ba8608533f18f10bd1"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetVipQosAction.Result res = action.call()

取消虚拟IP限速(DeleteVipQos)

API请求

URLs
DELETE zstack/v1/vips/{uuid}/vip-qos?port={port}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/vips/cbfc39af27633b31927fa0c259bfde80/vip-qos?
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 资源的UUID,唯一标示该资源 2.3
port (可选) Integer url 端口 2.3
systemTags (可选) List body 系统标签 2.3
userTags (可选) List body 用户标签 2.3

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
DeleteVipQosAction action = new DeleteVipQosAction();
action.uuid = "cbfc39af27633b31927fa0c259bfde80";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteVipQosAction.Result res = action.call();
Python SDK
DeleteVipQosAction action = DeleteVipQosAction()
action.uuid = "cbfc39af27633b31927fa0c259bfde80"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteVipQosAction.Result res = action.call()
开发手册 | 5.4.12 | ZStack Cloud · ZCF | ZStack 资源中心