创建二层连接 - CreateConnection
功能介绍
当您的ESW实例创建成功后,您可以通过调用此接口在该实例上创建一个二层连接。
调试
您可以在API Explorer中调试该接口,支持自动认证鉴权。API Explorer可以自动生成SDK代码示例,并提供SDK代码示例调试功能。
授权信息
账号具备所有API的调用权限,如果使用账号下的IAM用户调用当前API,该IAM用户需具备如下身份策略权限,更多的权限说明请参见权限和授权项。
| 授权项 | 访问级别 | 资源类型(*为必须) | 条件键 | 别名 | 依赖的授权项 |
|---|---|---|---|---|---|
| esw:connection:create | Write | - | - | - | - |
URI
POST /v3/{project_id}/l2cg/instances/{instance_id}/connections
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| instance_id | 是 | String |
|
| project_id | 是 | String |
|
请求参数
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| connection | 是 | CreateConnectionOption object |
|
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| fixed_ips | 否 | Array of strings |
|
| name | 是 | String |
|
| remote_infos | 是 | Array of RemoteInfosOption objects |
|
| virsubnet_id | 是 | String |
|
| vpc_id | 是 | String |
|
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| segmentation_id | 是 | Integer |
|
| tunnel_ip | 是 | String |
|
| tunnel_port | 否 | Integer |
|
响应参数
状态码:201
| 参数 | 参数类型 | 描述 |
|---|---|---|
| request_id | String |
|
| connection | Connection object |
|
| 参数 | 参数类型 | 描述 |
|---|---|---|
| fixed_ips | Array of strings |
|
| id | String |
|
| instance_id | String |
|
| name | String |
|
| project_id | String |
|
| remote_infos | Array of RemoteInfosResult objects |
|
| status | String |
|
| virsubnet_id | String |
|
| vpc_id | String |
|
| created_at | String |
|
| updated_at | String |
|
| 参数 | 参数类型 | 描述 |
|---|---|---|
| segmentation_id | Integer |
|
| tunnel_ip | String |
|
| tunnel_port | Integer |
|
| tunnel_type | String |
|
请求示例
POST https://{endpoint}/v3/dd9e484e058b48e18b820948dcbd480e/l2cg/instances/87fea8df-3e0d-473a-a1bd-e6a76157f4ce/connections
{
"connection" : {
"virsubnet_id" : "2c649856-0d44-400c-8194-f6d67603e0eb",
"fixed_ips" : [ "192.168.0.11", "192.168.0.12" ],
"name" : "l2conn-7a0c",
"remote_infos" : [ {
"tunnel_port" : 4789,
"segmentation_id" : 7127,
"tunnel_ip" : "192.168.111.111"
} ],
"vpc_id" : "6ae030de-f630-476e-8284-7bcfbd94929d"
}
} 响应示例
状态码:201
POST操作正常返回,更多状态码请参见状态码。
{
"request_id" : "318ad7fa0bae74f2b0a22b44d6740309",
"connection" : {
"name" : "l2conn-7a0c",
"id" : "555fe9b7-62fe-48c6-a73d-a62413f110f1",
"status" : "pending",
"created_at" : "2025-07-28T08:39:59Z",
"updated_at" : "2025-07-28T08:39:59Z",
"project_id" : "dd9e484e058b48e18b820948dcbd480e",
"instance_id" : "87fea8df-3e0d-473a-a1bd-e6a76157f4ce",
"vpc_id" : "6ae030de-f630-476e-8284-7bcfbd94929d",
"virsubnet_id" : "2c649856-0d44-400c-8194-f6d67603e0eb",
"fixed_ips" : [ "192.168.0.11", "192.168.0.12" ],
"remote_infos" : [ {
"segmentation_id" : 7127,
"tunnel_ip" : "192.168.111.111",
"tunnel_port" : 4789,
"tunnel_type" : "vxlan"
} ]
}
} 状态码
| 状态码 | 描述 |
|---|---|
| 201 | POST操作正常返回,更多状态码请参见状态码。 |
错误码
请参见错误码。