This topic describes how to use Alibaba Cloud SDK for Python to connect a virtual border router (VBR) to a virtual private cloud (VPC).
Prerequisites
Before you run Alibaba Cloud SDK for Python, make sure that the following requirements
are met:
- An Alibaba Cloud account and the AccessKey pair are obtained. You can create and view your AccessKey pair on the Security Management page of the Alibaba Cloud Management Console.
- Make sure that Alibaba Cloud SDK for Python is installed. For more information, see aliyun-python-sdk-vpc 3.0.11.
- The VPC Python example library is downloaded.
Go to the directory where the setup.py file is stored, and run the following command to initialize the environment:
python setup.py install
Background information
When you create a router interface, take note of the following limits:
- You can create only one pair of interfaces to be connected between two routers.
- You can create at most five router interfaces for each router.
- If your Alibaba Cloud account contains a router interface that has overdue payments, you cannot create new router interfaces.
- The destination CIDR blocks of routes in the same route table must be unique.
- The VBR must serve as the initiator and must be in the Activated state.
Procedure
Result
The following system output is displayed:
---------------------------create_virtual_border_router---------------------------
{
"VbrId": "vbr-bp1vudncgk9jt****",
"RequestId": "0C4FABDB-FF18-4E70-9E43-6DC03197F0EA"
}
---------------------------create_router_interface---------------------------
{
"RequestId": "11F14FA2-ECFA-4B27-A75D-7C6D5FECACDF",
"RouterInterfaceId": "ri-bp1vabte8nbde****"
}
---------------------------create_router_interface---------------------------
{
"RequestId": "72FAB86D-470B-40E4-8476-F9223A911486",
"RouterInterfaceId": "ri-bp1mxkc61ly0n****"
}
---------------------------modify_router_interface_attribute---------------------------
{
"RequestId": "93D5FFF7-6C05-41B1-92F0-AC8F1809BC98"
}
---------------------------modify_router_interface_attribute---------------------------
{
"RequestId": "1C461452-42BD-4649-B318-2214222B4FCA"
}
---------------------------describe_router_interface---------------------------
{
"TotalCount": 1,
"RouterInterfaceSet": {
"RouterInterfaceType": [
{
"BusinessStatus": "Normal",
"CreationTime": "2019-04-30T02:54:22Z",
"AccessPointId": "ap-cn-hangzhou-xx-x",
"Role": "InitiatingSide",
"OppositeRouterId": "vrt-bp141no9pds2b****",
"Spec": "Large.2",
"Status": "Idle",
"EndTime": "2999-09-08T16:00:00Z",
"OppositeInterfaceSpec": "Negative",
"RouterInterfaceId": "ri-bp1vabte8nbde****",
"RouterType": "VBR",
"OppositeBandwidth": 0,
"OppositeVpcInstanceId": "vpc-bp1v31by9jix2****",
"HasReservationData": false,
"OppositeInterfaceBusinessStatus": "Normal",
"OppositeRouterType": "VRouter",
"OppositeRegionId": "cn-hangzhou",
"RouterId": "vbr-bp1vudncgk9jt****",
"CrossBorder": false,
"OppositeInterfaceOwnerId": "",
"Bandwidth": 2048,
"OppositeInterfaceId": "ri-bp1mxkc61ly0n****",
"ChargeType": "AfterPay"
}
]
},
"PageNumber": 1,
"RequestId": "3553DB38-A4A0-4453-976C-542E96B1B5A9",
"PageSize": 10
}
---------------------------describe_router_interface---------------------------
{
"TotalCount": 1,
"RouterInterfaceSet": {
"RouterInterfaceType": [
{
"Status": "Idle",
"OppositeRegionId": "cn-hangzhou",
"BusinessStatus": "Normal",
"OppositeRouterId": "vbr-bp1vudncgk9jt****",
"VpcInstanceId": "vpc-bp1v31by9jix2****",
"RouterInterfaceId": "ri-bp1mxkc61ly0n****",
"CreationTime": "2019-04-30T02:54:24Z",
"RouterType": "VRouter",
"OppositeInterfaceOwnerId": "",
"RouterId": "vrt-bp141no9pds2b****",
"Bandwidth": 0,
"OppositeInterfaceId": "ri-bp1vabte8nbde****",
"EndTime": "2999-09-08T16:00:00Z",
"ChargeType": "AfterPay",
"OppositeAccessPointId": "ap-cn-hangzhou-xx-x",
"HasReservationData": false,
"CrossBorder": false,
"OppositeInterfaceBusinessStatus": "Normal",
"Spec": "Negative",
"OppositeRouterType": "VBR",
"Role": "AcceptingSide"
}
]
},
"PageNumber": 1,
"RequestId": "217D8D94-C508-4285-8101-7DE3B53A88A5",
"PageSize": 10
}
---------------------------describe_route_table---------------------------
{
"TotalCount": 1,
"PageNumber": 1,
"RequestId": "CA6BBE52-DF5E-496A-93CF-9857AF22D2AC",
"PageSize": 10,
"RouteTables": {
"RouteTable": [
{
"RouteTableId": "vtb-bp1s126yz0swp****",
"RouteEntrys": {
"RouteEntry": []
},
"CreationTime": "2019-04-30T02:54:19Z",
"VSwitchIds": {
"VSwitchId": []
},
"ResourceGroupId": "",
"VRouterId": "vbr-bp1vudncgk9jt****",
"RouteTableType": "System"
}
]
}
}
---------------------------connect_router_interface---------------------------
{
"RequestId": "93476D4E-6C08-44B8-83E4-5759E1A08F29"
}
---------------------------create_route_entry---------------------------
{
"RequestId": "66D4F46B-5E0F-4565-8740-845EC26EBE00"
}
---------------------------create_route_entry---------------------------
{
"RequestId": "E1F99FEF-2499-40A7-84ED-6F9D440D4FF8"
}
---------------------------delete_route_entry---------------------------
{
"RequestId": "8C983886-F058-4234-A6D7-ECDEE2C2D945"
}
---------------------------delete_route_entry---------------------------
{
"RequestId": "DDEC56B9-CDD4-4D0A-B460-040B85B97FE9"
}
---------------------------deactivate_router_interface---------------------------
{
"RequestId": "04069B7C-6A42-43F2-A086-50F802940045"
}
---------------------------deactivate_router_interface---------------------------
{
"RequestId": "B2EBF829-E1C0-43E5-9BAD-DFFCBFA301F7"
}
---------------------------delete_router_interface---------------------------
{
"RequestId": "20EEC4A6-E468-4F3C-A743-89193F7504E1"
}
---------------------------delete_router_interface---------------------------
{
"RequestId": "59DCE168-B9CC-43A3-A54F-0D8C194BABE0"
}
---------------------------delete_virtual_border_router---------------------------
{
"RequestId": "E1D71EEC-FE9F-4834-8780-19EBBD91A638"
}