百度智能云

All Product Document

          Virtual Private Cloud

          Peer Connection

          Acquire Endpoint

          When confirming the Endpoint configured when you use the SDK, you can first read the section on VPC Service Domain Name in the Developer Guide to understand the Endpoint concept. Baidu AI Cloud currently opens the multi-region (Region) support. Please refer to the part of network product VPC in Region Selection Introduction. The peer connection services are a part of VPC services, and use the VPC service domain name.

          Get the Key

          To use Baidu Cloud products, you need to have a Baidu Cloud account and a valid AK (Access Key ID) and SK (Secret Access Key) for signature verification. You can obtain and understand your AK/SK information through the following steps:

          1.[Register Baidu Cloud Account](https://login.bce.baidu.com/reg.html? tpl=bceplat&from=portal)

          2.[Create AK/SK](https://console.bce.baidu.com/iam/? _=1513940574695#/iam/accesslist)

          Peerconn_client

          The peerconn_client encapsulates the API of peer connection services, and simplifies the interaction between developers and peer connection services. The users can call the methods in peerconn_client to configure the peer connection. The method return parameter in peerconn_client is consistent with API Method.

          Create peerconn_client

          When creating peerconn_client, you need to first use Endpoint, AK and SK to configure the BceClientConfiguration type config instance, and then use the config instance to configure the peerconn_client. The specific configuration method is as follows:

          HOST = b''
           AK = b''
           SK = b''
           config = BceClientConfiguration(
               credentials=BceCredentials(AK, SK), endpoint=HOST)
           self.client = peerconn_client.PeerConnClient(config)

          Create a Peer Connection

          When the peer connection is created, attention should be paid to:

          • For the peer connection of the same account, the system will trigger the opposite terminal for automatic acceptance.
          • For the cross-account peer connection, the peer connection is available only after being accepted by the acceptor.
          • For the peer connections with the same local region and opposite terminal region, the billing parameter only supports the postpaid (the billing parameter should be transmitted, but the bill is 0).
          • Only one peer connection exists between any two VPC.
          • The VPCs of the initiator and the acceptor cannot be the same.
          • If the local vpc and opposite terminal vpc are both relay vpc, the peer connection cannot be established.

          The create_peerconn function can be used to create the peer connection in the specified VPC, and is defined as below:

          @required(bandwidth_in_mbps=int,
                     local_vpc_id=(bytes, str),
                     peer_vpc_id=(bytes, str),
                     peer_region=(bytes, str))
          def create_peerconn(self, bandwidth_in_mbps, local_vpc_id,
                              peer_vpc_id, peer_region, description=None,
                              local_if_name=None, peer_account_id=None,
                              peer_if_name=None, client_token=None,
                              billing=None, config=None)

          The parameters are described as follows:

          Parameter name Type Required or not Description
          bandwidth_in_mbps int Yes the maximum bandwidth of peer connection, in mbps.
          local_vpc_id Bytes or str Yes Local VPC ID
          peer_vpc_id Bytes or str Yes Opposite terminal VPC ID
          peer_region Bytes or str Yes Opposite terminal region
          description Bytes or str No Description
          local_if_name Bytes or str No Local interface name
          peer_account_id Bytes or str No Opposite terminal account ID
          peer_if_name Bytes or str No Opposite terminal interface name
          client_token Bytes or str No The idempotence Token is a ASCII string with a length not exceeding 64 bits. Refer to Idempotence Token for details.
          billing Customized Billing type No The billing mode is postpayment by default and supports the monthly repayment. Refer to Billing Description for details.
          config BceClientConfiguration No Config in initializing peerconn_client by default

          For the customized Billing type definition, refer to peerconn_model.py. The region parameter is as follows:

          Name Value
          Beijing bj
          Guangzhou gz
          Suzhou su
          Shanghai fsh
          Hong Kong hkg
          Baoding bd
          Du Xiaoman Finance Special Zone hb-fsg
          Wuhan fwh
          Singapore sin
          Du Xiaoman Finance Special Zone II bjfsg

          Query the Peer Connection List

          The list_peerconns function can be used to query the peer connection list, and is defined as below:

          @required(vpc_id=(bytes, str))
          def list_peerconns(self, vpc_id, marker=None,
                             max_keys=None, config=None)

          The parameters are described as follows:

          Parameter name Type Required or not Description
          vpc_id Bytes or str Yes ID of VPC to which NAT gateway belongs
          marker Bytes or str No Starting location of query for batch acquisition of lists
          maxKeys int No Maximum number contained in each page, generally not exceeding 1000. The default value is 1000.
          config BceClientConfiguration No Config in initializing peerconn_client by default

          Query the Peer Connection Details

          The get_nat function can be used to query the NAT details, and is defined as below:

          @required(peer_conn_id=(bytes, str))
          def get_peerconn(self, peer_conn_id, config=None)

          The parameters are described as follows:

          Parameter name Type Required or not Description
          peer_conn_id Bytes or str Yes peer connection ID
          config BceClientConfiguration No Config in initializing peerconn_client by default

          Update the Local Interface Name and Comments of peer Connection

          The update_peerconn function can be used to update the peer connection, and is defined as below:

          @required(peer_conn_id=(bytes, str), local_if_id=(bytes, str))
          def update_peerconn(self, peer_conn_id, local_if_id, description=None,
                              local_if_name=None, client_token=None, config=None)

          The parameters are described as follows:

          Parameter name Type Required or not Description
          peer_conn_id Bytes or str Yes peer connection ID
          local_if_id Bytes or str Yes Local interface ID
          description Bytes or str No Description
          local_if_name Bytes or str No Local interface name
          client_token Bytes or str No The idempotence Token is a ASCII string with a length not exceeding 64 bits. Refer to Idempotence Token for details.
          config BceClientConfiguration No Config in initializing peerconn_client by default

          Process the peer Connection Application

          • When the connection request timeout initiated by the initiator is 7 days, the status of the peer connection of the initiator after time-out is "Consultation Failed".
          • After the acceptor denies, the status of the peer connection of the initiator is "Consultation Failed".

          The handle_peerconn function can be used to update the peer connection, and is defined as below:

          @required(peer_conn_id=(bytes, str), action=(bytes, str))
          def handle_peerconn(self, peer_conn_id, action, client_token=None,
                              config=None)

          The parameters are described as follows:

          Parameter name Type Required or not Description
          peer_conn_id Bytes or str Yes peer connection ID
          action Bytes or str Yes In this interface, the value taken for rejection parameter is "reject" and that for acceptance parameter is "accept".
          client_token Bytes or str No The idempotence Token is a ASCII string with a length not exceeding 64 bits. Refer to Idempotence Token for details.
          config BceClientConfiguration No Config in initializing peerconn_client by default

          Release the Peer Connection

          The delete_peerconn function can be used to release the peer connection, and is defined as below:

          @required(peer_conn_id=(bytes, str))
          def delete_peerconn(self, peer_conn_id, client_token=None,
                              config=None)

          The parameters are described as follows:

          Parameter name Type Required or not Description
          peer_conn_id Bytes or str Yes peer connection ID
          client_token Bytes or str No The idempotence Token is a ASCII string with a length not exceeding 64 bits. Refer to Idempotence Token for details.
          config BceClientConfiguration No Config in initializing peerconn_client by default

          Upgrade and Degrade of peer Connection Bandwidth

          The resize_peerconn function can be used to release the peer connection, and is defined as below:

          @required(peer_conn_id=(bytes, str), new_bandwidth_in_mbps=int)
          def resize_peerconn(self, peer_conn_id, new_bandwidth_in_mbps,
                              client_token=None, config=None)

          The parameters are described as follows:

          Parameter name Type Required or not Description
          peer_conn_id Bytes or str Yes peer connection ID
          new_bandwidth_in_mbps int Yes Upgraded bandwidth of peer connection
          client_token Bytes or str No The idempotence Token is a ASCII string with a length not exceeding 64 bits. Refer to Idempotence Token for details.
          config BceClientConfiguration No Config in initializing peerconn_client by default

          Peer Connection Renewal

          • The postpaid peer connection cannot be renewed.
          • The cross-account renewal can only be operated by the initiator.

          The purchase_reserved_peerconn function can be used to release the peer connection, and is defined as below:

          @required(peer_conn_id=(bytes, str))
          def purchase_reserved_peerconn(self, peer_conn_id, client_token=None,
                                         billing=None, config=None)

          The parameters are described as follows:

          Parameter name Type Required or not Description
          peer_conn_id Bytes or str Yes peer connection ID
          billing Customized Billing type No Billing mode, 1 month by default
          client_token Bytes or str No The idempotence Token is a ASCII string with a length not exceeding 64 bits. Refer to Idempotence Token for details.
          config BceClientConfiguration No Config in initializing peerconn_client by default

          Open the Synchronous DNS of peer Connection

          • The DNS can be enabled only when the status of peer connection is "available".
          • The synchronization of DNS cannot be enabled when the DNS status of peer connection is "Synchronizing" or "Synchronization Closed".

          The open_peerconn_dns_syn function can be used to release the peer connection, and is defined as below:

          @required(peer_conn_id=(bytes, str), role=(bytes, str))
          def open_peerconn_dns_sync(self, peer_conn_id, role,
                                     client_token=None, config=None)

          The parameters are described as follows:

          Parameter name Type Required or not Description
          peer_conn_id Bytes or str Yes peer connection ID
          role Bytes or str Yes "initiator" and "acceptor"
          client_token Bytes or str No The idempotence Token is a ASCII string with a length not exceeding 64 bits. Refer to Idempotence Token for details.
          config BceClientConfiguration No Config in initializing peerconn_client by default

          Close the Synchronous DNS of peer Connection

          • The DNS can be closed only when the status of peer connection is "available".
          • The synchronization of DNS cannot be closed when the DNS status of peer connection is "Synchronizing" or "Synchronization Closed".

          The close_peerconn_dns_syn function can be used to release the peer connection, and is defined as below:

          @required(peer_conn_id=(bytes, str), role=(bytes, str))
          def close_peerconn_dns_sync(self, peer_conn_id, role,
                                      client_token=None, config=None)

          The parameters are described as follows:

          Parameter name Type Required or not Description
          peer_conn_id Bytes or str Yes peer connection ID
          role Bytes or str Yes "initiator" and "acceptor"
          client_token Bytes or str No The idempotence Token is a ASCII string with a length not exceeding 64 bits. Refer to Idempotence Token for details.
          config BceClientConfiguration No Config in initializing peerconn_client by default
          Previous
          NAT
          Next
          Version Description