策略路由相关接口
创建策略路由规则集(CreatePolicyRouteRuleSet)
API请求
URLs
POST zstack/v1/policy-routes/rulesetsHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "ruleSet",
"description": "description",
"vRouterUuid": "85eb5d9f50bc3919b793b3caf9f3e859"
},
"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":"ruleSet","description":"description","vRouterUuid":"85eb5d9f50bc3919b793b3caf9f3e859"}}' http://localhost:8080/zstack/v1/policy-routes/rulesets参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| name | String | body(包含在params结构中) | 资源名称 | 3.6.0 | |
| description (可选) | String | body(包含在params结构中) | 资源的详细描述 | 3.6.0 | |
| vRouterUuid | String | body(包含在params结构中) | 路由器uuid | 3.6.0 | |
| type (可选) | String | body(包含在params结构中) |
|
3.9.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返回
返回示例
{
"inventory": {
"name": "name",
"description": "example-des",
"rules": [
{
"uuid": "74cc4fed46f633f2a618b0e06d122377",
"ruleNumber": 1.0,
"ruleSetUuid": "00693e31fa3b3e3fba017ed714c02cdf",
"tableUuid": "b273e0c273c03559872efa272194492c",
"destIp": "192.168.1.1",
"sourceIp": "10.0.0.1",
"destPort": "22",
"sourcePort": "80",
"protocol": "tcp",
"state": "enable"
}
]
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.6.0 |
| inventory | PolicyRouteRuleSetInventory | 详情参考inventory | 3.6.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.6.0 |
| description | String | 错误的概要描述 | 3.6.0 |
| details | String | 错误的详细信息 | 3.6.0 |
| elaboration | String | 保留字段,默认为null | 3.6.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.6.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.6.0 |
#inventory
#rules
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.6.0 |
| ruleNumber | int | 优先级 | 3.6.0 |
| ruleSetUuid | String | 策略路由规则集uuid | 3.6.0 |
| tableUuid | String | 策略路由表uuid | 3.6.0 |
| destIp | String | 目标ip | 3.6.0 |
| sourceIp | String | 源ip | 3.6.0 |
| destPort | String | 目标端口 | 3.6.0 |
| sourcePort | String | 源端口 | 3.6.0 |
| createDate | Timestamp | 创建时间 | 3.6.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.6.0 |
| protocol | PolicyRouteRuleProtocol | 详情参考protocol | 3.6.0 |
| state | PolicyRouteRuleState | 详情参考state | 3.6.0 |
#protocol
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| tcp | PolicyRouteRuleProtocol | 3.6.0 | |
| udp | PolicyRouteRuleProtocol | 3.6.0 |
#state
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| enable | PolicyRouteRuleState | 3.6.0 | |
| disable | PolicyRouteRuleState | 3.6.0 |
#l3Refs
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| id | long | 3.9.0 | |
| l3NetworkUuid | String | 三层网络UUID | 3.9.0 |
| ruleSetUuid | String | 3.9.0 | |
| createDate | Timestamp | 创建时间 | 3.9.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.9.0 |
SDK示例
Java
SDK
CreatePolicyRouteRuleSetAction action = new CreatePolicyRouteRuleSetAction();
action.name = "ruleSet";
action.description = "description";
action.vRouterUuid = "85eb5d9f50bc3919b793b3caf9f3e859";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreatePolicyRouteRuleSetAction.Result res = action.call();Python
SDK
CreatePolicyRouteRuleSetAction action = CreatePolicyRouteRuleSetAction()
action.name = "ruleSet"
action.description = "description"
action.vRouterUuid = "85eb5d9f50bc3919b793b3caf9f3e859"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreatePolicyRouteRuleSetAction.Result res = action.call()删除策略路由规则集(DeletePolicyRouteRuleSet)
API请求
URLs
DELETE zstack/v1/policy-routes/ruleSets/{uuid}?deleteMode={deleteMode}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/policy-routes/ruleSets/f430004bc0ed315c89eb7909a48d27e7?deleteMode=Permissive参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 资源的UUID,唯一标示该资源 | 3.6.0 | |
| deleteMode (可选) | String | body | 3.6.0 | ||
| systemTags (可选) | List | body | 3.6.0 | ||
| userTags (可选) | List | body | 3.6.0 |
API返回
该API成功时返回一个空的JSON结构
{},出错时返回的JSON结构包含一个error字段,例如:{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK示例
Java
SDK
DeletePolicyRouteRuleSetAction action = new DeletePolicyRouteRuleSetAction();
action.uuid = "f430004bc0ed315c89eb7909a48d27e7";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeletePolicyRouteRuleSetAction.Result res = action.call();Python
SDK
DeletePolicyRouteRuleSetAction action = DeletePolicyRouteRuleSetAction()
action.uuid = "f430004bc0ed315c89eb7909a48d27e7"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeletePolicyRouteRuleSetAction.Result res = action.call()更新策略路由规则集属性(UpdatePolicyRouteRuleSet)
API请求
URLs
PUT zstack/v1/policy-routes/ruleSets/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"updatePolicyRouteRuleSet": {
"name": "name",
"description": "desc"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updatePolicyRouteRuleSet":{"name":"name","description":"desc"}}' http://localhost:8080/zstack/v1/policy-routes/ruleSets/e58212f4cd0c3f2f96d27dde19de1383/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 资源的UUID,唯一标示该资源 | 3.6.0 | |
| name (可选) | String | body(包含在updatePolicyRouteRuleSet结构中) | 资源名称 | 3.6.0 | |
| description (可选) | String | body(包含在updatePolicyRouteRuleSet结构中) | 资源的详细描述 | 3.6.0 | |
| systemTags (可选) | List | body | 3.6.0 | ||
| userTags (可选) | List | body | 3.6.0 |
API返回
返回示例
{
"inventory": {
"name": "name",
"description": "example-des",
"rules": []
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.6.0 |
| inventory | PolicyRouteRuleSetInventory | 详情参考inventory | 3.6.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.6.0 |
| description | String | 错误的概要描述 | 3.6.0 |
| details | String | 错误的详细信息 | 3.6.0 |
| elaboration | String | 保留字段,默认为null | 3.6.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.6.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.6.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.6.0 |
| name | String | 资源名称 | 3.6.0 |
| description | String | 资源的详细描述 | 3.6.0 |
| createDate | Timestamp | 创建时间 | 3.6.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.6.0 |
| rules | List | 详情参考rules | 3.6.0 |
#rules
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.6.0 |
| ruleNumber | int | 优先级 | 3.6.0 |
| ruleSetUuid | String | 策略路由规则集uuid | 3.6.0 |
| tableUuid | String | 策略路由表uuid | 3.6.0 |
| destIp | String | 目标ip | 3.6.0 |
| sourceIp | String | 源ip | 3.6.0 |
| destPort | String | 目标端口 | 3.6.0 |
| sourcePort | String | 源端口 | 3.6.0 |
| createDate | Timestamp | 创建时间 | 3.6.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.6.0 |
| protocol | PolicyRouteRuleProtocol | 详情参考protocol | 3.6.0 |
| state | PolicyRouteRuleState | 详情参考state | 3.6.0 |
#protocol
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| tcp | PolicyRouteRuleProtocol | 3.6.0 | |
| udp | PolicyRouteRuleProtocol | 3.6.0 |
#state
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| enable | PolicyRouteRuleState | 3.6.0 | |
| disable | PolicyRouteRuleState | 3.6.0 |
SDK示例
Java
SDK
UpdatePolicyRouteRuleSetAction action = new UpdatePolicyRouteRuleSetAction();
action.uuid = "e58212f4cd0c3f2f96d27dde19de1383";
action.name = "name";
action.description = "desc";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdatePolicyRouteRuleSetAction.Result res = action.call();Python
SDK
UpdatePolicyRouteRuleSetAction action = UpdatePolicyRouteRuleSetAction()
action.uuid = "e58212f4cd0c3f2f96d27dde19de1383"
action.name = "name"
action.description = "desc"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdatePolicyRouteRuleSetAction.Result res = action.call()查询策略路由规则集(QueryPolicyRouteRuleSet)
API请求
URLs
GET zstack/v1/policy-routes/rulesetsGET zstack/v1/policy-routes/rulesets/{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/policy-routes/rulesetscurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/policy-routes/rulesets/f3c338fa05d63ceaa90fedcaffebfd66可查询字段
运行CLI命令行工具,输入QueryPolicyRouteRuleSet并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"name": "name",
"description": "example-des",
"rules": [
{
"uuid": "2e05ab3c36323487baea2414005817ee",
"ruleNumber": 1.0,
"ruleSetUuid": "4c86543d473f3127885b3ffc8be5ec88",
"tableUuid": "d2ad1f7ad9aa354e8da24829bbd31a05",
"destIp": "192.168.1.1",
"sourceIp": "10.0.0.1",
"destPort": "22",
"sourcePort": "80",
"protocol": "tcp",
"state": "enable"
}
]
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.6.0 |
| inventories | List | 详情参考inventories | 3.6.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.6.0 |
| description | String | 错误的概要描述 | 3.6.0 |
| details | String | 错误的详细信息 | 3.6.0 |
| elaboration | String | 保留字段,默认为null | 3.6.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.6.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.6.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.6.0 |
| name | String | 资源名称 | 3.6.0 |
| description | String | 资源的详细描述 | 3.6.0 |
| createDate | Timestamp | 创建时间 | 3.6.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.6.0 |
| rules | List | 详情参考rules | 3.6.0 |
#rules
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.6.0 |
| ruleNumber | int | 优先级 | 3.6.0 |
| ruleSetUuid | String | 策略路由规则集uuid | 3.6.0 |
| tableUuid | String | 策略路由表uuid | 3.6.0 |
| destIp | String | 目标ip | 3.6.0 |
| sourceIp | String | 源ip | 3.6.0 |
| destPort | String | 目标端口 | 3.6.0 |
| sourcePort | String | 源端口 | 3.6.0 |
| createDate | Timestamp | 创建时间 | 3.6.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.6.0 |
| protocol | PolicyRouteRuleProtocol | 详情参考protocol | 3.6.0 |
| state | PolicyRouteRuleState | 详情参考state | 3.6.0 |
#protocol
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| tcp | PolicyRouteRuleProtocol | 3.6.0 | |
| udp | PolicyRouteRuleProtocol | 3.6.0 |
#state
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| enable | PolicyRouteRuleState | 3.6.0 | |
| disable | PolicyRouteRuleState | 3.6.0 |
SDK示例
Java
SDK
QueryPolicyRouteRuleSetAction action = new QueryPolicyRouteRuleSetAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryPolicyRouteRuleSetAction.Result res = action.call();Python
SDK
QueryPolicyRouteRuleSetAction action = QueryPolicyRouteRuleSetAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryPolicyRouteRuleSetAction.Result res = action.call()查询策略路由规则集网络关联(QueryPolicyRouteRuleSetL3Ref)
API请求
URLs
GET zstack/v1/policy-routes/rulesets/l3networdks/refsHeaders
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/policy-routes/rulesets/l3networdks/refs可查询字段
运行CLI命令行工具,输入QueryPolicyRouteRuleSetL3Ref并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"id": 1.0,
"l3NetworkUuid": "764cba1766563fd683ef1fcf76c7295c",
"ruleSetUuid": "ddb87b28f0253810b753fc9ae62ebd31"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.6.0 |
| inventories | List | 详情参考inventories | 3.6.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.6.0 |
| description | String | 错误的概要描述 | 3.6.0 |
| details | String | 错误的详细信息 | 3.6.0 |
| elaboration | String | 保留字段,默认为null | 3.6.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.6.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.6.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| id | long | 3.6.0 | |
| l3NetworkUuid | String | 三层网络UUID | 3.6.0 |
| ruleSetUuid | String | 策略路由规则集uuid | 3.6.0 |
| createDate | Timestamp | 创建时间 | 3.6.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.6.0 |
SDK示例
Java
SDK
QueryPolicyRouteRuleSetL3RefAction action = new QueryPolicyRouteRuleSetL3RefAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryPolicyRouteRuleSetL3RefAction.Result res = action.call();Python
SDK
QueryPolicyRouteRuleSetL3RefAction action = QueryPolicyRouteRuleSetL3RefAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryPolicyRouteRuleSetL3RefAction.Result res = action.call()查询策略路由规则集与单节点路由器关联(QueryPolicyRouteRuleSetVRouterRef)
API请求
URLs
GET zstack/v1/policy-routes/rulesets/vrouters/refsHeaders
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/policy-routes/rulesets/vrouters/refs可查询字段
运行CLI命令行工具,输入QueryPolicyRouteRuleSetVRouterRef并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"id": 1.0,
"vRouterUuid": "8715faa19cb03995a864330766fdc77c",
"ruleSetUuid": "2e27f9015ad3357996546fd51c2d808e"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.6.0 |
| inventories | List | 详情参考inventories | 3.6.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.6.0 |
| description | String | 错误的概要描述 | 3.6.0 |
| details | String | 错误的详细信息 | 3.6.0 |
| elaboration | String | 保留字段,默认为null | 3.6.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.6.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.6.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| id | long | 3.6.0 | |
| vRouterUuid | String | 路由器uuid | 3.6.0 |
| ruleSetUuid | String | 策略路由规则集uuid | 3.6.0 |
| createDate | Timestamp | 创建时间 | 3.6.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.6.0 |
SDK示例
Java
SDK
QueryPolicyRouteRuleSetVRouterRefAction action = new QueryPolicyRouteRuleSetVRouterRefAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryPolicyRouteRuleSetVRouterRefAction.Result res = action.call();Python
SDK
QueryPolicyRouteRuleSetVRouterRefAction action = QueryPolicyRouteRuleSetVRouterRefAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryPolicyRouteRuleSetVRouterRefAction.Result res = action.call()创建策略路由规则集规则(CreatePolicyRouteRule)
API请求
URLs
POST zstack/v1/policy-routes/rulesHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"ruleSetUuid": "ec2472bf205931318e02a2bb5356c0ee",
"tableUuid": "b4c03beba98c3502ac53d784dd9bfe61",
"ruleNumber": 1001.0,
"destIp": "192.168.1.0/24",
"sourceIp": "192.168.2.0/24",
"destPort": "22",
"sourcePort": "33",
"protocol": "tcp"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"ruleSetUuid":"ec2472bf205931318e02a2bb5356c0ee","tableUuid":"b4c03beba98c3502ac53d784dd9bfe61","ruleNumber":1001.0,"destIp":"192.168.1.0/24","sourceIp":"192.168.2.0/24","destPort":"22","sourcePort":"33","protocol":"tcp"}}' http://localhost:8080/zstack/v1/policy-routes/rules参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| ruleSetUuid | String | body(包含在params结构中) | 策略路由规则集uuid | 3.6.0 | |
| tableUuid | String | body(包含在params结构中) | 策略路由表uuid | 3.6.0 | |
| ruleNumber | int | body(包含在params结构中) | 规则优先级 | 3.6.0 | |
| destIp (可选) | String | body(包含在params结构中) | 目标ip | 3.6.0 | |
| sourceIp (可选) | String | body(包含在params结构中) | 源ip | 3.6.0 | |
| destPort (可选) | String | body(包含在params结构中) | 目标端口 | 3.6.0 | |
| sourcePort (可选) | String | body(包含在params结构中) | 源端口 | 3.6.0 | |
| protocol (可选) | String | 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返回
返回示例
{
"inventory": {
"uuid": "8b14e8fd1bae3b35acb67d19b8c7580e",
"ruleNumber": 1.0,
"ruleSetUuid": "7cd6023e32c639169b2316ffec4c79f3",
"tableUuid": "3d5c0b99cfac3654a451c854cf449091",
"destIp": "192.168.1.1",
"sourceIp": "80",
"destPort": "22",
"protocol": "tcp",
"state": "enable"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.6.0 |
| inventory | PolicyRouteRuleInventory | 详情参考inventory | 3.6.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.6.0 |
| description | String | 错误的概要描述 | 3.6.0 |
| details | String | 错误的详细信息 | 3.6.0 |
| elaboration | String | 保留字段,默认为null | 3.6.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.6.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.6.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.6.0 |
| ruleNumber | int | 优先级 | 3.6.0 |
| ruleSetUuid | String | 策略路由规则集uuid | 3.6.0 |
| tableUuid | String | 策略路由表uuid | 3.6.0 |
| destIp | String | 目标ip | 3.6.0 |
| sourceIp | String | 源ip | 3.6.0 |
| destPort | String | 目标端口 | 3.6.0 |
| sourcePort | String | 源端口 | 3.6.0 |
| createDate | Timestamp | 创建时间 | 3.6.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.6.0 |
| protocol | PolicyRouteRuleProtocol | 详情参考protocol | 3.6.0 |
| state | PolicyRouteRuleState | 详情参考state | 3.6.0 |
#protocol
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| tcp | PolicyRouteRuleProtocol | 3.6.0 | |
| udp | PolicyRouteRuleProtocol | 3.6.0 |
#state
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| enable | PolicyRouteRuleState | 3.6.0 | |
| disable | PolicyRouteRuleState | 3.6.0 |
SDK示例
Java
SDK
CreatePolicyRouteRuleAction action = new CreatePolicyRouteRuleAction();
action.ruleSetUuid = "ec2472bf205931318e02a2bb5356c0ee";
action.tableUuid = "b4c03beba98c3502ac53d784dd9bfe61";
action.ruleNumber = 1001.0;
action.destIp = "192.168.1.0/24";
action.sourceIp = "192.168.2.0/24";
action.destPort = "22";
action.sourcePort = "33";
action.protocol = "tcp";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreatePolicyRouteRuleAction.Result res = action.call();Python
SDK
CreatePolicyRouteRuleAction action = CreatePolicyRouteRuleAction()
action.ruleSetUuid = "ec2472bf205931318e02a2bb5356c0ee"
action.tableUuid = "b4c03beba98c3502ac53d784dd9bfe61"
action.ruleNumber = 1001.0
action.destIp = "192.168.1.0/24"
action.sourceIp = "192.168.2.0/24"
action.destPort = "22"
action.sourcePort = "33"
action.protocol = "tcp"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreatePolicyRouteRuleAction.Result res = action.call()删除策略路由规则集规则(DeletePolicyRouteRule)
API请求
URLs
DELETE zstack/v1/policy-routes/rules/{uuid}?deleteMode={deleteMode}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/policy-routes/rules/b02689c3b5513b8db2bb5f45a8c7b169?deleteMode=Permissive参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 资源的UUID,唯一标示该资源 | 3.6.0 | |
| deleteMode (可选) | String | body | 3.6.0 | ||
| systemTags (可选) | List | body | 3.6.0 | ||
| userTags (可选) | List | body | 3.6.0 |
API返回
该API成功时返回一个空的JSON结构
{},出错时返回的JSON结构包含一个error字段,例如:{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK示例
Java
SDK
DeletePolicyRouteRuleAction action = new DeletePolicyRouteRuleAction();
action.uuid = "b02689c3b5513b8db2bb5f45a8c7b169";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeletePolicyRouteRuleAction.Result res = action.call();Python
SDK
DeletePolicyRouteRuleAction action = DeletePolicyRouteRuleAction()
action.uuid = "b02689c3b5513b8db2bb5f45a8c7b169"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeletePolicyRouteRuleAction.Result res = action.call()创建策略路由表(CreatePolicyRouteTable)
API请求
URLs
POST zstack/v1/policy-routes/tablesHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"vRouterUuid": "efe77450940f3dfe9023f2589fdeda25",
"number": 1.0,
"description": "description"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"vRouterUuid":"efe77450940f3dfe9023f2589fdeda25","number":1.0,"description":"description"}}' http://localhost:8080/zstack/v1/policy-routes/tables参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| vRouterUuid | String | body(包含在params结构中) | 路由器uuid | 3.6.0 | |
| number | Integer | body(包含在params结构中) | 表名 | 3.6.0 | |
| description (可选) | String | 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返回
返回示例
{
"inventory": {
"uuid": "8bd52616389d3ce7b5d74bc2424d3f8d",
"tableNumber": 1.0,
"description": "example-des",
"routes": [
{
"tableUuid": "2a7ba1261cef3cf19b587e493e479286",
"destinationCidr": "192.168.1.0/24",
"nextHopIp": "192.168.1.1",
"distance": 1.0
}
]
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.6.0 |
| inventory | PolicyRouteTableInventory | 详情参考inventory | 3.6.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.6.0 |
| description | String | 错误的概要描述 | 3.6.0 |
| details | String | 错误的详细信息 | 3.6.0 |
| elaboration | String | 保留字段,默认为null | 3.6.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.6.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.6.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.6.0 |
| tableNumber | int | 表名 | 3.6.0 |
| description | String | 资源的详细描述 | 3.6.0 |
| createDate | Timestamp | 创建时间 | 3.6.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.6.0 |
| routes | List | 详情参考routes | 3.6.0 |
#routes
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.6.0 |
| tableUuid | String | 策略路由表uuid | 3.6.0 |
| destinationCidr | String | 目标cidr | 3.6.0 |
| nextHopIp | String | 下一跳ip | 3.6.0 |
| distance | int | 优先级 | 3.6.0 |
| createDate | Timestamp | 创建时间 | 3.6.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.6.0 |
SDK示例
Java
SDK
CreatePolicyRouteTableAction action = new CreatePolicyRouteTableAction();
action.vRouterUuid = "efe77450940f3dfe9023f2589fdeda25";
action.number = 1.0;
action.description = "description";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreatePolicyRouteTableAction.Result res = action.call();Python
SDK
CreatePolicyRouteTableAction action = CreatePolicyRouteTableAction()
action.vRouterUuid = "efe77450940f3dfe9023f2589fdeda25"
action.number = 1.0
action.description = "description"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreatePolicyRouteTableAction.Result res = action.call()删除策略路由表(DeletePolicyRouteTable)
API请求
URLs
DELETE zstack/v1/policy-routes/tables/{uuid}?deleteMode={deleteMode}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/policy-routes/tables/4c24bf6b15d3338ab1d66eac97eec58b?deleteMode=Permissive参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 资源的UUID,唯一标示该资源 | 3.6.0 | |
| deleteMode (可选) | String | body | 3.6.0 | ||
| systemTags (可选) | List | body | 3.6.0 | ||
| userTags (可选) | List | body | 3.6.0 |
API返回
该API成功时返回一个空的JSON结构
{},出错时返回的JSON结构包含一个error字段,例如:{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK示例
Java
SDK
DeletePolicyRouteTableAction action = new DeletePolicyRouteTableAction();
action.uuid = "4c24bf6b15d3338ab1d66eac97eec58b";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeletePolicyRouteTableAction.Result res = action.call();Python
SDK
DeletePolicyRouteTableAction action = DeletePolicyRouteTableAction()
action.uuid = "4c24bf6b15d3338ab1d66eac97eec58b"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeletePolicyRouteTableAction.Result res = action.call()查询策略路由表(QueryPolicyRouteTable)
API请求
URLs
GET zstack/v1/policy-routes/tablesGET zstack/v1/policy-routes/tables/{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/policy-routes/tablescurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/policy-routes/tables/e32b296e6633331284c5cbbd71cedfa4可查询字段
运行CLI命令行工具,输入QueryPolicyRouteTable并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"uuid": "6e39025e9eb432fda488f19e7104fdf0",
"tableNumber": 1.0,
"description": "example-des",
"routes": [
{
"tableUuid": "90f075232c383565ac3dbc09554c4152",
"destinationCidr": "192.168.1.0/24",
"nextHopIp": "192.168.1.1",
"distance": 1.0
}
]
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.6.0 |
| inventories | List | 详情参考inventories | 3.6.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.6.0 |
| description | String | 错误的概要描述 | 3.6.0 |
| details | String | 错误的详细信息 | 3.6.0 |
| elaboration | String | 保留字段,默认为null | 3.6.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.6.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.6.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.6.0 |
| tableNumber | int | 表名 | 3.6.0 |
| description | String | 资源的详细描述 | 3.6.0 |
| createDate | Timestamp | 创建时间 | 3.6.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.6.0 |
| routes | List | 详情参考routes | 3.6.0 |
#routes
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.6.0 |
| tableUuid | String | 策略路由表uuid | 3.6.0 |
| destinationCidr | String | 目标cidr | 3.6.0 |
| nextHopIp | String | 下一跳ip | 3.6.0 |
| distance | int | 优先级 | 3.6.0 |
| createDate | Timestamp | 创建时间 | 3.6.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.6.0 |
SDK示例
Java
SDK
QueryPolicyRouteTableAction action = new QueryPolicyRouteTableAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryPolicyRouteTableAction.Result res = action.call();Python
SDK
QueryPolicyRouteTableAction action = QueryPolicyRouteTableAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryPolicyRouteTableAction.Result res = action.call()查询策略路由表与单节点路由器关联(QueryPolicyRouteTableVRouterRef)
API请求
URLs
GET zstack/v1/policy-routes/tables/vrouters/refsHeaders
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/policy-routes/tables/vrouters/refs可查询字段
运行CLI命令行工具,输入QueryPolicyRouteTableVRouterRef并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"id": 1.0,
"tableUuid": "cc3bb710f9d43cedb044213253363604",
"vRouterUuid": "f281299552813438acc3c5a400802a78"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.6.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.6.0 |
| description | String | 错误的概要描述 | 3.6.0 |
| details | String | 错误的详细信息 | 3.6.0 |
| elaboration | String | 保留字段,默认为null | 3.6.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.6.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.6.0 |
SDK示例
Java
SDK
QueryPolicyRouteTableVRouterRefAction action = new QueryPolicyRouteTableVRouterRefAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryPolicyRouteTableVRouterRefAction.Result res = action.call();Python
SDK
QueryPolicyRouteTableVRouterRefAction action = QueryPolicyRouteTableVRouterRefAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryPolicyRouteTableVRouterRefAction.Result res = action.call()创建策略路由(CreatePolicyRouteTableRouteEntry)
API请求
URLs
POST zstack/v1/policy-routes/routesHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"tableUuid": "ef44a453884a3b93867d6ec0b7dd5716",
"destinationCidr": "192.168.1.0/24",
"nextHopIp": "192.168.1.1",
"distance": 1.0
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"tableUuid":"ef44a453884a3b93867d6ec0b7dd5716","destinationCidr":"192.168.1.0/24","nextHopIp":"192.168.1.1","distance":1.0}}' http://localhost:8080/zstack/v1/policy-routes/routes参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| tableUuid | String | body(包含在params结构中) | 策略路由表uuid | 3.6.0 | |
| destinationCidr | String | body(包含在params结构中) | 目标ip cidr | 3.6.0 | |
| nextHopIp | String | body(包含在params结构中) | 下一跳ip | 3.6.0 | |
| distance (可选) | Integer | 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返回
返回示例
{
"inventory": {
"tableUuid": "a6e9466373c333948f8d6ef573992d43",
"destinationCidr": "192.168.1.0/24",
"nextHopIp": "192.168.1.1",
"distance": 1.0
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.6.0 |
| inventory | PolicyRouteTableRouteEntryInventory | 详情参考inventory | 3.6.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.6.0 |
| description | String | 错误的概要描述 | 3.6.0 |
| details | String | 错误的详细信息 | 3.6.0 |
| elaboration | String | 保留字段,默认为null | 3.6.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.6.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.6.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.6.0 |
| tableUuid | String | 策略路由表uuid | 3.6.0 |
| destinationCidr | String | 目标cidr | 3.6.0 |
| nextHopIp | String | 下一跳ip | 3.6.0 |
| distance | int | 优先级 | 3.6.0 |
| createDate | Timestamp | 创建时间 | 3.6.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.6.0 |
SDK示例
Java
SDK
CreatePolicyRouteTableRouteEntryAction action = new CreatePolicyRouteTableRouteEntryAction();
action.tableUuid = "ef44a453884a3b93867d6ec0b7dd5716";
action.destinationCidr = "192.168.1.0/24";
action.nextHopIp = "192.168.1.1";
action.distance = 1.0;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreatePolicyRouteTableRouteEntryAction.Result res = action.call();Python
SDK
CreatePolicyRouteTableRouteEntryAction action = CreatePolicyRouteTableRouteEntryAction()
action.tableUuid = "ef44a453884a3b93867d6ec0b7dd5716"
action.destinationCidr = "192.168.1.0/24"
action.nextHopIp = "192.168.1.1"
action.distance = 1.0
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreatePolicyRouteTableRouteEntryAction.Result res = action.call()删除策略路由(DeletePolicyRouteTableRouteEntry)
API请求
URLs
DELETE zstack/v1/policy-routes/routes/{uuid}?deleteMode={deleteMode}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/policy-routes/routes/7e28a7059fb33a8bb2d7c61b7951303e?deleteMode=Permissive参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 资源的UUID,唯一标示该资源 | 3.6.0 | |
| deleteMode (可选) | String | body | 3.6.0 | ||
| systemTags (可选) | List | body | 3.6.0 | ||
| userTags (可选) | List | body | 3.6.0 |
API返回
该API成功时返回一个空的JSON结构
{},出错时返回的JSON结构包含一个error字段,例如:{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK示例
Java
SDK
DeletePolicyRouteTableRouteEntryAction action = new DeletePolicyRouteTableRouteEntryAction();
action.uuid = "7e28a7059fb33a8bb2d7c61b7951303e";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeletePolicyRouteTableRouteEntryAction.Result res = action.call();Python
SDK
DeletePolicyRouteTableRouteEntryAction action = DeletePolicyRouteTableRouteEntryAction()
action.uuid = "7e28a7059fb33a8bb2d7c61b7951303e"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeletePolicyRouteTableRouteEntryAction.Result res = action.call()查询策略路由(QueryPolicyRouteTableRouteEntry)
API请求
URLs
GET zstack/v1/policy-routes/routesGET zstack/v1/policy-routes/routes/{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/policy-routes/routescurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/policy-routes/routes/775c98615c5936f3aab19b6271c9e5dc可查询字段
运行CLI命令行工具,输入QueryPolicyRouteTableRouteEntry并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"tableUuid": "49bf5678360b38058ab7096715e219f4",
"destinationCidr": "192.168.1.0/24",
"nextHopIp": "192.168.1.1",
"distance": 1.0
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.6.0 |
| inventories | List | 详情参考inventories | 3.6.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.6.0 |
| description | String | 错误的概要描述 | 3.6.0 |
| details | String | 错误的详细信息 | 3.6.0 |
| elaboration | String | 保留字段,默认为null | 3.6.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.6.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.6.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.6.0 |
| tableUuid | String | 策略路由表uuid | 3.6.0 |
| destinationCidr | String | 目标cidr | 3.6.0 |
| nextHopIp | String | 下一跳ip | 3.6.0 |
| distance | int | 优先级 | 3.6.0 |
| createDate | Timestamp | 创建时间 | 3.6.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.6.0 |
SDK示例
Java
SDK
QueryPolicyRouteTableRouteEntryAction action = new QueryPolicyRouteTableRouteEntryAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryPolicyRouteTableRouteEntryAction.Result res = action.call();Python
SDK
QueryPolicyRouteTableRouteEntryAction action = QueryPolicyRouteTableRouteEntryAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryPolicyRouteTableRouteEntryAction.Result res = action.call()查询策略路由规则(QueryPolicyRouteRule)
API请求
URLs
GET zstack/v1/policy-routes/rulesGET zstack/v1/policy-routes/rules/{uuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/policy-routes/rulescurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/policy-routes/rules/cc3c19210de13878994ddcb5bee8a34c可查询字段
运行CLI命令行工具,输入QueryPolicyRouteRule并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"uuid": "538840755c1a36e0b79f1d04097b252e",
"ruleNumber": 1.0,
"ruleSetUuid": "7cb413c84b243290a7105e8c21f42b59",
"tableUuid": "d29940b692f33c0eaf96b0193029636c",
"destIp": "192.168.1.1",
"sourceIp": "80",
"destPort": "22",
"protocol": "tcp",
"state": "enable"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.6.0 |
| inventories | List | 详情参考inventories | 3.6.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.6.0 |
| description | String | 错误的概要描述 | 3.6.0 |
| details | String | 错误的详细信息 | 3.6.0 |
| elaboration | String | 保留字段,默认为null | 3.6.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.6.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.6.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.6.0 |
| ruleNumber | int | 优先级 | 3.6.0 |
| ruleSetUuid | String | 策略路由规则集uuid | 3.6.0 |
| tableUuid | String | 策略路由表uuid | 3.6.0 |
| destIp | String | 目标ip | 3.6.0 |
| sourceIp | String | 源ip | 3.6.0 |
| destPort | String | 目标端口 | 3.6.0 |
| sourcePort | String | 源端口 | 3.6.0 |
| createDate | Timestamp | 创建时间 | 3.6.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.6.0 |
| protocol | PolicyRouteRuleProtocol | 详情参考protocol | 3.6.0 |
| state | PolicyRouteRuleState | 详情参考state | 3.6.0 |
#protocol
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| tcp | PolicyRouteRuleProtocol | 3.6.0 | |
| udp | PolicyRouteRuleProtocol | 3.6.0 |
#state
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| enable | PolicyRouteRuleState | 3.6.0 | |
| disable | PolicyRouteRuleState | 3.6.0 |
SDK示例
Java
SDK
QueryPolicyRouteRuleAction action = new QueryPolicyRouteRuleAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryPolicyRouteRuleAction.Result res = action.call();Python
SDK
QueryPolicyRouteRuleAction action = QueryPolicyRouteRuleAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryPolicyRouteRuleAction.Result res = action.call()网络加载策略路由规则集(AttachPolicyRouteRuleSetToL3)
API请求
URLs
POST zstack/v1/policy-routes/rulesets/{ruleSetUuid}/l3networks/{l3Uuid}Headers
Authorization: OAuth the-session-uuidBody
{
"params": {},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{}}' http://localhost:8080/zstack/v1/policy-routes/rulesets/1e6eb259093e3fa2a30c837ae69d259c/l3networks/8748b8be922938bbb430ed9cbe3e4e46参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| l3Uuid | String | url | 三层网络uuid | 3.6.0 | |
| ruleSetUuid | String | url | 策略路由规则集uuid | 3.6.0 | |
| systemTags (可选) | List | body | 3.6.0 | ||
| userTags (可选) | List | body | 3.6.0 |
API返回
该API成功时返回一个空的JSON结构
{},出错时返回的JSON结构包含一个error字段,例如:{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK示例
Java
SDK
AttachPolicyRouteRuleSetToL3Action action = new AttachPolicyRouteRuleSetToL3Action();
action.l3Uuid = "8748b8be922938bbb430ed9cbe3e4e46";
action.ruleSetUuid = "1e6eb259093e3fa2a30c837ae69d259c";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AttachPolicyRouteRuleSetToL3Action.Result res = action.call();Python
SDK
AttachPolicyRouteRuleSetToL3Action action = AttachPolicyRouteRuleSetToL3Action()
action.l3Uuid = "8748b8be922938bbb430ed9cbe3e4e46"
action.ruleSetUuid = "1e6eb259093e3fa2a30c837ae69d259c"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AttachPolicyRouteRuleSetToL3Action.Result res = action.call()网络解绑策略路由(DetachPolicyRouteRuleSetFromL3)
API请求
URLs
DELETE zstack/v1/policy-routes/rulesets/{ruleSetUuid}/l3networks/{l3Uuid}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/policy-routes/rulesets/75641a6f70c03fcea051d7fb5e45a0e5/l3networks/9556f3da05743aa88a603e086875e22c参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| l3Uuid | String | url | 三层网络uuid | 3.6.0 | |
| ruleSetUuid | String | url | 策略规则集uuid | 3.6.0 | |
| systemTags (可选) | List | body | 3.6.0 | ||
| userTags (可选) | List | body | 3.6.0 |
API返回
该API成功时返回一个空的JSON结构
{},出错时返回的JSON结构包含一个error字段,例如:{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK示例
Java
SDK
DetachPolicyRouteRuleSetFromL3Action action = new DetachPolicyRouteRuleSetFromL3Action();
action.l3Uuid = "9556f3da05743aa88a603e086875e22c";
action.ruleSetUuid = "75641a6f70c03fcea051d7fb5e45a0e5";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DetachPolicyRouteRuleSetFromL3Action.Result res = action.call();Python
SDK
DetachPolicyRouteRuleSetFromL3Action action = DetachPolicyRouteRuleSetFromL3Action()
action.l3Uuid = "9556f3da05743aa88a603e086875e22c"
action.ruleSetUuid = "75641a6f70c03fcea051d7fb5e45a0e5"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DetachPolicyRouteRuleSetFromL3Action.Result res = action.call()获取虚拟路由器的策略路由集合(GetPolicyRouteRuleSetFromVirtualRouter)
API请求
URLs
GET zstack/v1/policy-routes/rulesets/virtualrouter/{vmInstanceUuid}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/policy-routes/rulesets/virtualrouter/d38e9c3321af3f01a5509fa7f43dc46a参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| vmInstanceUuid | String | url | 云主机UUID | 3.9.0 | |
| systemTags (可选) | List | query | 系统标签 | 3.9.0 | |
| userTags (可选) | List | query | 用户标签 | 3.9.0 |
API返回
返回示例
{
"inventories": [
{
"uuid": "de191bb7f4763ce580fd7e2ed457cde8",
"name": "policy-rule-set",
"description": "policy rule set",
"type": "User",
"rules": [],
"l3Refs": []
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.9.0 |
| inventories | List | 详情参考inventories | 3.9.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.9.0 |
| description | String | 错误的概要描述 | 3.9.0 |
| details | String | 错误的详细信息 | 3.9.0 |
| elaboration | String | 保留字段,默认为null | 3.9.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.9.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.9.0 |
#inventories
#rules
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.9.0 |
| ruleNumber | int | 3.9.0 | |
| ruleSetUuid | String | 3.9.0 | |
| tableUuid | String | 3.9.0 | |
| destIp | String | 3.9.0 | |
| sourceIp | String | 3.9.0 | |
| destPort | String | 3.9.0 | |
| sourcePort | String | 3.9.0 | |
| createDate | Timestamp | 创建时间 | 3.9.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.9.0 |
| protocol | PolicyRouteRuleProtocol | 详情参考protocol | 3.9.0 |
| state | PolicyRouteRuleState | 详情参考state | 3.9.0 |
#protocol
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| tcp | PolicyRouteRuleProtocol | 3.9.0 | |
| udp | PolicyRouteRuleProtocol | 3.9.0 |
#state
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| enable | PolicyRouteRuleState | 3.9.0 | |
| disable | PolicyRouteRuleState | 3.9.0 |
#l3Refs
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| id | long | 3.9.0 | |
| l3NetworkUuid | String | 三层网络UUID | 3.9.0 |
| ruleSetUuid | String | 3.9.0 | |
| createDate | Timestamp | 创建时间 | 3.9.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.9.0 |
SDK示例
Java
SDK
GetPolicyRouteRuleSetFromVirtualRouterAction action = new GetPolicyRouteRuleSetFromVirtualRouterAction();
action.vmInstanceUuid = "d38e9c3321af3f01a5509fa7f43dc46a";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetPolicyRouteRuleSetFromVirtualRouterAction.Result res = action.call();Python
SDK
GetPolicyRouteRuleSetFromVirtualRouterAction action = GetPolicyRouteRuleSetFromVirtualRouterAction()
action.vmInstanceUuid = "d38e9c3321af3f01a5509fa7f43dc46a"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetPolicyRouteRuleSetFromVirtualRouterAction.Result res = action.call()