Actualización de un par de interfaz virtual
Función
Esta API se utiliza para actualizar un par de la interfaz virtual, por ejemplo, su subred remota, nombre y descripción. Esta API solo está disponible en regiones que admiten IPv6. Para utilizar esta API, póngase en contacto con el servicio de atención al cliente.
Método de invocación
Para obtener más información, consulte Invocación a las API.
URI
PUT /v3/{project_id}/dcaas/vif-peers/{vif_peer_id}
Parámetro |
Obligatorio |
Tipo |
Descripción |
---|---|---|---|
project_id |
Sí |
String |
Especifica el ID del proyecto. |
vif_peer_id |
Sí |
String |
Especifica el identificador del par de la interfaz virtual. |
Parámetros de solicitud
Parámetro |
Obligatorio |
Tipo |
Descripción |
---|---|---|---|
X-Auth-Token |
Sí |
String |
Especifica el token de usuario. Para obtener el token, consulte la sección "Obtención del token de usuario" en la Referencia de las API de Identity and Access Management. El token es el valor de X-Subject-Token en el encabezado de respuesta. Mínimo: 0 Máximo: 10240 |
Parámetro |
Obligatorio |
Tipo |
Descripción |
---|---|---|---|
vif_peer |
No |
UpdateVifPeer object |
Especifica los parámetros para actualizar un par de interfaz virtual. |
Parámetro |
Obligatorio |
Tipo |
Descripción |
---|---|---|---|
name |
No |
String |
Especifica el nombre del par de interfaz virtual. Mínimo: 0 Máximo: 64 |
description |
No |
String |
Proporciona información adicional sobre el par de la interfaz virtual. Mínimo: 0 Máximo: 128 |
remote_ep_group |
No |
Array of strings |
Especifica la lista de subred remota, que registra los bloques CIDR utilizados en el centro de datos local. |
Parámetros de respuesta
Código de estado: 200
Parámetro |
Tipo |
Descripción |
---|---|---|
vif_peer |
VifPeer object |
Especifica el par de la interfaz virtual. |
Parámetro |
Tipo |
Descripción |
---|---|---|
id |
String |
Especifica el ID del recurso. Mínimo: 36 Máximo: 36 |
tenant_id |
String |
Especifica el ID del proyecto al que pertenece el par de la interfaz virtual. Mínimo: 36 Máximo: 36 |
name |
String |
Especifica el nombre del par de interfaz virtual. Mínimo: 0 Máximo: 64 |
description |
String |
Proporciona información adicional sobre el par de la interfaz virtual. Mínimo: 0 Máximo: 128 |
address_family |
String |
Especifica el tipo de familia de direcciones de la interfaz virtual, que puede ser IPv4 o IPv6. |
local_gateway_ip |
String |
Especifica la dirección del par de interfaz virtual utilizado en la nube. |
remote_gateway_ip |
String |
Especifica la dirección del par de interfaz virtual utilizado en el centro de datos local. |
route_mode |
String |
Especifica el modo de enrutamiento, que puede ser static o bgp. Máximo: 255 Valores de enumeración:
|
bgp_asn |
Integer |
Especifica el ASN del par de BGP. Mínimo: 1 Máximo: 4294967295 |
bgp_md5 |
String |
Especifica la contraseña de MD5 del par BGP. |
remote_ep_group |
Array of strings |
Especifica la lista de subred remota, que registra los bloques CIDR utilizados en el centro de datos local. |
service_ep_group |
Array of strings |
Especifica la lista de direcciones de red pública a las que puede acceder el centro de datos local. Este campo es obligatorio en las API de conexiones de red pública. |
device_id |
String |
Especifica el ID del dispositivo al que pertenece el par de interfaz virtual. |
bgp_route_limit |
Integer |
Especifica la configuración de enrutamiento de BGP. |
bgp_status |
String |
Especifica el estado del protocolo BGP del par de interfaz virtual. Si el par de la interfaz virtual utiliza enrutamiento estático, el estado es null. Máximo: 10 |
status |
String |
Especifica el estado del par de la interfaz virtual. |
vif_id |
String |
Especifica el ID de la interfaz virtual correspondiente al par de la interfaz virtual. Mínimo: 36 Máximo: 36 |
receive_route_num |
Integer |
Especifica el número de enrutamientos de BGP recibidos si se utiliza el enrutamiento de BGP. Si se utiliza el enrutamiento estático, este parámetro no tiene sentido y el valor es -1. Nota: Si no se puede obtener este parámetro, póngase en contacto con el servicio de atención al cliente para migrar los puertos. |
enable_nqa |
Boolean |
Especifica si se va a habilitar NQA. El valor puede ser true o false. |
enable_bfd |
Boolean |
Especifica si se activa BFD. El valor puede ser true o false. |
Ejemplo de solicitudes
Actualizar el nombre, la descripción y la subred remota de un par de interfaz virtual
PUT 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" ] } }
Ejemplo de respuestas
Código de estado: 200
Aceptar
{ "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" : [ "20.1.1.0/24" ] } }
Ejemplo de código del SDK
El ejemplo de código del SDK es el siguiente.
Java
Actualizar el nombre, la descripción y la subred remota de un par de interfaz virtual
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 UpdateVifPeerSolution { 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(); UpdateVifPeerRequest request = new UpdateVifPeerRequest(); UpdateVifPeerRequestBody body = new UpdateVifPeerRequestBody(); List<String> listVifPeerRemoteEpGroup = new ArrayList<>(); listVifPeerRemoteEpGroup.add("20.1.1.0/24"); UpdateVifPeer vifPeerbody = new UpdateVifPeer(); vifPeerbody.withName("vif-0819") .withDescription("mytest") .withRemoteEpGroup(listVifPeerRemoteEpGroup); body.withVifPeer(vifPeerbody); request.withBody(body); try { UpdateVifPeerResponse response = client.updateVifPeer(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()); } } } |
Python
Actualizar el nombre, la descripción y la subred remota de un par de interfaz virtual
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 = UpdateVifPeerRequest() listRemoteEpGroupVifPeer = [ "20.1.1.0/24" ] vifPeerbody = UpdateVifPeer( name="vif-0819", description="mytest", remote_ep_group=listRemoteEpGroupVifPeer ) request.body = UpdateVifPeerRequestBody( vif_peer=vifPeerbody ) response = client.update_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) |
Go
Actualizar el nombre, la descripción y la subred remota de un par de interfaz virtual
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.UpdateVifPeerRequest{} var listRemoteEpGroupVifPeer = []string{ "20.1.1.0/24", } nameVifPeer:= "vif-0819" descriptionVifPeer:= "mytest" vifPeerbody := &model.UpdateVifPeer{ Name: &nameVifPeer, Description: &descriptionVifPeer, RemoteEpGroup: &listRemoteEpGroupVifPeer, } request.Body = &model.UpdateVifPeerRequestBody{ VifPeer: vifPeerbody, } response, err := client.UpdateVifPeer(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
Otro más
Para obtener un ejemplo de código del SDK de más lenguajes de programación, consulta la ficha Ejemplo de código en API Explorer. El ejemplo de código del SDK se puede generar automáticamente.
Códigos de estado
Código de estado |
Descripción |
---|---|
200 |
Aceptar |
Códigos de error
Consulte Códigos de error.