华为云用户手册

  • 插件安装 CCE提供了节点本地域名解析加速插件,可以方便的安装NodeLocal DNSCache。 NodeLocal DNSCache不提供Hosts、Rewrite等插件能力,仅作为CoreDNS的透明缓存代理。如有需要,可在CoreDNS配置中修改。 (可选)修改CoreDNS配置,让CoreDNS优先采用UDP协议与上游DNS服务器通信。 NodeLocal DNSCache采用TCP协议与CoreDNS进行通信,CoreDNS会根据请求来源使用的协议与上游DNS服务器进行通信。当使用了NodeLocal DNSCache时,访问上游DNS服务器时会使用TCP协议,而云上DNS服务器对TCP协议支持有限,如果您使用了NodeLocal DNSCache,您需要修改CoreDNS配置,让其总是优先采用UDP协议与上游DNS服务器进行通信,避免解析异常。 执行如下步骤,在forward插件中指定请求上游的协议为perfer_udp,修改之后CoreDNS会优先使用UDP协议与上游通信。 登录CCE控制台,单击集群名称进入集群。 在左侧导航栏中选择“插件中心”,在“已安装插件”下,在CoreDNS下单击“编辑”,进入插件详情页。 在“参数配置”下编辑高级配置,在plugins字段修改以下内容。 { "configBlock": "prefer_udp", "name": "forward", "parameters": ". /etc/resolv.conf" } 登录CCE控制台,单击集群名称进入集群,在左侧导航栏中选择“插件中心”,在右侧找到节点本地域名解析加速插件,单击“安装”。 在安装插件页面,选择插件规格,并配置相关参数。 DNSConfig自动注入:启用后,会创建DNSConfig动态注入控制器,该控制器基于Admission Webhook机制拦截目标命名空间(即命名空间包含标签node-localdns-injection=enabled)下Pod的创建请求,自动配置使用DNS缓存的Pod dnsConfig字段。未开启DNSConfig自动注入或Pod属于非目标命名空间,则需要手动给Pod配置DNSConfig。 目标命名空间:启用DNSConfig自动注入时支持设置。仅1.3.0及以上版本的插件支持。 全部开启:CCE会为已创建的命名空间添加标签(node-local-dns-injection=enabled),同时会识别命名空间的创建请求并自动添加标签,这些操作的目标不包含系统内置的命名空间(如kube-system)。 手动配置:手动为需要注入DNSConfig的命名空间添加标签(node-local-dns-injection=enabled),操作步骤请参见管理命名空间标签。 完成以上配置后,单击“安装”。
  • 常见问题 如何避免DNSConfig自动注入? 解决方案: 如果某个工作负载需要避免DNSConfig自动注入,可在Pod模板的labels字段中添加node-local-dns-injection: disabled的标签。示例如下: apiVersion: apps/v1 kind: Deployment metadata: name: test namespace: default spec: replicas: 2 selector: matchLabels: app: test template: metadata: labels: app: test node-local-dns-injection: disabled # 避免DNSConfig自动注入 spec: containers: - name: container-1 image: nginx:latest imagePullPolicy: IfNotPresent imagePullSecrets: - name: default-secret
  • 前提条件 Ingress为后端工作负载提供网络访问,因此集群中需提前部署可用的工作负载。若您无可用工作负载,可参考创建无状态负载(Deployment)、创建有状态负载(StatefulSet)或创建守护进程集(DaemonSet)部署工作负载。 为上述工作负载配置ClusterIP类型或NodePort类型的Service,可参考集群内访问(ClusterIP)或节点访问(NodePort)配置示例Service。 添加Nginx Ingress时,需在集群中提前安装NGINX Ingress 控制器,具体操作可参考安装插件。
  • 添加Nginx Ingress 本节以Nginx作为工作负载并添加Nginx Ingress为例进行说明。 登录CCE控制台,单击集群名称进入集群。 选择左侧导航栏的“服务”,在右侧选择“路由”页签,单击右上角“创建路由”。 设置Ingress参数。 名称:自定义Ingress名称,例如nginx-ingress-demo。 命名空间:选择需要添加Ingress的命名空间。 对接Nginx:集群中已安装NGINX Ingress控制器插件后显示此选项,未安装nginx-ingress模板时本选项不显示。 单击开启后将对接nginx-ingress提供7层访问,可配置如下参数。 TLS配置:nginx-ingress支持HTTP和HTTPS,安装nginx-ingress时预留的监听端口,默认HTTP为80,HTTPS为443。使用HTTPS需要配置相关证书。 服务器证书:创建HTTPS协议监听时需要绑定TLS类型的密钥证书,以支持HTTPS数据传输加密认证,创建密钥的方法请参见创建密钥。 SNI:SNI(Server Name Indication)是TLS的扩展协议,在该协议下允许同一个IP地址和端口号下对外提供多个基于TLS的访问域名,且不同的域名可以使用不同的安全证书。开启SNI后,允许客户端在发起TLS握手请求时就提交请求的域名信息。负载均衡收到TLS请求后,会根据请求的域名去查找证书:若找到域名对应的证书,则返回该证书认证鉴权;否则,返回缺省证书(服务器证书)认证鉴权。 转发策略配置:请求的访问地址与转发规则匹配时(转发规则由域名、URL组成),此请求将被转发到对应的目标Service处理。单击“添加转发策略”按钮可添加多条转发策略。 域名:实际访问的域名地址。请确保所填写的域名已注册并备案,在Ingress创建完成后,将域名与自动创建的负载均衡实例的IP(即Ingress访问地址的IP部分)绑定。一旦配置了域名规则,则必须使用域名访问。 URL匹配规则: 默认:默认为前缀匹配。 前缀匹配:例如映射URL为/healthz,只要符合此前缀的URL均可访问。例如/healthz/v1,/healthz/v2。 精确匹配:表示只有URL完全匹配时,访问才能生效。例如映射URL为/healthz,则必须为此URL才能访问。 URL:需要注册的访问路径,例如:/healthz。 Nginx Ingress的访问路径匹配规则是基于“/”符号分隔的路径前缀匹配,并区分大小写。只要访问路径以“/”符号分隔后的子路径匹配此前缀,均可正常访问,但如果该前缀仅是子路径中的部分字符串,则不会匹配。例如URL设置为/healthz,则匹配/healthz/v1,但不匹配/healthzv1。 此处添加的访问路径要求后端应用内存在相同的路径,否则转发无法生效。 例如,Nginx应用默认的Web访问路径为“/usr/share/nginx/html”,在为Ingress转发策略添加“/test”路径时,需要应用的Web访问路径下也包含相同路径,即“/usr/share/nginx/html/test”,否则将返回404。 目标服务名称:请选择已有Service或新建Service。页面列表中的查询结果已自动过滤不符合要求的Service。 目标服务访问端口:可选择目标Service的访问端口。 操作:可单击“删除”按钮删除该配置。 注解:以“key: value”形式设置,可通过Annotations查询nginx-ingress支持的配置。 配置完成后,单击“确定”。 创建完成后,在Ingress列表可查看到已添加的Ingress。
  • 响应示例 状态码: 200 OK { "tags" : [ { "key" : "keys", "values" : [ "value" ] }, { "key" : "key3", "values" : [ "value3", "value33" ] }, { "key" : "key1", "values" : [ "value1" ] }, { "key" : "key2", "values" : [ "value2", "value22" ] } ] }
  • Python 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 # coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdker.v3.region.er_region import ErRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdker.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 = ErClient.new_builder() \ .with_credentials(credentials) \ .with_region(ErRegion.value_of("cn-north-4")) \ .build() try: request = ListProjectTagsRequest() response = client.list_project_tags(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
  • URI GET /v3/{project_id}/{resource_type}/tags 表1 路径参数 参数 是否必选 参数类型 描述 project_id 是 String 项目ID resource_type 是 String 标签资源类型: instance: 企业路由器实例 route-table: 路由表 vpc-attachment: VPC连接 vgw-attachment: 虚拟网关连接 peering-attachment: 对等连接(Peering)连接 vpn-attachment: VPN网关连接 attachments: 所有连接类型
  • Java 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 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.er.v3.region.ErRegion; import com.huaweicloud.sdk.er.v3.*; import com.huaweicloud.sdk.er.v3.model.*; public class ListProjectTagsSolution { 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); ErClient client = ErClient.newBuilder() .withCredential(auth) .withRegion(ErRegion.valueOf("cn-north-4")) .build(); ListProjectTagsRequest request = new ListProjectTagsRequest(); try { ListProjectTagsResponse response = client.listProjectTags(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()); } } }
  • Go 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 package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" er "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/er/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/er/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/er/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 := er.NewErClient( er.ErClientBuilder(). WithRegion(region.ValueOf("cn-north-4")). WithCredential(auth). Build()) request := &model.ListProjectTagsRequest{} response, err := client.ListProjectTags(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • 响应示例 状态码: 200 OK { "instances" : [ { "id" : "94c2b814-99dc-939a-e811-ae84c61ea3ff", "name" : "my_er", "description" : "this is my first enterprise router", "asn" : 64512, "project_id" : "08d5a9564a704afda6039ae2babbef3c", "enable_default_association" : true, "enable_default_propagation" : true, "default_association_route_table_id" : "7f7f738f-453c-40b1-be26-28e7b9e390c1", "default_propagation_route_table_id" : "7f7f738f-453c-40b1-be26-28e7b9e390c1", "auto_accept_shared_attachments" : false, "created_at" : "2019-09-06 02:11:13Z", "updated_at" : "2019-09-06 02:11:13Z", "tags" : [ { "key" : "key", "value" : "value" } ], "enterprise_project_id" : 0, "availability_zone_ids" : [ "az1", "az2" ] } ], "request_id" : "915a14a6-867b-4af7-83d1-70efceb146f9", "page_info" : { "next_marker" : "2", "current_count" : 1 } }
  • URI GET /v3/{project_id}/enterprise-router/instances 表1 路径参数 参数 是否必选 参数类型 描述 project_id 是 String 项目ID 表2 Query参数 参数 是否必选 参数类型 描述 limit 否 Integer 每页返回的个数。 取值范围:0~2000。 最小值:0 最大值:2000 marker 否 String 查询的页码id,为空时为查询第一页。 使用说明:必须与limit一起使用。 最小长度:1 最大长度:128 enterprise_project_id 否 Array 企业项目ID state 否 Array 企业路由器实例状态:pending|available|modifying|deleting|deleted|failed|freezed id 否 Array 根据资源ID查询,可同时查询多个。 resource_id 否 Array 连接对应的资源ID列表 owned_by_self 否 Boolean 过滤资源是否属于当前租户;取值为true时,只查属于当前租户的资源,不包括共享资源;为false时,查询当前租户及共享给该租户的资源; sort_key 否 Array 按关键字排序,默认按照id排序,可选值:id|name|state sort_dir 否 Array 返回结果按照升序或降序排列,默认为asc,降序为desc
  • 响应参数 状态码: 200 表3 响应Body参数 参数 参数类型 描述 instances Array of EnterpriseRouter objects 企业路由器列表 page_info PageInfo object 分页查询的信息 request_id String 请求ID 表4 EnterpriseRouter 参数 参数类型 描述 id String 企业路由器实例的ID name String 企业路由器实例名称 description String 企业路由器实例描述信息 state String 运行状态:pending|available|modifying|deleting|deleted|failed tags Array of Tag objects 标签信息 charge_mode String 计费模式 按需 缺省值:postPaid created_at String 创建时间,格式:YYYY-MM-DDTHH:mm:ss.sssZ updated_at String 更新时间,格式:YYYY-MM-DDTHH:mm:ss.sssZ enterprise_project_id String 企业项目ID project_id String 项目ID asn Long 企业路由器实例的BGP AS号 enable_default_propagation Boolean 是否开启默认路由表传播,默认false不开启 enable_default_association Boolean 是否开启默认路由表关联,默认false不开启 default_propagation_route_table_id String 默认传播路由表id default_association_route_table_id String 默认关联路由表id availability_zone_ids Array of strings 企业路由器所在可用区信息 auto_accept_shared_attachments Boolean 是否自动接受共享连接创建,默认false不开启 表5 Tag 参数 参数类型 描述 key String 标签键,规则: 1.可用 UTF-8 格式表示的字母(包含中文)、数字和空格,以及字符:下划线“_”,点“.”,冒号“:”,等号“=”,加号“+”,中划线“-”,“@”。 2._sys_开头属于系统标签,租户不能输入。 3.标签key不能为空(长度不能为0)。 4.长度在1-128之间。 最小长度:1 最大长度:128 value String 标签值,规则: 1.可用 UTF-8 格式表示的字母(包含中文)、数字和空格,以及字符:下划线“_”,点“.”,冒号“:”,等号“=”,加号“+”,中划线“-”,“@”。 2.资源标签值可以为空(empty or null)。 3.长度在0-255之间。 最小长度:0 最大长度:255 表6 PageInfo 参数 参数类型 描述 next_marker String 下一个marker标识,为空时表示最后一页 current_count Integer 当前列表中资源数量
  • 请求示例 分页查询2两条记录 GET https://{erouter_endpoint}/v3/08d5a9564a704afda6039ae2babbef3c/enterprise-router/instances?limit=2&marker=1 全量查询 GET https://{erouter_endpoint}/v3/08d5a9564a704afda6039ae2babbef3c/enterprise-router/instances
  • 响应参数 状态码: 200 表3 响应Body参数 参数 参数类型 描述 attachments Array of AttachmentDetails objects 连接列表 page_info PageInfo object 分页查询的信息 request_id String 请求ID 表4 AttachmentDetails 参数 参数类型 描述 id String 连接ID name String 连接名字 description String 描述信息 state String 连接状态:pending|available|modifying|deleting|deleted|failed|pending_acceptance|rejected|initiating_request|freezed created_at String 创建时间,格式:YYYY-MM-DDTHH:mm:ss.sssZ updated_at String 更新时间,格式:YYYY-MM-DDTHH:mm:ss.sssZ tags Array of Tag objects 企业路由器关联tag project_id String 项目ID er_id String er id resource_id String 内部连接关联的资源ID resource_type String 内部连接关联的资源类型: vgw:云专线的虚拟网关 vpn:vpn网关 peering:对等连接,通过云连接CC加载不同区域的企业路由器来创建“对等连接(Peering)”连接 vpc:虚拟私有云 resource_project_id String 资源所属项目ID associated Boolean 表示此连接是否被关联 route_table_id String 关联路由表id 表5 Tag 参数 参数类型 描述 key String 标签键,规则: 1.可用 UTF-8 格式表示的字母(包含中文)、数字和空格,以及字符:下划线“_”,点“.”,冒号“:”,等号“=”,加号“+”,中划线“-”,“@”。 2._sys_开头属于系统标签,租户不能输入。 3.标签key不能为空(长度不能为0)。 4.长度在1-128之间。 最小长度:1 最大长度:128 value String 标签值,规则: 1.可用 UTF-8 格式表示的字母(包含中文)、数字和空格,以及字符:下划线“_”,点“.”,冒号“:”,等号“=”,加号“+”,中划线“-”,“@”。 2.资源标签值可以为空(empty or null)。 3.长度在0-255之间。 最小长度:0 最大长度:255 表6 PageInfo 参数 参数类型 描述 next_marker String 下一个marker标识,为空时表示最后一页 current_count Integer 当前列表中资源数量
  • 响应示例 状态码: 200 OK { "attachments" : [ { "id" : "6f83b848-8331-4271-ac0c-ef94b7686402", "name" : "vpc-001", "description" : "vpc attachment", "resource_id" : "b715e131-3371-4e17-a2de-4f669e24439a", "resource_type" : "vpc", "project_id" : "0605767a9980d5762fbcc00b3537e757", "state" : "available", "created_at" : "2020-03-11T15:13:31Z", "updated_at" : "2020-03-11T15:13:31Z" }, { "id" : "6f83b848-8331-4271-ac0c-ef94b7686403", "name" : "vpc-002", "description" : "for test", "resource_id" : "4b8567f6-358f-4a7f-8cd3-3cbb82c0b25f", "resource_type" : "vpc", "project_id" : "0605767a9980d5762fbcc00b3537e757", "state" : "available", "created_at" : "2020-03-11T15:13:31Z", "updated_at" : "2020-03-11T15:13:31Z" } ], "page_info" : { "next_marker" : "1", "current_count" : 2 }, "request_id" : "b715e131-3371-4e17-a2de-4f669e24439a" }
  • URI GET /v3/{project_id}/enterprise-router/{er_id}/attachments 表1 路径参数 参数 是否必选 参数类型 描述 project_id 是 String 项目ID er_id 是 String 企业路由器实例ID 表2 Query参数 参数 是否必选 参数类型 描述 limit 否 Integer 每页返回的个数。 取值范围:0~2000。 最小值:0 最大值:2000 marker 否 String 查询的页码id,为空时为查询第一页。 使用说明:必须与limit一起使用。 最小长度:1 最大长度:128 state 否 Array 连接状态:pending|available|modifying|deleting|deleted|failed|pending_acceptance|rejected|initiating_request resource_type 否 Array vpc:虚拟私有云 vpn:vpn网关 vgw:云专线的虚拟网关 peering:对等连接,通过云连接CC加载不同区域的企业路由器来创建“对等连接(Peering)”连接 resource_id 否 Array 连接对应的资源ID列表 sort_key 否 Array 按关键字排序,默认按照id排序,可选值:id|name|state sort_dir 否 Array 返回结果按照升序或降序排列,默认为asc,降序为desc
  • 响应示例 状态码: 200 OK { "vpc_attachments" : [ { "id" : "6f83b848-8331-4271-ac0c-ef94b7686402", "name" : "vpc-attach-01", "vpc_id" : "b715e131-3371-4e17-a2de-4f669e24439a", "virsubnet_id" : "aacdc21d-90f9-45ef-ab48-80ec1bbe15b8", "project_id" : "08d5a9564a704afda6039ae2babbef3c", "state" : "available", "created_at" : "2020-03-11T15:13:31Z", "updated_at" : "2020-03-11T15:13:31Z" }, { "id" : "6f83b848-8331-4271-ac0c-ef94b7686402", "name" : "vpc-attach-01", "vpc_id" : "4b8567f6-358f-4a7f-8cd3-3cbb82c0b25f", "virsubnet_id" : "2b55f334-a15e-43a9-ab11-b34c2dbb6fac", "project_id" : "08d5a9564a704afda6039ae2babbef3c", "state" : "available", "created_at" : "2020-03-11T15:13:31Z", "updated_at" : "2020-03-11T15:13:31Z" } ], "page_info" : { "next_marker" : "1", "current_count" : 2 }, "request_id" : "915a14a6-867b-4af7-83d1-70efceb146f9" }
  • 响应参数 状态码: 200 表3 响应Body参数 参数 参数类型 描述 vpc_attachments Array of VpcAttachmentDetails objects VPC连接列表 page_info PageInfo object 分页查询的信息 request_id String 请求ID 表4 VpcAttachmentDetails 参数 参数类型 描述 id String VPC连接ID name String VPC连接名称 vpc_id String VPC id virsubnet_id String VPC子网id auto_create_vpc_routes Boolean 默认为false,当设置true时,会自动为VPC配置10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16三条路由,下一跳指向企业路由器。 缺省值:false state String VPC连接状态:pending|available|modifying|deleting|deleted|failed|initiating_request|rejected|pending_acceptance|freezed created_at String 创建时间,格式:YYYY-MM-DDTHH:mm:ss.sssZ updated_at String 更新时间,格式:YYYY-MM-DDTHH:mm:ss.sssZ tags Array of Tag objects 标签信息 description String VPC连接描述信息 project_id String 项目ID vpc_project_id String vpc所属项目ID 表5 Tag 参数 参数类型 描述 key String 标签键,规则: 1.可用 UTF-8 格式表示的字母(包含中文)、数字和空格,以及字符:下划线“_”,点“.”,冒号“:”,等号“=”,加号“+”,中划线“-”,“@”。 2._sys_开头属于系统标签,租户不能输入。 3.标签key不能为空(长度不能为0)。 4.长度在1-128之间。 最小长度:1 最大长度:128 value String 标签值,规则: 1.可用 UTF-8 格式表示的字母(包含中文)、数字和空格,以及字符:下划线“_”,点“.”,冒号“:”,等号“=”,加号“+”,中划线“-”,“@”。 2.资源标签值可以为空(empty or null)。 3.长度在0-255之间。 最小长度:0 最大长度:255 表6 PageInfo 参数 参数类型 描述 next_marker String 下一个marker标识,为空时表示最后一页 current_count Integer 当前列表中资源数量
  • 请求示例 分页查询VPC连接信息 GET https://{erouter_endpoint}/v3/08d5a9564a704afda6039ae2babbef3c/enterprise-router/vpc-attachments?limit=10 查询全量VPC连接信息 GET https://{erouter_endpoint}/v3/08d5a9564a704afda6039ae2babbef3c/enterprise-router/vpc-attachments
  • URI GET /v3/{project_id}/enterprise-router/{er_id}/vpc-attachments 表1 路径参数 参数 是否必选 参数类型 描述 project_id 是 String 项目ID er_id 是 String 企业路由器实例ID 表2 Query参数 参数 是否必选 参数类型 描述 limit 否 Integer 每页返回的个数。 取值范围:0~2000。 最小值:0 最大值:2000 marker 否 String 查询的页码id,为空时为查询第一页。 使用说明:必须与limit一起使用。 最小长度:1 最大长度:128 state 否 Array 连接状态:pending|available|modifying|deleting|deleted|failed|pending_acceptance|rejected|initiating_request id 否 Array 根据资源ID查询,可同时查询多个。 sort_key 否 Array 按关键字排序,默认按照id排序,可选值:id|name|state sort_dir 否 Array 返回结果按照升序或降序排列,默认为asc,降序为desc vpc_id 否 Array VPC id
  • Python 更新企业路由器,开启默认路由表关联和默认路由表传播功能,并指定对应的路由表 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 # coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdker.v3.region.er_region import ErRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdker.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 = ErClient.new_builder() \ .with_credentials(credentials) \ .with_region(ErRegion.value_of("cn-north-4")) \ .build() try: request = UpdateEnterpriseRouterRequest() instancebody = UpdateEnterpriseRouter( enable_default_propagation=True, enable_default_association=True, default_propagation_route_table_id="94c2b814-99dc-939a-e811-ae84c61ea3ff", default_association_route_table_id="94c2b814-99dc-939a-e811-ae84c61ea3ff" ) request.body = UpdateEnterpriseRouterRequestBody( instance=instancebody ) response = client.update_enterprise_router(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 更新企业路由器,开启默认路由表关联和默认路由表传播功能,并指定对应的路由表 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" er "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/er/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/er/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/er/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 := er.NewErClient( er.ErClientBuilder(). WithRegion(region.ValueOf("cn-north-4")). WithCredential(auth). Build()) request := &model.UpdateEnterpriseRouterRequest{} enableDefaultPropagationInstance:= true enableDefaultAssociationInstance:= true defaultPropagationRouteTableIdInstance:= "94c2b814-99dc-939a-e811-ae84c61ea3ff" defaultAssociationRouteTableIdInstance:= "94c2b814-99dc-939a-e811-ae84c61ea3ff" instancebody := &model.UpdateEnterpriseRouter{ EnableDefaultPropagation: &enableDefaultPropagationInstance, EnableDefaultAssociation: &enableDefaultAssociationInstance, DefaultPropagationRouteTableId: &defaultPropagationRouteTableIdInstance, DefaultAssociationRouteTableId: &defaultAssociationRouteTableIdInstance, } request.Body = &model.UpdateEnterpriseRouterRequestBody{ Instance: instancebody, } response, err := client.UpdateEnterpriseRouter(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • Java 更新企业路由器,开启默认路由表关联和默认路由表传播功能,并指定对应的路由表 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 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.er.v3.region.ErRegion; import com.huaweicloud.sdk.er.v3.*; import com.huaweicloud.sdk.er.v3.model.*; public class UpdateEnterpriseRouterSolution { 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); ErClient client = ErClient.newBuilder() .withCredential(auth) .withRegion(ErRegion.valueOf("cn-north-4")) .build(); UpdateEnterpriseRouterRequest request = new UpdateEnterpriseRouterRequest(); UpdateEnterpriseRouterRequestBody body = new UpdateEnterpriseRouterRequestBody(); UpdateEnterpriseRouter instancebody = new UpdateEnterpriseRouter(); instancebody.withEnableDefaultPropagation(true) .withEnableDefaultAssociation(true) .withDefaultPropagationRouteTableId("94c2b814-99dc-939a-e811-ae84c61ea3ff") .withDefaultAssociationRouteTableId("94c2b814-99dc-939a-e811-ae84c61ea3ff"); body.withInstance(instancebody); request.withBody(body); try { UpdateEnterpriseRouterResponse response = client.updateEnterpriseRouter(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()); } } }
  • 响应参数 状态码: 200 表4 响应Body参数 参数 参数类型 描述 instance EnterpriseRouter object 企业路由器 request_id String 请求ID 表5 EnterpriseRouter 参数 参数类型 描述 id String 企业路由器实例的ID name String 企业路由器实例名称 description String 企业路由器实例描述信息 state String 运行状态:pending|available|modifying|deleting|deleted|failed tags Array of Tag objects 标签信息 charge_mode String 计费模式 按需 缺省值:postPaid created_at String 创建时间,格式:YYYY-MM-DDTHH:mm:ss.sssZ updated_at String 更新时间,格式:YYYY-MM-DDTHH:mm:ss.sssZ enterprise_project_id String 企业项目ID project_id String 项目ID asn Long 企业路由器实例的BGP AS号 enable_default_propagation Boolean 是否开启默认路由表传播,默认false不开启 enable_default_association Boolean 是否开启默认路由表关联,默认false不开启 default_propagation_route_table_id String 默认传播路由表id default_association_route_table_id String 默认关联路由表id availability_zone_ids Array of strings 企业路由器所在可用区信息 auto_accept_shared_attachments Boolean 是否自动接受共享连接创建,默认false不开启 表6 Tag 参数 参数类型 描述 key String 标签键,规则: 1.可用 UTF-8 格式表示的字母(包含中文)、数字和空格,以及字符:下划线“_”,点“.”,冒号“:”,等号“=”,加号“+”,中划线“-”,“@”。 2._sys_开头属于系统标签,租户不能输入。 3.标签key不能为空(长度不能为0)。 4.长度在1-128之间。 最小长度:1 最大长度:128 value String 标签值,规则: 1.可用 UTF-8 格式表示的字母(包含中文)、数字和空格,以及字符:下划线“_”,点“.”,冒号“:”,等号“=”,加号“+”,中划线“-”,“@”。 2.资源标签值可以为空(empty or null)。 3.长度在0-255之间。 最小长度:0 最大长度:255
  • 响应示例 状态码: 200 OK { "instance" : { "id" : "94c2b814-99dc-939a-e811-ae84c61ea3ff", "name" : "my_er", "description" : "this is my first enterprise router", "project_id" : "08d5a9564a704afda6039ae2babbef3c", "state" : "pending", "asn" : 64512, "enable_default_association" : true, "enable_default_propagation" : true, "default_propagation_route_table_id" : "94c2b814-99dc-939a-e811-ae84c61ea3ff", "default_association_route_table_id" : "94c2b814-99dc-939a-e811-ae84c61ea3ff", "auto_accept_shared_attachments" : false, "availability_zone_ids" : [ "az1" ], "created_at" : "2019-09-06 02:11:13Z", "updated_at" : "2019-09-06 02:11:13Z" }, "request_id" : "14c2b814-99dc-939b-e81c-ae84c61ea3f7" }
  • 请求示例 更新企业路由器,开启默认路由表关联和默认路由表传播功能,并指定对应的路由表 PUT https://{erouter_endpoint}/v3/08d5a9564a704afda6039ae2babbef3c/enterprise-router/instances/94c2b814-99dc-939a-e811-ae84c61ea3ff { "instance" : { "enable_default_association" : true, "enable_default_propagation" : true, "default_propagation_route_table_id" : "94c2b814-99dc-939a-e811-ae84c61ea3ff", "default_association_route_table_id" : "94c2b814-99dc-939a-e811-ae84c61ea3ff" } }
  • 请求参数 表2 请求Body参数 参数 是否必选 参数类型 描述 instance 否 UpdateEnterpriseRouter object 更新企业路由器请求体 表3 UpdateEnterpriseRouter 参数 是否必选 参数类型 描述 name 否 String 企业路由器实例名称,取值范围:1-64个字符,支持数字、字母、中文、_(下划线)、-(中划线)、.(点) 最小长度:1 最大长度:64 description 否 String 企业路由器实例描述信息 最小长度:0 最大长度:255 enable_default_propagation 否 Boolean 是否开启默认传播 enable_default_association 否 Boolean 是否开启默认关联 default_propagation_route_table_id 否 String 默认传播路由表ID default_association_route_table_id 否 String 默认关联路由表ID auto_accept_shared_attachments 否 Boolean 是否自动接受共享连接创建,默认false不开启
  • Python 在企业路由器的路由表中创建静态路由,该路由不是黑洞路由,目的地址为192.168.0.0/16,下一跳为指定连接 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 # coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdker.v3.region.er_region import ErRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdker.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 = ErClient.new_builder() \ .with_credentials(credentials) \ .with_region(ErRegion.value_of("cn-north-4")) \ .build() try: request = CreateStaticRouteRequest() routebody = CreateRoute( destination="192.168.0.0/16", attachment_id="b70aee08-c671-4cad-9fd5-7381d163bcc8", is_blackhole=False ) request.body = CreateRouteRequestBody( route=routebody ) response = client.create_static_route(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 在企业路由器的路由表中创建静态路由,该路由不是黑洞路由,目的地址为192.168.0.0/16,下一跳为指定连接 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 package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" er "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/er/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/er/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/er/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 := er.NewErClient( er.ErClientBuilder(). WithRegion(region.ValueOf("cn-north-4")). WithCredential(auth). Build()) request := &model.CreateStaticRouteRequest{} attachmentIdRoute:= "b70aee08-c671-4cad-9fd5-7381d163bcc8" isBlackholeRoute:= false routebody := &model.CreateRoute{ Destination: "192.168.0.0/16", AttachmentId: &attachmentIdRoute, IsBlackhole: &isBlackholeRoute, } request.Body = &model.CreateRouteRequestBody{ Route: routebody, } response, err := client.CreateStaticRoute(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • 请求示例 在企业路由器的路由表中创建静态路由,该路由不是黑洞路由,目的地址为192.168.0.0/16,下一跳为指定连接 POST https://{erouter_endpoint}/v3/08d5a9564a704afda6039ae2babbef3c/enterprise-router/route-tables/0d1748a0-5188-11e5-b86f-a51b5f125b84/static-routes { "route" : { "destination" : "192.168.0.0/16", "is_blackhole" : false, "attachment_id" : "b70aee08-c671-4cad-9fd5-7381d163bcc8" } }
共100000条