• 文档
  • 控制台
  • 登录
  • 立即注册
    目前不支持用户自主注册,如需注册账号,请联系400-080-1100
专有网络VPC API参考手册
最近更新时间:2023-04-16 17:00:00

7 虚 IP 管理

7.1 CreateVirtualIP

调用 CreateVirtualIP 接口创建虚 IP。

7.1.1 使用说明

POST http://{endpoint}/vpc/v1.0/vips

新创建的虚 IP 处于可用(RUNNING)状态。

7.1.2 请求参数

1.png

7.1.3 返回数据

1.png

2.png

7.1.4 示例

1. 请求示例

POST http://{endpoint}/vpc/v1.0/vips 

     "SubnetId": "snet-xxx", 

     "CreateType ":”1”, 

     "PrivateIp":"192.168.0.11"

}

2. 正常返回示例

HTTP/1.1 200 OK

Content-Type:application/json 

{

     "RequestId": "3d65df346d1a27793f5c05191ab53e8d",

     "Id": "port-xxx",

     "UUid": "c8458574-28b7-4496-8288-5fa12cc44bab",

     "Name": null,

     "SubnetId": "snet-xxx,

     "AdminStateUp": false,

     "MacAddress": "0E:2C:CF:AD:B7:EA",

     "DeviceId": "snet-n0ld7l7gkn",

     116

     "DeviceOwner": "ha_vip_port",

     "FixedIps": "[{\"subnet_id\":\"snet-xxx\",\"ip_address\":\"10.10.10.11\"}]",

     "TenantId": "220007091311010",

     "Status": "RUNNING",

     "SecurityGroups": "[]",

     "created_at": "2022-10-12T11:17:49+08:00",

     "updated_at": "2022-10-12T11:17:49+08:00"

}

7.2 DeleteVirtualIP

调用 DeleteElasticVirtualIP 接口删除虚 IP。

7.2.1 使用说明

DELETE http://{endpoint}/vpc/v1.0/vips/{port_id}

调用 DeleteVirtualIP 删除一个虚 IP 实例。

与虚机或者 EIP 绑定的虚 IP,需要先解绑再删除。

7.2.2 请求参数

1.png

7.2.3 返回数据

2.png

7.2.4 示例

1. 请求示例

DELETE http://{endpoint}/vpc/v1.0/vips/{port_id}

2. 正常返回示例

HTTP/1.1 200 OK

Content-Type:application/json 

            "RequestId": "4553c4897137c1a2988b1a7558d65541"

}

7.3 GetVirtualIPList

调用 GetVirtualIPList 查询虚 IP 列表。

7.3.1 使用说明

GET http://{Endpoint}/vpc/v1.0/vips?SubnetId=snet-xxx

7.3.2 请求参数

1.png

7.3.3 返回数据

1.png

1.png

表7-1 VirtualIP Object

1.png

表7-2 EcsInfo 对象

2.png

7.3.4 示例

1. 请求示例

GET http://{Endpoint}/vpc/v1.0/vips?SubnetId=snet-7pjkmza8hh

2. 正常返回示例

HTTP/1.1 200 OK

Content-Type:application/json 

{

         "RequestId": "80be526fdf3a67b1a8ca871634fe1e01",

        "TotalCount": 2,

         "PageSize": 10,

         "PageNumber": 1,

         "Vips": [

             {

                     "PrivateIp": "192.168.12.2",

                     "SubnetId": "snet-xxx",

                     "VipId": "port-xxx",

                     "Eip": [

                            "10.253.37.254"

                    ],

                    "Ecs": [

                             {

                                     "EcsId": "ecs-xxx",

                                     "EcsIp": "192.168.12.4"

                             },

                             {

                                     "EcsId": "ecs-aaa",

                                     "EcsIp": "192.168.12.5"

                             }

                     ]

             },

             {

                     "PrivateIp": "192.168.12.8",

                     "SubnetId": "snet-xxx",

                     "VipId": "port-xxx",

                     "Eip": [],

                     "Ecs": [

                            {

                                     "EcsId": "ecs-bbb",

                                     "EcsIp": "192.168.12.9"

                            }

                     ]

             }

     ]

}

7.4 AttachElasticComputeService

调用 AttachElasticComputeService 绑定虚 IP 到虚机。

7.4.1 使用说明

PUT http://{endpoint}/vpc/v1.0/vips/attachEcs/{port_id}

7.4.2 请求参数

1.png

表7-3 EcsData 对象

2.png

7.4.3 返回数据

1.png

7.4.4 示例

1. 请求示例

PUT http://{endpoint}/vpc/v1.0/vips/attachEcs/{port_id}

{

         "EcsDatas": [

                 {

                         "InstanceUid": "ecs-xxx",

                         "EcsIP": "192.168.12.6"

                 }

         ],

         "SubnetId": "snet-xxx"

}

2. 正常返回示例

HTTP/1.1 200 OK

Content-Type:application/json 

        "RequestId": "4553c4897137c1a2988b1a7558d65541"

}

7.5 DetachElasticComputeService

调用 DetachElasticComputeService 解绑虚 IP 到虚机。

7.5.1 使用说明

PUT http://{endpoint}/vpc/v1.0/vips/detachEcs/{port_id}

7.5.2 请求参数

1.png

7.5.3 返回数据

2.png

7.5.4 示例

1. 请求示例

PUT http://{endpoint}/vpc/v1.0/vips/detachEcs/{port_id}

2. 正常返回示例

HTTP/1.1 200 OK

Content-Type:application/json 

        "RequestId": "4553c4897137c1a2988b1a7558d65541"

}

7.6 AttachElasticIP

调用 AttachElasticIP 绑定虚 IP 到弹性公网 IP。

7.6.1 使用说明

PUT http://{endpoint}/vpc/v1.0/vips/attachEip/{port_id}

7.6.2 请求参数

1.png

7.6.3 返回数据

2.png

7.6.4 示例

1. 请求示例

PUT http://{endpoint}/vpc/v1.0/vips/attachEip/{port_id}

{

         "InstanceUid": "eip-3j12uw7o2w5u",

         "PrivateIp": "192.168.12.8",

         "SubnetId": "snet-7pjkmza8hh",

         "Remark":"10.253.37.252"

}

2. 正常返回示例

HTTP/1.1 200 OK

Content-Type:application/json 

        "RequestId": "4553c4897137c1a2988b1a7558d65541"

}

7.7 DetachElasticIP

调用 DetachElasticIP 解绑虚 IP 到弹性公网 IP。

7.7.1 使用说明

PUT http://{endpoint}/vpc/v1.0/vips/detachEip/{port_id}

7.7.2 请求参数

1.png

7.7.3 返回数据

2.png

7.7.4 示例

1. 请求示例

PUT http://{endpoint}/vpc/v1.0/vips/detachEip/{port_id}

2. 正常返回示例

HTTP/1.1 200 OK

Content-Type:application/json 

        "RequestId": "4553c4897137c1a2988b1a7558d65541"

}

7.8 GetElasticComputeServiceList

调用 GetElasticComputeServiceList 查询未绑定的 ElasticComputeService 列表。

7.8.1 使用说明

PUT http://{endpoint}/vpc/v1.0/vips/listEcs?SubnetId=snet-7pjkmza8hh&VipId=port-a6nshnpana请求参数

1.png

7.8.2 返回数据

1.png

表7-4 EcsInfos Object

2.png

7.8.3 示例

1. 请求示例

PUT http://{endpoint}/vpc/v1.0/vips/listEcs?SubnetId=snet-7pjkmza8hh&VipId=port-a6nshnpana

2. 正常返回示例

HTTP/1.1 200 OK

Content-Type:application/json 

{

         "RequestId": "3767339aae16f22e6953c791d26988a2",

         "TotalCount": 2,

         "PageSize": 10,

         "PageNumber": 1,

         "EcsInfos": [

                 {

                         "FixedIp": "192.168.12.4",

                         "EcsName": "cecloud-ecs-55693",

                         "EcsId": "ecs-xcsni3liw3so73",

                         "Status": 2,

                         "VpcId": "",

                         "SubnetId": "snet-7pjkmza8hh",

                         "HostId": "",

                         "HostName": "",

                         "EcsIP": "192.168.12.4",

                         "NetWorkInterfaceId": ""

                 },

                 {

                         "FixedIp": "192.168.12.9",

                         "EcsName": "cecloud-ecs-26974",

                         "EcsId": "ecs-xccvzc4sqm3zte",

                         "Status": 2,

                         "VpcId": "",

                         "SubnetId": "snet-7pjkmza8hh",

                         "HostId": "",

                         "HostName": "",

                         "EcsIP": "192.168.12.9",

                         "NetWorkInterfaceId": ""

                }

        ]

}

7.9 错误码

1.png

2.png

意见反馈

文档内容是否对您有帮助?

如您有其他疑问,您也可以通过在线客服来与我们联系探讨 在线客服

联系我们
回到顶部