华为云用户手册

  • Token认证 Token的有效期为24小时,需要使用一个Token鉴权时,可以先缓存起来,避免频繁调用。 Token在计算机系统中代表令牌(临时)的意思,拥有Token就代表拥有某种权限。Token认证就是在调用API的时候将Token加到请求消息头中,从而通过身份认证,获得操作API的权限。Token可通过调用获取用户Token接口获取。 调用VPC API需要项目级别的Token,即调用获取用户Token接口时,请求body中auth.scope的取值需要选择project,如下所示。 { "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "name": "username", // IAM 用户名 "password": "********", //IAM用户密码 "domain": { "name": "domainname" //IAM用户所属账号名 } } } }, "scope": { "project": { "name": "xxxxxxxx" //项目名称 } } }} 获取Token 后,再调用其他接口时,您需要在请求消息头中添加“X-Auth-Token”,其值即为Token。例如Token值为“ABCDEFJ....”,则调用接口时将“X-Auth-Token: ABCDEFJ....”加到请求消息头即可,如下所示。 123 POST https://iam.cn-north-1.myhuaweicloud.com/v3/auth/projectsContent-Type: application/jsonX-Auth-Token: ABCDEFJ.... 您还可以通过这个视频教程了解如何使用Token认证:https://bbs.huaweicloud.com/videos/101333。
  • 请求参数 表2 请求Body参数 参数 是否必选 参数类型 描述 dry_run 否 Boolean 功能说明:是否只预检此次请求。 取值范围: true:发送检查请求,不会移除VPC扩展网段。检查项包括是否填写了必需参数、请求格式、业务限制。如果检查不通过,则返回对应错误。如果检查通过,则返回响应码202。 false(默认值):发送正常请求,并直接移除VPC扩展网段。 vpc 是 RemoveExtendCidrOption object 移除VPC扩展网段请求体。 表3 RemoveExtendCidrOption 参数 是否必选 参数类型 描述 extend_cidrs 是 Array of strings 功能说明:移除VPC扩展网段。 取值范围:该VPC已经存在的扩展网段。 约束:移除扩展网段前,请先清理该VPC下对应cidr范围内的subnet。
  • 请求示例 移除id为99d9d709-8478-4b46-9f3f-2206b1023fd3的vpc的扩展网段23.8.0.0/16。 PUT https://{Endpoint}/v3/{project_id}/vpc/vpcs/99d9d709-8478-4b46-9f3f-2206b1023fd3/remove-extend-cidr{ "vpc" : { "extend_cidrs" : [ "23.8.0.0/16" ] }}
  • 响应示例 状态码: 200 PUT操作正常返回,更多状态码请参见状态码。 { "request_id" : "84eb4f775d66dd916db121768ec55626", "vpc" : { "id" : "0552091e-b83a-49dd-88a7-4a5c86fd9ec3", "name" : "vpc1", "description" : "test1", "cidr" : "192.168.0.0/16", "extend_cidrs" : [ ], "enterprise_project_id" : "0", "tags" : [ { "key" : "key", "value" : "value" } ], "cloud_resources" : [ { "resource_type" : "routetable", "resource_count" : 1 } ], "status" : "ACTIVE", "project_id" : "060576782980d5762f9ec014dd2f1148", "created_at" : "2018-03-23T09:26:08", "updated_at" : "2018-08-24T08:49:53" }} 状态码: 202 API V3的指定预检请求正常返回,更多状态码请参见状态码。 { "error_msg" : "Request validation has been passed with dry run...", "error_code" : "SYS.0202", "request_id" : "cfd81aea3f59eac7128dba4b36d516c8"}
  • 安全组规则icmp协议名称对应关系表 icmp type port_range_min port_range_max Any NULL NULL Echo 8 0 Echo reply 0 0 Fragment need DF set 3 4 Host redirect 5 1 Host TOS redirect 5 3 Host unreachable 3 1 Information reply 16 0 Information request 15 0 Net redirect 5 0 Net TOS redirect 5 2 Net unreachable 3 0 Parameter problem 12 0 Port unreachable 3 3 Protocol unreachable 3 2 Reassembly timeout 11 1 Source quench 4 0 Source route failed 3 5 Timestamp reply 14 0 Timestamp request 13 0 TTL exceeded 11 0 父主题: 附录
  • 请求示例 更新id为3d42a0d4-a980-4613-ae76-a2cddecff054的路由表,新增一条ecs类型的路由,修改一条ecs类型的路由,删除一条目的网段为20.20.10.0/24的路由。 PUT https://{Endpoint}/v1/6fbe9263116a4b68818cf1edce16bc4f/routetables/3d42a0d4-a980-4613-ae76-a2cddecff054{ "routetable": { "name": "routertable-789", "description": "abc", "routes": { "add": [ { "type": "ecs", "destination": "10.10.10.0/24", "nexthop": "7c50463d-d36c-4417-aa85-cc11fa10f341", "description": "abc" } ], "mod": [ { "type": "ecs", "destination": "20.10.10.0/24", "nexthop": "7c50463d-d36c-4417-aa85-cc11fa10f341", "description": "abc" } ], "del": [ { "destination": "20.20.10.0/24" } ] } }}
  • 响应示例 { "routetable": { "id": "3d42a0d4-a980-4613-ae76-a2cddecff054", "vpc_id": "ab78be2d-782f-42a5-aa72-35879f6890ff", "description": "abc", "default": false, "routes": [ { "type": "ecs", "destination": "10.10.10.0/24", "nexthop": "7c50463d-d36c-4417-aa85-cc11fa10f341", "description": "abc" } ], "subnets": [ { "id": "8d4ce32f-d68a-4c4c-9f18-c68d8a5c7f2f" } ], "tenant_id": "6fbe9263116a4b68818cf1edce16bc4f", "created_at": "2022-12-15T02:56:40", "updated_at": "2022-12-15T03:03:42" }}
  • 请求示例 添加扩展网段,vpc id为99d9d709-8478-4b46-9f3f-2206b1023fd3,添加的扩展网段为23.8.0.0/16。 PUT https://{Endpoint}/v3/{project_id}/vpc/vpcs/99d9d709-8478-4b46-9f3f-2206b1023fd3/add-extend-cidr{ "vpc" : { "extend_cidrs" : [ "23.8.0.0/16" ] }}
  • 请求参数 表2 请求Body参数 参数 是否必选 参数类型 描述 dry_run 否 Boolean 功能说明:是否只预检此次请求。 取值范围: true:发送检查请求,不会添加扩展网段。检查项包括是否填写了必需参数、请求格式、业务限制。如果检查不通过,则返回对应错误。如果检查通过,则返回响应码202。 false(默认值):发送正常请求,并直接添加VPC扩展网段。 vpc 是 AddExtendCidrOption object 添加VPC扩展网段请求体。 表3 AddExtendCidrOption 参数 是否必选 参数类型 描述 extend_cidrs 是 Array of strings 功能说明:扩展cidr列表。 取值范围:不能包含以下网段 100.64.0.0/10 214.0.0.0/7 198.18.0.0/15 169.254.0.0/16 0.0.0.0/8 127.0.0.0/8 240.0.0.0/4 172.31.0.0/16 192.168.0.0/16 255.255.255.255/32
  • 响应示例 状态码: 200 PUT操作正常返回,更多状态码请参见状态码。 { "request_id" : "84eb4f775d66dd916db121768ec55626", "vpc" : { "id" : "0552091e-b83a-49dd-88a7-4a5c86fd9ec3", "name" : "vpc1", "description" : "test1", "cidr" : "192.168.0.0/16", "extend_cidrs" : [ "23.8.0.0/16" ], "enterprise_project_id" : "0", "tags" : [ { "key" : "key", "value" : "value" } ], "cloud_resources" : [ { "resource_type" : "routetable", "resource_count" : 1 } ], "status" : "ACTIVE", "project_id" : "060576782980d5762f9ec014dd2f1148", "created_at" : "2018-03-23T09:26:08", "updated_at" : "2018-08-24T08:49:53" }} 状态码: 202 API V3的指定预检请求正常返回,更多状态码请参见状态码。 { "error_msg" : "Request validation has been passed with dry run...", "error_code" : "SYS.0202", "request_id" : "cfd81aea3f59eac7128dba4b36d516c8"}
  • 响应示例 { "routetable": { "id": "3d42a0d4-a980-4613-ae76-a2cddecff054", "vpc_id": "ab78be2d-782f-42a5-aa72-35879f6890ff", "description": "abc", "routes": [ { "type": "ecs", "destination": "10.10.10.0/24", "nexthop": "7c50463d-d36c-4417-aa85-cc11fa10f341", "description": "abc" } ], "subnets": [ { "id": "8d4ce32f-d68a-4c4c-9f18-c68d8a5c7f2f" } ], "tenant_id": "6fbe9263116a4b68818cf1edce16bc4f", "created_at": "2022-12-15T02:56:40", "updated_at": "2022-12-15T02:56:40" }}
  • 请求示例 创建一个路由表,所在vpc id为60c809cb-6731-45d0-ace8-3bf5626421a9,命名为routetable-1234,包含一条ecs类型的路由。 POST https://{Endpoint}/v1/6fbe9263116a4b68818cf1edce16bc4f/routetables{ "routetable": { "name": "routetable-1234", "vpc_id": "60c809cb-6731-45d0-ace8-3bf5626421a9", "routes":[ { "type": "ecs", "destination": "10.10.10.0/24", "nexthop":"7c50463d-d36c-4417-aa85-cc11fa10f341" } ], "description":"abc" } }
  • 请求示例 创建地址组,命名为AutoTester746010.580123789,指定ip类型为IPv4,地址集包含:192.168.3.2、192.168.3.40、192.168.3.20-192.168.3.100、192.168.5.0/24。 POST https://{{endpoint}}/v3/b2782e6708b8475c993e6064bc456bf8/vpc/address-groups{ "address_group" : { "ip_version" : 4, "name" : "AutoTester746010.580123789", "ip_set" : [ "192.168.3.2", "192.168.3.40", "192.168.3.20-192.168.3.100", "192.168.5.0/24" ], "description" : "test", "enterprise_project_id" : "0aad99bc-f5f6-4f78-8404-c598d76b0ed2", "max_capacity" : 20 }}
  • 响应示例 状态码: 201 POST操作正常返回,更多状态码请参见状态码。 { "address_group" : { "id" : "dd18a501-fcd5-4adc-acfe-b0e2384baf08", "name" : "AutoTester746010.580123789", "tenant_id" : "b2782e6708b8475c993e6064bc456bf8", "ip_version" : 4, "max_capacity" : 20, "ip_set" : [ "192.168.5.0/24", "192.168.3.20-192.168.3.100", "192.168.3.40", "192.168.3.2" ], "ip_extra_set" : [ { "ip" : "192.168.5.0/24", "remarks" : null }, { "ip" : "192.168.3.20-192.168.3.100", "remarks" : null }, { "ip" : "192.168.3.40", "remarks" : null }, { "ip" : "192.168.3.2", "remarks" : null } ], "enterprise_project_id" : "0aad99bc-f5f6-4f78-8404-c598d76b0ed2", "created_at" : "2019-06-28T02:06:38.000+00:00", "updated_at" : "2019-06-28T02:06:38.000+00:00", "description" : "test", "status" : "NORMAL", "status_message" : "" }, "request_id" : "f568db7a-2675-4271-8747-3e3f1c6381ba"}
  • 响应示例 { "tags": [ { "key": "key1", "values": [ "value1", "value2" ] }, { "key": "key2", "values": [ "value1", "value2" ] } ]}
  • 响应参数 表2 响应参数 参数名称 类型 说明 tags Array of tag objects tag对象列表,请参见表3。 表3 tag字段数据结构说明 名称 参数类型 说明 key String 键。 不能为空。 长度不超过128个字符(当前控制台操作key长度不超过36个字符)。 由英文字母、数字、下划线、中划线、中文字符组成。 values Array of strings 值列表。 长度不超过255个字符(当前控制台操作value长度不超过43个字符)。 由英文字母、数字、下划线、点、中划线、中文字符组成。
  • URI GET /v2.0/fwaas/firewall_rules 样例: GET https://{Endpoint}/v2.0/fwaas/firewall_rules?name={firewall_rule_name}&tenant_id={tenant_id}&public={is_public}&protocol={protocol}&ip_version={ip_version}&action={action}&enabled={is_enabled} 分页查询样例: GET https://{Endpoint}/v2.0/fwaas/firewall_rules?limit=2&marker=2a193015-4a88-4aa1-84ad-d4955adae707&page_reverse=False 参数说明请参见表1。 表1 参数说明 名称 是否必选 参数类型 说明 id 否 String 按照网络ACL规则对应的ID过滤查询 name 否 String 按照网络ACL规则的名称过滤查询 description 否 String 按照网络ACL规则的描述过滤查询 ip_version 否 Integer 按照网络ACL规则的IP协议版本过滤查询 取值范围:4,6 action 否 String 按照网络ACL规则的行为过滤查询 取值范围:allow or deny enabled 否 Boolean 按照网络ACL规则是否使能过滤查询 取值范围:true or false tenant_id 否 String 按照网络ACL规则所属的项目ID过滤查询 marker 否 String 分页查询的起始资源ID,表示从指定资源的下一条记录开始查询。 marker需要和limit配合使用: 若不传入marker和limit参数,查询结果返回第一页全部资源记录。 若不传入marker参数,limit为10,查询结果返回第1~10条资源记录。 若marker为第10条记录的资源ID,limit为10,查询结果返回第11~20条资源记录。 若marker为第10条记录的资源ID,不传入limit参数,查询结果返回第11~2000条(limit默认值2000)资源记录。 limit 否 Integer 分页查询每页返回的记录个数,取值范围为0~intmax(2^31-1),默认值2000。 limit需要和marker配合使用,详细规则请见marker的参数说明。
  • 响应参数 表2 响应参数 参数名称 类型 说明 firewall_rules Array of Firewall Rule objects firewall rule对象列表,参见表4。单次查询最多返回2000条数据,超过2000后会返回分页标记。 firewall_rules_links Array of firewall_rules_link Object 分页信息,参见表3 。 只有在使用limit过滤,并且资源个数超过limit或者资源个数超过2000时(limit默认值),该参数的rel和href取值才会显示为next和其对应的link。 表3 firewall_rules_link对象 参数名称 类型 说明 href String API链接 rel String API链接与该API版本的关系 表4 Firewall Rule对象 属性 类型 说明 id String 网络ACL规则的uuid标识。 name String 网络ACL规则名称。 description String 网络ACL规则描述。 tenant_id String 项目ID public Boolean 是否支持跨租户共享。 protocol String IP协议。 source_port String 源端口号或者一段端口范围。 destination_port String 目的端口号或者一段端口范围。 ip_version Integer IP协议版本。 source_ip_address String 源地址或者CIDR。 destination_ip_address String 目的地址或者CIDR。 action String 对通过网络ACL的流量执行的操作。 enabled Boolean 是否使能网络ACL规则。 project_id String 项目ID,请参见获取项目ID。
  • 响应示例 { "firewall_rules": [ { "protocol": "tcp", "description": "update check parameter", "source_ip_address": "116.66.184.0/24", "destination_ip_address": "0.0.0.0/0", "destination_port": null, "source_port": null, "id": "2a193015-4a88-4aa1-84ad-d4955adae707", "name": "crhfwruleupdate", "tenant_id": "a1c6f90c94334bd2953d9a61b8031a68", "project_id": "a1c6f90c94334bd2953d9a61b8031a68", "enabled": true, "action": "allow", "ip_version": 4, "public": false }, { "protocol": "tcp", "description": "update check parameter", "source_ip_address": null, "destination_ip_address": null, "destination_port": "40:60", "source_port": "20:50", "id": "db7a204c-9eb1-40a2-9bd6-ed5cfd3cff32", "name": "update_firewall-role-tommy", "tenant_id": "a1c6f90c94334bd2953d9a61b8031a68", "project_id": "a1c6f90c94334bd2953d9a61b8031a68", "enabled": false, "action": "deny", "ip_version": 4, "public": false } ], "firewall_rules_links": [ { "rel": "previous", "href": "https://{Endpoint}/v2.0/fwaas/firewall_rules?marker=2a193015-4a88-4aa1-84ad-d4955adae707&page_reverse=True" } ]}
  • 响应示例 状态码: 200 GET操作正常返回,更多状态码请参见状态码。 { "security_group" : { "id" : "69c999ad-d9ef-4d79-94fd-35e6ceb75325", "name" : "security_group_1", "project_id" : "060576782980d5762f9ec014dd2f1148", "description" : "security group description", "enterprise_project_id" : 0, "tags" : [ { "key" : "a", "value" : "b" } ], "security_group_rules" : [ { "id" : "f11a3824-ac19-4fad-b4f1-c5f4a6dd0a80", "project_id" : "060576782980d5762f9ec014dd2f1148", "security_group_id" : "69c999ad-d9ef-4d79-94fd-35e6ceb75325", "remote_group_id" : "69c999ad-d9ef-4d79-94fd-35e6ceb75325", "direction" : "ingress", "description" : "", "created_at" : "2020-07-09T05:56:27.000+00:00", "updated_at" : "2020-07-09T05:56:27.000+00:00", "ethertype" : "IPv6", "action" : "allow", "priority" : 100, "protocol" : null, "multiport" : null, "remote_ip_prefix" : null, "remote_address_group_id" : null, "enabled" : true }, { "id" : "3d6480e8-9ea4-46dc-bb1b-8db190cd5677", "project_id" : "060576782980d5762f9ec014dd2f1148", "security_group_id" : "69c999ad-d9ef-4d79-94fd-35e6ceb75325", "direction" : "egress", "description" : "", "created_at" : "2020-07-09T05:56:27.000+00:00", "updated_at" : "2020-07-09T05:56:27.000+00:00", "ethertype" : "IPv6", "action" : "allow", "priority" : 100, "protocol" : null, "multiport" : null, "remote_ip_prefix" : null, "remote_group_id" : null, "remote_address_group_id" : null, "enabled" : true }, { "id" : "9581f18c-1fdd-43da-ace9-7758a56ef28a", "project_id" : "060576782980d5762f9ec014dd2f1148", "security_group_id" : "69c999ad-d9ef-4d79-94fd-35e6ceb75325", "direction" : "egress", "description" : "", "created_at" : "2020-07-09T05:56:27.000+00:00", "updated_at" : "2020-07-09T05:56:27.000+00:00", "ethertype" : "IPv4", "action" : "allow", "priority" : 100, "protocol" : null, "multiport" : null, "remote_ip_prefix" : null, "remote_group_id" : null, "remote_address_group_id" : null, "enabled" : true }, { "id" : "a3ba270e-e58b-432d-a912-aeb7eace9fb8", "project_id" : "060576782980d5762f9ec014dd2f1148", "security_group_id" : "69c999ad-d9ef-4d79-94fd-35e6ceb75325", "remote_group_id" : "69c999ad-d9ef-4d79-94fd-35e6ceb75325", "direction" : "ingress", "description" : "", "created_at" : "2020-07-09T05:56:27.000+00:00", "updated_at" : "2020-07-09T05:56:27.000+00:00", "ethertype" : "IPv4", "action" : "allow", "priority" : 100, "protocol" : null, "multiport" : null, "remote_ip_prefix" : null, "remote_address_group_id" : null, "enabled" : true } ], "created_at" : "2020-07-09T05:56:27.000+00:00", "updated_at" : "2020-07-09T05:56:27.000+00:00" }, "request_id" : "a8cf4f79ca3c22ca685e7e8872e8c20b"}
  • 请求示例 批量创建两条子网资源标签,action为create。 POST https://{Endpoint}/v2.0/{project_id}/subnets/{subnet_id}/tags/action{ "action": "create", "tags": [ { "key": "key1", "value": "value1" }, { "key": "key2", "value": "value3" } ]} 批量删除两条子网资源标签,action为delete。 POST https://{Endpoint}/v2.0/{project_id}/subnets/{subnet_id}/tags/action{ "action": "delete", "tags": [ { "key": "key1", "value": "value1" }, { "key": "key2", "value": "value3" } ]}
  • 请求参数 表2 请求参数 参数名称 类型 是否必选 说明 tags Array of tag objects 是 tag对象列表,请参见表3。 action String 是 操作标识: create:创建 delete:删除 表3 tag对象 属性 类型 是否必选 说明 key String 是 标签名称。 不能为空。 长度不超过128个字符(当前控制台操作key长度不超过36个字符)。 由英文字母、数字、下划线、中划线、中文字符组成。 同一资源的key值不能重复。 value String 是 标签值。 长度不超过255个字符(当前控制台操作value长度不超过43个字符)。 由英文字母、数字、下划线、点、中划线、中文字符组成。
  • 请求示例 更新id为dd18a501-fcd5-4adc-acfe-b0e2384baf08的地址组,更新名称为vkvgykvsvhjaaaa1、ip地址集和描述。 PUT https://{endpoint}/v3/b2782e6708b8475c993e6064bc456bf8/vpc/address-groups/dd18a501-fcd5-4adc-acfe-b0e2384baf08{ "address_group" : { "name" : "vkvgykvsvhjaaaa1", "ip_set" : [ "192.168.3.2", "192.168.3.43", "192.168.3.20-192.168.3.100", "192.168.5.0/24" ], "description" : "xxxxxxxxxx" }}
  • 响应示例 状态码: 200 PUT操作正常返回,更多状态码请参见状态码。 { "address_group" : { "id" : "dd18a501-fcd5-4adc-acfe-b0e2384baf08", "name" : "vkvgykvsvhjaaaa1", "tenant_id" : "b2782e6708b8475c993e6064bc456bf8", "ip_version" : 4, "max_capacity" : 20, "ip_set" : [ "192.168.5.0/24", "192.168.3.20-192.168.3.100", "192.168.3.43", "192.168.3.2" ], "ip_extra_set" : [ { "ip" : "192.168.5.0/24", "remarks" : null }, { "ip" : "192.168.3.20-192.168.3.100", "remarks" : null }, { "ip" : "192.168.3.43", "remarks" : null }, { "ip" : "192.168.3.2", "remarks" : null } ], "enterprise_project_id" : "0aad99bc-f5f6-4f78-8404-c598d76b0ed2", "created_at" : "2019-06-28T02:06:38.000+00:00", "updated_at" : "2019-06-28T02:14:01.000+00:00", "description" : "xxxxxxxxxx", "status" : "NORMAL", "status_message" : "" }, "request_id" : "5bbd1640-fa68-4362-9a5c-30c4809958e0"}
  • 操作步骤 创建虚拟IP。 发送“POST https://VPC的Endpoint/v2.0/ports”。 在Request Header中增加“X-Auth-Token”。 在Request Body中传入参数如下,其中vip所在子网需与E CS 同子网。 {"port": {"network_id": "4779ab1c-7c1a-44b1-a02e-93dfc361b32d","device_owner": "neutron:VIP_PORT","name": "vip_port_test"}} 或者如下,可以指定IP创建: {"port": {"network_id": "4779ab1c-7c1a-44b1-a02e-93dfc361b32d","device_owner": "neutron:VIP_PORT","name": "vip_port_test","fixed_ips": [{"ip_address": "192.168.0.220"}]}} 查看请求响应结果。 请求成功时,响应参数如下: {"port": {"id": "a7d98f3c-b42f-460b-96a1-07601e145961","name": "port-test","status": "DOWN","admin_state_up": true,"fixed_ips": [{"subnet_id": "213cb9d-3122-2ac1-1a29-91ffc1231a12","ip_address": "192.168.0.220"}],"mac_address": "fa:16:3e:01:f7:90","network_id": "4779ab1c-7c1a-44b1-a02e-93dfc361b32d","tenant_id": "db82c9e1415a464ea68048baa8acc6b8","project_id": "db82c9e1415a464ea68048baa8acc6b8","device_id": "","device_owner": "neutron:VIP_PORT","security_groups": ["d0d58aa9-cda9-414c-9c52-6c3daf8534e6"],"extra_dhcp_opts": [],"allowed_address_pairs": [],"binding:vnic_type": "normal","binding:vif_details": {},"binding:profile": {},"port_security_enabled": true,"created_at": "2018-09-20T01:45:26","updated_at": "2018-09-20T01:45:26"}} 请求异常时,错误码请参见错误码。 通过云服务器的ID查询网卡信息。 发送“GET https://VPC的Endpoint/v2.0/ports?device_id={ecs_id}&network_id={network_id}” 在Request Header中增加“X-Auth-Token”。 查看请求响应结果。 请求成功时,响应参数如下: {"ports": [{"id": "02c72193-efec-42fb-853b-c33f2b802467","name": "","status": "ACTIVE","admin_state_up": true,"fixed_ips": [{"subnet_id": "213cb9d-3122-2ac1-1a29-91ffc1231a12","ip_address": "192.168.0.75"}],"mac_address": "fa:16:3e:47:5f:c1","network_id": "4779ab1c-7c1a-44b1-a02e-93dfc361b32d","tenant_id": "db82c9e1415a464ea68048baa8acc6b8","project_id": "db82c9e1415a464ea68048baa8acc6b8","device_id": "ea61f836-b52f-41bf-9d06-685644001d6f","device_owner": "compute:br-iaas-odin1a","security_groups": ["e0598d96-9451-4f8a-8de0-b8b4d451d9e7"],"extra_dhcp_opts": [],"allowed_address_pairs": [],"binding:vnic_type": "normal","binding:vif_details": {"primary_interface": true},"binding:profile": {},"port_security_enabled": true,"created_at": "2020-06-20T08:07:29","updated_at": "2020-06-20T08:07:29"}]} 请求异常时,错误码请参见错误码。 将云服务器与虚拟IP绑定。 发送“PUT https://VPC的Endpoint/v2.0/ports/{port_id}”。port_id为上面创建的虚拟IP对应的port_id。 在Request Header中增加“X-Auth-Token”。 在Request Body中传入参数如下,ip_address为2查询出的云服务器的网卡ip。 {"port": {"allowed_address_pairs": [{"ip_address": "192.168.0.75"}]}} 查看请求响应结果。 请求成功时,响应参数如下: {"port": {"id": "a7d98f3c-b42f-460b-96a1-07601e145961","name": "port-test","status": "DOWN","admin_state_up": true,"fixed_ips": [{"subnet_id": "213cb9d-3122-2ac1-1a29-91ffc1231a12","ip_address": "192.168.0.220"}],"mac_address": "fa:16:3e:01:f7:90","network_id": "4779ab1c-7c1a-44b1-a02e-93dfc361b32d","tenant_id": "db82c9e1415a464ea68048baa8acc6b8","project_id": "db82c9e1415a464ea68048baa8acc6b8","device_id": "","device_owner": "neutron:VIP_PORT","security_groups": ["d0d58aa9-cda9-414c-9c52-6c3daf8534e6"],"extra_dhcp_opts": [],"allowed_address_pairs": [{"ip_address": "192.168.0.75"}]"binding:vnic_type": "normal","binding:vif_details": {},"binding:profile": {},"port_security_enabled": true,"created_at": "2018-09-20T01:45:26","updated_at": "2018-09-20T01:45:26"}} 请求异常时,错误码请参见错误码。 关闭云服务器网卡的源/目的检查。 发送“PUT https://VPC的Endpoint/v2.0/ports/{port_id}”。port_id为2查询到的网卡ID。 在Request Header中增加“X-Auth-Token”。 在Request Body中传入参数如下:ip_address为1.1.1.1/0查询出的云服务器的网卡ip。 {"port": {"allowed_address_pairs": [{"ip_address": "1.1.1.1/0"}]}} 查看请求响应结果。 请求成功时,响应参数如下: {"port": {"id": "02c72193-efec-42fb-853b-c33f2b802467","name": "","status": "ACTIVE","admin_state_up": true,"fixed_ips": [{"subnet_id": "213cb9d-3122-2ac1-1a29-91ffc1231a12","ip_address": "192.168.0.75"}],"mac_address": "fa:16:3e:47:5f:c1","network_id": "4779ab1c-7c1a-44b1-a02e-93dfc361b32d","tenant_id": "db82c9e1415a464ea68048baa8acc6b8","project_id": "db82c9e1415a464ea68048baa8acc6b8","device_id": "ea61f836-b52f-41bf-9d06-685644001d6f","device_owner": "compute:br-iaas-odin1a","security_groups": ["e0598d96-9451-4f8a-8de0-b8b4d451d9e7"],"extra_dhcp_opts": [],"allowed_address_pairs": [{"ip_address": "1.1.1.1/0"}],"binding:vnic_type": "normal","binding:vif_details": {"primary_interface": true},"binding:profile": {},"port_security_enabled": true,"created_at": "2020-06-20T08:07:29","updated_at": "2020-06-20T08:07:29"}} 请求异常时,错误码请参见错误码。
  • 请求示例 创建一个vpc,命名为vpc,设置cidr为192.168.0.0/16。 POST https://{Endpoint}/v1/{project_id}/vpcs{ "vpc": { "name": "vpc", "description": "test", "cidr": "192.168.0.0/16", "enterprise_project_id": "0aad99bc-f5f6-4f78-8404-c598d76b0ed2" }}
  • 响应示例 { "vpc": { "id": "99d9d709-8478-4b46-9f3f-2206b1023fd3", "name": "vpc", "description": "test", "cidr": "192.168.0.0/16", "status": "CREATING", "enterprise_project_id": "0aad99bc-f5f6-4f78-8404-c598d76b0ed2", "routes": [], "tenant_id": "087679f0aa80d32a2f4ec0172f5e902b", "created_at": "2022-12-15T02:25:11", "updated_at": "2022-12-15T02:25:11" }}
  • 响应示例 { "routetable": { "id": "3d42a0d4-a980-4613-ae76-a2cddecff054", "vpc_id": "ab78be2d-782f-42a5-aa72-35879f6890ff", "description": "abc", "routes": [ { "type": "ecs", "destination": "10.10.10.0/24", "nexthop": "7c50463d-d36c-4417-aa85-cc11fa10f341", "description": "abc" } ], "subnets": [ { "id": "8d4ce32f-d68a-4c4c-9f18-c68d8a5c7f2f" } ], "tenant_id": "6fbe9263116a4b68818cf1edce16bc4f", "created_at": "2022-12-15T02:56:40", "updated_at": "2022-12-15T03:05:10" }}
  • 请求参数 表2 请求参数 名称 是否必选 参数类型 说明 routetable 是 routetable object 路由表对象,参见表3。 表3 routetable字段说明 名称 是否必选 参数类型 说明 subnets 是 subnet object 功能说明:路由表所关联的子网。 约束:只能关联路由表所属vpc下的子网 表4 subnet字段说明 名称 是否必选 参数类型 说明 associate 否 Array of strings 路由表关联子网ID列表 disassociate 否 Array of strings 路由表解除关联子网ID列表
  • 请求示例 关联路由表3d42a0d4-a980-4613-ae76-a2cddecff054和子网1a8b8c98-3976-401b-a735-8b058109268c。 POST https://{Endpoint}/v1/6fbe9263116a4b68818cf1edce16bc4f/routetables/3d42a0d4-a980-4613-ae76-a2cddecff054/action{ "routetable": { "subnets": { "associate": [ "1a8b8c98-3976-401b-a735-8b058109268c" ] } }}
共99354条