检查安全组规则是否可用
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/security-groups/0351d8b796bd3165967f13d1da2f9576/rules/validation?type=Ingress&protocol=TCP&remoteSecurityGroupUuid=f938bc96baae3dc4b18be6bdbf34e783&ipVersion=4&srcIpRange=10.0.0.1,10.0.0.2-10.0.0.200,10.1.1.0/24&dstIpRange=10.0.0.1,10.0.0.2-10.0.0.200,10.1.1.0/24&dstPortRange=1000,1001,1002-1005,1008&action=ACCEPT参数列表
名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
securityGroupUuid | String | url | 安全组的UUID,唯一标示该资源 |
| 4.7.21 |
type | String | query | 安全组规则的方向 |
| 4.7.21 |
protocol | String | query | 安全组规则的协议类型 |
| 4.7.21 |
remoteSecurityGroupUuid (可选) | String | query | 远端安全组的UUID,唯一标示该资源 |
| 4.7.21 |
ipVersion (可选) | Integer | query | 安全组规则的IP版本 |
| 4.7.21 |
srcIpRange (可选) | String | query | 安全组规则的源ip范围 |
| 4.7.21 |
dstIpRange (可选) | String | query | 安全组规则的目的ip范围 |
| 4.7.21 |
dstPortRange (可选) | String | query | 安全组规则的目的端口范围 |
| 4.7.21 |
action (可选) | String | query | 安全组规则的动作 |
| 4.7.21 |
startPort (可选) | Integer | query | 安全组规则的起始端口 |
| 4.7.21 |
endPort (可选) | Integer | query | 安全组规则的结束端口 |
| 4.7.21 |
allowedCidr (可选) | String | query | 安全组规则的ip范围 |
| 4.7.21 |
systemTags (可选) | List | body | 系统标签 |
| 4.7.21 |
userTags (可选) | List | body | 用户标签 |
| 4.7.21 |
API返回
返回示例
{
"available": true,
"code": "SG.2000"
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| available | boolean | 规则是否可用 | 4.7.21 |
| code | String | 规则检验错误码 | 4.7.21 |
| reason | String | 原因 | 4.7.21 |
| success | boolean | 4.7.21 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 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
ValidateSecurityGroupRuleAction action = new ValidateSecurityGroupRuleAction();
action.securityGroupUuid = "0351d8b796bd3165967f13d1da2f9576";
action.type = "Ingress";
action.protocol = "TCP";
action.remoteSecurityGroupUuid = "f938bc96baae3dc4b18be6bdbf34e783";
action.ipVersion = 4;
action.srcIpRange = "10.0.0.1,10.0.0.2-10.0.0.200,10.1.1.0/24";
action.dstIpRange = "10.0.0.1,10.0.0.2-10.0.0.200,10.1.1.0/24";
action.dstPortRange = "1000,1001,1002-1005,1008";
action.action = "ACCEPT";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ValidateSecurityGroupRuleAction.Result res = action.call();Python SDK
ValidateSecurityGroupRuleAction action = ValidateSecurityGroupRuleAction()
action.securityGroupUuid = "0351d8b796bd3165967f13d1da2f9576"
action.type = "Ingress"
action.protocol = "TCP"
action.remoteSecurityGroupUuid = "f938bc96baae3dc4b18be6bdbf34e783"
action.ipVersion = 4
action.srcIpRange = "10.0.0.1,10.0.0.2-10.0.0.200,10.1.1.0/24"
action.dstIpRange = "10.0.0.1,10.0.0.2-10.0.0.200,10.1.1.0/24"
action.dstPortRange = "1000,1001,1002-1005,1008"
action.action = "ACCEPT"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ValidateSecurityGroupRuleAction.Result res = action.call()