Creating a Virtual Interface Peer
Function
This API is used to create an IPv6 peer. Each virtual interface can have two peers: IPv4 and IPv6 peers. When a virtual interface is created, an IPv4 peer is created by default. After a virtual interface peer is created, you can query its settings by viewing the virtual interface details. This API is available only in regions that support IPv6. To use this API, contact customer service.
Calling Method
For details, see Calling APIs.
URI
POST /v3/{project_id}/dcaas/vif-peers
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Specifies the project ID. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
Specifies the user token. To obtain the token, see section "Obtaining the User Token" in the Identity and Access Management API Reference. The token is the value of X-Subject-Token in the response header. Minimum: 0 Maximum: 10240 |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
vif_peer |
No |
CreateVifPeer object |
Specifies parameters for creating a virtual interface peer. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
No |
String |
Specifies the name of the virtual interface peer. Minimum: 0 Maximum: 64 |
description |
No |
String |
Provides supplementary information about the virtual interface peer. Minimum: 0 Maximum: 128 |
address_family |
No |
String |
Specifies the address family of the virtual interface, which can be IPv4 or IPv6. |
local_gateway_ip |
No |
String |
Specifies the cloud-side gateway IP address of the virtual interface peer. |
remote_gateway_ip |
No |
String |
Specifies the customer-side gateway address of the virtual interface peer. |
route_mode |
No |
String |
Specifies the routing mode, which can be static or bgp. Maximum: 255 Enumeration values:
|
bgp_asn |
No |
Integer |
Specifies the AS of the BGP peer. Minimum: 1 Maximum: 4294967295 |
bgp_md5 |
No |
String |
Specifies the MD5 password of the BGP peer. |
remote_ep_group |
No |
Array of strings |
Specifies the remote subnet list, which records the CIDR blocks used in the on-premises data center. |
vif_id |
No |
String |
Specifies the ID of the virtual interface corresponding to the virtual interface peer. Minimum: 36 Maximum: 36 |
Response Parameters
Status code: 201
Parameter |
Type |
Description |
---|---|---|
vif_peer |
VifPeer object |
Specifies the virtual interface peer. |
Parameter |
Type |
Description |
---|---|---|
id |
String |
Specifies the resource ID. Minimum: 36 Maximum: 36 |
tenant_id |
String |
Specifies the ID of the project that the virtual interface peer belongs to. Minimum: 36 Maximum: 36 |
name |
String |
Specifies the name of the virtual interface peer. Minimum: 0 Maximum: 64 |
description |
String |
Provides supplementary information about the virtual interface peer. Minimum: 0 Maximum: 128 |
address_family |
String |
Specifies the address family type of the virtual interface, which can be IPv4 or IPv6. |
local_gateway_ip |
String |
Specifies the address of the virtual interface peer used on the cloud. |
remote_gateway_ip |
String |
Specifies the address of the virtual interface peer used in the on-premises data center. |
route_mode |
String |
Specifies the routing mode, which can be static or bgp. Maximum: 255 Enumeration values:
|
bgp_asn |
Integer |
Specifies the ASN of the BGP peer. Minimum: 1 Maximum: 4294967295 |
bgp_md5 |
String |
Specifies the MD5 password of the BGP peer. |
remote_ep_group |
Array of strings |
Specifies the remote subnet list, which records the CIDR blocks used in the on-premises data center. |
service_ep_group |
Array of strings |
Specifies the list of public network addresses that can be accessed by the on-premises data center. This field is required in the APIs of public network connections. |
device_id |
String |
Specifies the ID of the device that the virtual interface peer belongs to. |
bgp_route_limit |
Integer |
Specifies the BGP route configuration. |
bgp_status |
String |
Specifies the BGP protocol status of the virtual interface peer. If the virtual interface peer uses static routing, the status is null. Maximum: 10 |
status |
String |
Specifies the status of the virtual interface peer. |
vif_id |
String |
Specifies the ID of the virtual interface corresponding to the virtual interface peer. Minimum: 36 Maximum: 36 |
receive_route_num |
Integer |
Specifies the number of received BGP routes if BGP routing is used. If static routing is used, this parameter is meaningless and the value is -1. Note: If this parameter cannot be obtained, contact customer service to migrate your ports. |
enable_nqa |
Boolean |
Specifies whether to enable NQA. The value can be true or false. |
enable_bfd |
Boolean |
Specifies whether to enable BFD. The value can be true or false. |
Example Requests
Creating a virtual interface peer with the remote subnet set to 20.1.1.0/24
POST https://{endpoint}/v3/cfa563efb77d4b6d9960781d82530fd8/dcaas/vif-peers/68250543-0a13-4ac7-aa36-d018856ac640 { "vif_peer" : { "name" : "vif-0819", "description" : "mytest", "remote_ep_group" : [ "20.1.1.0/24" ] } }
Example Responses
Status code: 201
Created
{ "vif_peer" : { "name" : "vif-0819", "description" : "mytest", "id" : "4c95de3e-9f75-4357-9c79-b22498dd71c7", "tenant_id" : "ed28c294165741faaeccab26913122a1", "address_family" : "ipv4", "local_gateway_ip" : "12.3.4.1/30", "remote_gateway_ip" : "12.3.4.2/30", "route_mode" : "static", "bgp_asn" : null, "bgp_md5" : null, "bgp_route_limit" : 100, "bgp_status" : null, "status" : "ACTIVE", "vif_id" : "5d6c17bc-0ebe-420b-8734-21f519e9d7ad", "receive_route_num" : -1, "remote_ep_group" : [ "12.3.4.0/30 172.56.0.0/16" ] } }
SDK Sample Code
The SDK sample code is as follows.
Creating a virtual interface peer with the remote subnet set to 20.1.1.0/24
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.dc.v3.region.DcRegion; import com.huaweicloud.sdk.dc.v3.*; import com.huaweicloud.sdk.dc.v3.model.*; import java.util.List; import java.util.ArrayList; public class CreateVifPeerSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); ICredential auth = new BasicCredentials() .withAk(ak) .withSk(sk); DcClient client = DcClient.newBuilder() .withCredential(auth) .withRegion(DcRegion.valueOf("<YOUR REGION>")) .build(); CreateVifPeerRequest request = new CreateVifPeerRequest(); CreateVifPeerRequestBody body = new CreateVifPeerRequestBody(); List<String> listVifPeerRemoteEpGroup = new ArrayList<>(); listVifPeerRemoteEpGroup.add("20.1.1.0/24"); CreateVifPeer vifPeerbody = new CreateVifPeer(); vifPeerbody.withName("vif-0819") .withDescription("mytest") .withRemoteEpGroup(listVifPeerRemoteEpGroup); body.withVifPeer(vifPeerbody); request.withBody(body); try { CreateVifPeerResponse response = client.createVifPeer(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
Creating a virtual interface peer with the remote subnet set to 20.1.1.0/24
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkdc.v3.region.dc_region import DcRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkdc.v3 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.getenv("CLOUD_SDK_AK") sk = os.getenv("CLOUD_SDK_SK") credentials = BasicCredentials(ak, sk) \ client = DcClient.new_builder() \ .with_credentials(credentials) \ .with_region(DcRegion.value_of("<YOUR REGION>")) \ .build() try: request = CreateVifPeerRequest() listRemoteEpGroupVifPeer = [ "20.1.1.0/24" ] vifPeerbody = CreateVifPeer( name="vif-0819", description="mytest", remote_ep_group=listRemoteEpGroupVifPeer ) request.body = CreateVifPeerRequestBody( vif_peer=vifPeerbody ) response = client.create_vif_peer(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
Creating a virtual interface peer with the remote subnet set to 20.1.1.0/24
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" dc "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dc/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dc/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dc/v3/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). Build() client := dc.NewDcClient( dc.DcClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.CreateVifPeerRequest{} var listRemoteEpGroupVifPeer = []string{ "20.1.1.0/24", } nameVifPeer:= "vif-0819" descriptionVifPeer:= "mytest" vifPeerbody := &model.CreateVifPeer{ Name: &nameVifPeer, Description: &descriptionVifPeer, RemoteEpGroup: &listRemoteEpGroupVifPeer, } request.Body = &model.CreateVifPeerRequestBody{ VifPeer: vifPeerbody, } response, err := client.CreateVifPeer(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.
Status Codes
Status Code |
Description |
---|---|
201 |
Created |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot