创建部署计划
场景描述
本章节指导用户通过API创建部署计划。API的调用方法请参见如何调用API 。
约束限制
创建部署计划前,请预先创建好虚拟私有云,创建安全组并配置安全组规则,如需使用密钥或私有镜像,需预先创建。
涉及接口
创建部署计划时,需要进行规格查询、边缘站点查询、虚拟私有云查询等操作,涉及的接口如下:
操作步骤
- 确定待创建边缘业务的区域。
- 查询边缘站点列表。
- 接口相关信息
详情请参见查询边缘站点列表。
- 请求示例
GET https://{endpoint}/v1/sites
{endpoint}信息请从地区和终端节点获取。
- 响应示例
{ "count": 1, "sites": [ { "id": "4789fe21-3c90-11eb-8801-fa165cf67eaf", "name": "dongguan-cdn-tri-lan", "city": "dongguan", "i18n_city": "东莞市", "province": "guangdong", "i18n_province": "广东", "area": "south", "i18n_area": "华南地区", "country": "china", "i18n_country": "中国", "status": "Normal", "city_short_name": "DG", "pools": [ { "id": "630c665d-3c92-11eb-86c6-fa165eb5c534", "site_id": "4789fe21-3c90-11eb-8801-fa165cf67eaf", "display_name": "东莞移动", "operator": { "id": "3", "name": "chinamobile", "i18n_name": "中国移动", "sa": "CMCC" }, "pool_id": "5_900y_mobile", "ip_version": "4" }, { "id": "613c730a-3c94-11eb-ab1c-fa165c13ae1a", "site_id": "4789fe21-3c90-11eb-8801-fa165cf67eaf", "display_name": "东莞电信", "operator": { "id": "1", "name": "chinatelecom", "i18n_name": "中国电信", "sa": "CTCC" }, "pool_id": "5_900y_telcom", "ip_version": "4" }, { "id": "27d87b7f-3c95-11eb-8801-fa165cf67eaf", "site_id": "4789fe21-3c90-11eb-8801-fa165cf67eaf", "display_name": "东莞联通", "operator": { "id": "2", "name": "chinaunicom", "i18n_name": "中国联通", "sa": "CUCC" }, "pool_id": "5_900y_union", "ip_version": "4" } ] } ] }
- 接口相关信息
- 根据实际需要选择站点、城市、省份或大区信息,并记录相关信息。
- 查询边缘站点列表。
- 确定待创建边缘业务的规格。
- 查询边缘实例规格列表。
- 接口相关信息
URI格式:GET /v1/cloudservers/flavors
详情请参见查询边缘实例规格列表。
- 请求示例
GET https://{endpoint}/v1/cloudservers/flavors
{endpoint}信息请从地区和终端节点获取。
- 响应示例
{ "count": 1, "flavors": [ { "id": "c6.large.2", "name": "c6.large.2", "vcpus": "2", "ram": 4096, "disk": "0", "links": [ { "rel": "self", "href": "https://compute-ext.region.cn-north-900.myhuaweicloud.com/v1.0/08fab6922f8010b82fe6c004b5b26d04/flavors/c6.large.2", "type": "" }, { "rel": "bookmark", "href": "https://compute-ext.region.cn-north-900.myhuaweicloud.com/08fab6922f8010b82fe6c004b5b26d04/flavors/c6.large.2", "type": "" } ], "os_extra_specs": { "ecs:performancetype": "computingv3", "resource_type": "IOoptimizedC6_HV602", "ecs:generation": "c6", "ecs:virtualization_env_types": "CloudCompute", "pci_passthrough:enable_gpu": "", "pci_passthrough:gpu_specs": "", "pci_passthrough:alias": "", "info:cpu:name": "Intel Cascade Lake 3.0GHz", "cond:operation:status": "abandon", "cond:compute": "autorecovery", "cond:image": "__support_kvm=true&__support_kvm_hi1822_hiovs=true", "cond:network": "", "quota:vif_max_num": "2", "quota:physics_max_rate": "44000", "quota:vif_multiqueue_num": "2", "quota:min_rate": "1200", "quota:max_rate": "4000", "quota:max_pps": "400000", "hw:cpu_sockets": "1", "hw:numa_nodes": "1", "hw:cpu_threads": "2", "hw:mem_page_size": "1048576", "quota:conn_limit_total": "2000000", "hw:cpu_cores": "1", "cond:spot_block:operation:az": "", "cond:spot_block:operation:longest_duration_hours": "", "cond:spot_block:operation:longest_duration_count": "", "cond:spot_block:operation:interrupt_policy": "", "cond:spot:operation:az": "", "cond:spot:operation:status": "" }, "swap": "", "OS-FLV-EXT-DATA:ephemeral": 0, "OS-FLV-DISABLED:disabled": false, "rxtx_factor": 1, "rxtx_quota": "", "rxtx_cap": "", "os-flavor-access:is_public": true } ] }
- 接口相关信息
- 根据实际需要选择规格,并记录规格的ID。
- 查询边缘实例规格列表。
- 确定待创建边缘业务的镜像。
- 查询边缘镜像列表。
- 接口相关信息
详情请参见查询边缘镜像列表。
- 请求示例
GET https://{endpoint}/v1/images
{endpoint}信息请从地区和终端节点获取。
- 响应示例
{ "images": [ { "id": "b76b5e98-b30b-11ea-a45e-fa165cec2c7a", "name": "EulerOS 2.2 64bit", "status": "active", "disk_format": "zvhd2", "min_disk": 40, "min_ram": 1024, "owner": "0756fdcb2f00261d0fb6c0049e7e7fa0", "protected": true, "visibility": "public", "created_at": "2020-06-20T15:35:49Z", "updated_at": "2020-06-20T15:37:09Z", "self": "/v1/images/b76b5e98-b30b-11ea-a45e-fa165cec2c7a", "deleted": false, "virtual_env_type": "FusionCompute", "deleted_at": "", "related_job_id": "", "__imagetype": "gold", "__platform": "EulerOS", "__os_type": "Linux", "__os_version": "EulerOS 2.2 64bit", "__isregistered": true, "__support_kvm": "true", "__support_kvm_hi1822_hiovs": "true" } ], "total": 1 }
- 接口相关信息
- 根据需要选择镜像,并记录镜像ID。
- 查询边缘镜像列表。
- 确定边缘业务的网络信息。
- 确定边缘业务的安全组信息。
- 查询安全组列表
- 接口相关信息
详情请参见查询安全组列表。
- 请求示例
GET https://{endpoint}/v1/security-groups
{endpoint}信息请从地区和终端节点获取。
- 响应示例
{ "security_groups": [ { "id": "153133f5-2b16-11eb-a594-fa16408859a1", "name": "stock_sg_changsha568", "description": "cloudtest", "security_group_rules": [ { "id": "1fb600fb-2c76-11eb-80d1-fa16406a65c4", "description": "", "security_group_id": "153133f5-2b16-11eb-a594-fa16408859a1", "direction": "ingress", "ethertype": "IPv4", "protocol": "", "port_range_min": "", "port_range_max": "", "remote_ip_prefix": "0.0.0.0/0", "remote_group_id": "" } ] } ], "count": 1 }
- 接口相关信息
- 查询安全组列表
- 确定边缘业务的密钥信息。
如需设置为密码登录方式,请直接跳转至7。
- 查询密钥列表。
[ { "name": "KeyPair-n1f4", "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDDlsS+/EhexDDej1uoWHrNolqWcfXH4yINpPuoKJPnvBFl+9Uu6sYVUZzRQ8yIOXHsn0iIDPua8i6pMeG3RpNvWWbfdHL6TCM3yfgTo3UN4pEGgI67k78TJ7T6yX+u7R+sxMDt55o75kaDy1j/W/RC30xQ1MiwBdHpHCIDpuj07R4Zhcblh9PHRrIk40+jldRNCpM0eVaUsIVKKP0LUydZeBI9HdsUNFNeDWykEPcWiayQBse6Uj8unwGTOKQX+Zwfhfr9AO3eoZmWHQmep17u0fAWduxImfZIkaIeVlVXEA31GrREy2uehzG5UhQR1xHUVXIdGty1C6n8+KN0M6dr Generated-by-Nova\n", "fingerprint": "SHA256:G2+HAgNyIi2maUvkuLne9BM/93TZ2eGoNKtP8MxPF74", "user_id": "dc36c78ad96f42e394f3221bf7c17166" } ]
- 根据需要选择密钥,并记录密钥名称。
- 查询密钥列表。
- 设置密码登录方式。
- 使用非cloud-init镜像创建部署计划时,Windows和Linux系统都使用“admin_pass”参数实现密码注入。
- 使用cloud-init镜像创建部署计划时:
- 对于Linux系统,只能使用“user_data”进行密码注入,“user_data”字符串长度小于65535,且必须是base64加密的;
- 对于Windows系统,只能通过“admin_pass”进行密码注入。
- 创建密码方式登录鉴权的部署计划。
- 使用非cloud-init镜像创建部署计划(使用admin_pass实现密码注入)。
- 接口相关信息
接口约束及请求参数说明详情,请参见创建部署计划。
- 请求示例
POST https://{endpoint}/v1/deployments
{endpoint}信息请从地区和终端节点获取。
{ "edgecloud": { "stack": { "name": "stack-bm3m", "resources": [ { "name": "res-uoio", "image_ref": "00000000-0000-0000-0000-000000000008", "flavor_ref": "c6.large.2", "net_config": { "vpc_id": "c4b78eca-8ce4-4e7e-8aba-f7da2c7b1816", "nic_num": 1 }, "count": 1, "root_volume": { "volume_type": "SAS", "size": 40 }, "security_groups": [ { "id": "18289138-5b8b-11eb-bcf8-fa16406a65c4" } ], "admin_pass": "NOVAGLANCEI@123" } ] }, "coverage": { "coverage_level": "city", "coverage_policy": "centralize", "coverage_sites": [ { "site": "xi'an", "demands": [ { "demand_count": 1 } ] } ] }, "name": "iec-m83t" } }
- 响应示例
{ "id": "0359ca05-7790-46e8-9a4a-8a8fa118b14f", "locations": [ { "site_id": "74a75ed3-cfb9-11ea-a0c3-fa1640495574", "area": "north", "province": "shaanxi", "city": "xi'an", "operator": "bgp", "pool_id": "5_bgp_edgecloud-site4_1", "stack_count": 1, "city_short_name": "" } ] }
- 接口相关信息
- 使用cloud-init镜像(以Linux为例)创建部署计划(使用user_data进行密码注入)。
- 接口相关信息
接口约束及请求参数说明详情,请参见创建部署计划。
- 请求示例
POST https://{endpoint}/v1/deployments
{endpoint}信息请从地区和终端节点获取。
{ "edgecloud": { "stack": { "name": "stack-bm3m", "resources": [ { "name": "res-uoio", "image_ref": "00000000-0000-0000-0000-000000000008", "edge_scenes": null, "flavor_ref": "c6.large.2", "net_config": { "vpc_id": "c4b78eca-8ce4-4e7e-8aba-f7da2c7b1816", "nic_num": 1 }, "count": 1, "root_volume": { "volume_type": "SAS", "size": 40 }, "security_groups": [ { "id": "18289138-5b8b-11eb-bcf8-fa16406a65c4" } ], "user_data": "IyEvYmluL2Jhc2gKZWNobyAncm9vdDokNiQ3ODlCMkYkbFhXWDhmbE5qakxWamRGVDM1MEdYVm1NMURGQW1tQTBMRHA0M3dLSUxKcERkU3l6VUdqMC9qMTdXYzRYblQ4SVNQS2UxMVlIcWdCa1dRNUFxeUc0djEnIHwgY2hwYXNzd2QgLWU7", "bandwidth": { "sharetype": "WHOLE" } } ] }, "coverage": { "coverage_level": "city", "coverage_policy": "centralize", "coverage_sites": [ { "site": "xi'an", "demands": [ { "demand_count": 1, "pool_id": "5_bgp_edgecloud-site4_1" } ] } ] }, "name": "iec-m1183t" } }
- 响应示例
{ "id": "e127b7f4-9969-4c2a-bd3d-b813d9ff6573", "locations": [ { "site_id": "74a75ed3-cfb9-11ea-a0c3-fa1640495574", "area": "north", "province": "shaanxi", "city": "xi'an", "operator": "bgp", "pool_id": "5_bgp_edgecloud-site4_1", "stack_count": 1, "city_short_name": "" } ] }
- 接口相关信息
- 使用非cloud-init镜像创建部署计划(使用admin_pass实现密码注入)。