弹性云服务器 ECS-创建云服务器:请求示例
时间:2025-05-30 17:57:07
请求示例
- 创建一台包年/包月云服务器,操作系统为CentOS 7.6 64bit,1U1G,绑定1M带宽的弹性公网IP,采用密钥方式登录鉴权。
POST https://{endpoint}/v1.1/{project_id}/cloudservers { "server": { "availability_zone":"az1-dc1", "name": "newserver", "imageRef": "67f433d8-ed0e-4321-a8a2-a71838539e09", "root_volume": { "volumetype": "SSD" }, "data_volumes": [ { "volumetype": "SSD", "size": 100 }, { "volumetype": "SSD", "size": 100, "multiattach": true, "hw:passthrough": true } ], "flavorRef": "s2.small.1", "vpcid": "2a6f4aa6-d93e-45f5-a8cb-b030dbf8cd68", "security_groups": [ { "id": "6242ef48-4d35-49c8-8711-a6e54902e44a" } ], "nics": [ { "subnet_id": "ef039b60-6a14-42d1-963b-687b627fea08" } ], "publicip": { "eip": { "iptype": "5_sbgp", "bandwidth": { "size": 1, "sharetype": "PER" } } }, "key_name": "id_rsa", "count": 1, "metadata": { "op_svc_userid": "f79791beca3c48159ac2553fff22e166" }, "extendparam": { "chargingMode": "prePaid", "periodType": "month", "periodNum": 1, "isAutoRenew": "true", "isAutoPay": "true", "enterprise_project_id": "f8e0ecc8-3825-4ee8-9596-fb4258ffdcbb" }, "os:scheduler_hints": { "group": "cdbbfffe-ef18-47b4-a5c8-f61a984c0ecc" } } }
- 创建一台包年/包月云服务器,操作系统为CentOS 7.6 64bit,1U1G,绑定1M带宽的弹性公网IP,采用密码方式登录鉴权请求中的密码,建议将密码在配置文件或者环境变量中密文存放,使用时解密,确保安全。
POST https://{endpoint}/v1.1/{project_id}/cloudservers { "server": { "availability_zone":"az1-dc1", "name": "newserver", "adminPass": "$ADMIN_PASS", "imageRef": "67f433d8-ed0e-4321-a8a2-a71838539e09", "root_volume": { "volumetype": "SSD" }, "data_volumes": [ { "volumetype": "SSD", "size": 100 }, { "volumetype": "SSD", "size": 100, "multiattach": true, "hw:passthrough": true } ], "flavorRef": "s2.small.1", "vpcid": "2a6f4aa6-d93e-45f5-a8cb-b030dbf8cd68", "security_groups": [ { "id": "6242ef48-4d35-49c8-8711-a6e54902e44a" } ], "nics": [ { "subnet_id": "ef039b60-6a14-42d1-963b-687b627fea08" } ], "publicip": { "eip": { "iptype": "5_sbgp", "bandwidth": { "size": 1, "sharetype": "PER" } } }, "key_name": "", "count": 1, "metadata": {}, "extendparam": { "chargingMode": "prePaid", "periodType": "month", "periodNum": 1, "isAutoRenew": "true", "isAutoPay": "true", "enterprise_project_id": "f8e0ecc8-3825-4ee8-9596-fb4258ffdcbb" }, "os:scheduler_hints": { "group": "cdbbfffe-ef18-47b4-a5c8-f61a984c0ecc" } } }
- 创建一台包年/包月云服务器,操作系统为CentOS 7.6 64bit,1U1G,绑定1M带宽的按需按流量计费的弹性公网IP,采用密钥方式登录鉴权。
POST https://{endpoint}/v1.1/{project_id}/cloudservers { "server": { "availability_zone":"az1-dc1", "name": "newserver", "imageRef": "67f433d8-ed0e-4321-a8a2-a71838539e09", "root_volume": { "volumetype": "SSD" }, "data_volumes": [ { "volumetype": "SSD", "size": 100 }, { "volumetype": "SSD", "size": 100, "multiattach": true, "hw:passthrough": true } ], "flavorRef": "s2.small.1", "vpcid": "2a6f4aa6-d93e-45f5-a8cb-b030dbf8cd68", "security_groups": [ { "id": "6242ef48-4d35-49c8-8711-a6e54902e44a" } ], "nics": [ { "subnet_id": "ef039b60-6a14-42d1-963b-687b627fea08" } ], "publicip": { "eip": { "iptype": "5_sbgp", "bandwidth": { "size": 1, "sharetype": "PER", "chargemode": "traffic" }, "extendparam": { "chargingMode": "postPaid" } } }, "key_name": "id_rsa", "count": 1, "metadata": { "op_svc_userid": "f79791beca3c48159ac2553fff22e166" }, "extendparam": { "chargingMode": "prePaid", "periodType": "month", "periodNum": 1, "isAutoRenew": "true", "isAutoPay": "true", "enterprise_project_id": "f8e0ecc8-3825-4ee8-9596-fb4258ffdcbb" }, "os:scheduler_hints": { "group": "cdbbfffe-ef18-47b4-a5c8-f61a984c0ecc" } } }
- 创建一台包年/包月云服务器,操作系统为CentOS 7.6 64bit,1U1G,绑定共享带宽的弹性公网IP,采用密钥方式登录鉴权。
POST https://{endpoint}/v1.1/{project_id}/cloudservers { "server": { "availability_zone":"az1-dc1", "name": "newserver", "imageRef": "67f433d8-ed0e-4321-a8a2-a71838539e09", "root_volume": { "volumetype": "SSD" }, "data_volumes": [ { "volumetype": "SSD", "size": 100 }, { "volumetype": "SSD", "size": 100, "multiattach": true, "hw:passthrough": true } ], "flavorRef": "s2.small.1", "vpcid": "2a6f4aa6-d93e-45f5-a8cb-b030dbf8cd68", "security_groups": [ { "id": "6242ef48-4d35-49c8-8711-a6e54902e44a" } ], "nics": [ { "subnet_id": "ef039b60-6a14-42d1-963b-687b627fea08" } ], "publicip": { "eip": { "iptype": "5_sbgp", "bandwidth": { "id": "a0d4b26f-699d-49a0-bcc8-6f707a925abf", "sharetype": "WHOLE" } } }, "key_name": "id_rsa", "count": 1, "metadata": { "op_svc_userid": "f79791beca3c48159ac2553fff22e166", "agency_name": "test" }, "extendparam": { "chargingMode": "prePaid", "periodType": "month", "periodNum": 1, "isAutoRenew": "true", "isAutoPay": "true", "enterprise_project_id": "f8e0ecc8-3825-4ee8-9596-fb4258ffdcbb" }, "os:scheduler_hints": { "group": "cdbbfffe-ef18-47b4-a5c8-f61a984c0ecc" } } }
support.huaweicloud.com/api-ecs/ecs_02_0101.html