This API is used to create one or more ECSs.
This is an asynchronous API. After the ECS creation request is issued, the system will return job_id. The ECS creation is still in progress. Therefore, you need to call the API described in Querying Task Execution Status to obtain the task status. When the status changes to SUCCESS, the ECS has been created.
Before calling this API, you need to obtain Regions and Endpoints.
Logging in to an ECS can be authenticated using either a key pair or password. For security purposes, you are advised to use key pair authentication.
A key pair is used for ECS login authentication.
Method of calling APIs: Use the key_name field to specify the key file used for logging in to the ECS.
If you choose the initial password for authentication in an ECS, you can log in to the ECS using the username and its initial password. The initial password of user root is used for authentication in Linux, while that of user Administrator is used for authentication in Windows.
If the user_data field is specified for a Linux ECS that is created using an image with Cloud-Init installed, the adminPass field becomes invalid.
If you use a Linux private image to create an ECS, you can use the image password for login authentication.
Method of calling APIs: If the image password is used, the key_name and adminPass fields do not need to be specified.
Request parameters
Table 2 describes the request parameters.
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
server |
Yes |
Object |
Specifies the ECS information. For details, see Table 3. |
dry_run |
No |
Boolean |
Specifies whether to check the request and create the ECS.
|
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
imageRef |
Yes |
String |
Specifies the ID of the system image used for creating ECSs. The ID is in Universally Unique Identifier (UUID) format. NOTE:
|
flavorRef |
Yes |
String |
Specifies the flavor ID of the ECS to be created. For details about the flavors that have been released, see "Instances" in Elastic Cloud Server User Guide. |
name |
Yes |
String |
Specifies the ECS name. Value requirements:
|
user_data |
No |
String |
Specifies the user data to be injected to the ECS during the creation. Text and text files can be injected. NOTE:
For more information about the user data to be injected, see "Injecting User Data into ECSs" in Elastic Cloud Server User Guide. Examples Before base64 encoding:
After base64 encoding:
|
adminPass |
No |
String |
Specifies the initial login password of the administrator account for logging in to an ECS using password authentication. The Linux administrator is root, and the Windows administrator is Administrator. For details, see Function. Password complexity requirements:
|
key_name |
No |
String |
Specifies the name of the SSH key used for logging in to the ECS. Keys can be created using the key creating API (Creating and Importing an SSH Key Pair) or obtained using the SSH key query API (Querying SSH Key Pairs). |
vpcid |
Yes |
String |
Specifies the ID of the VPC to which the ECS belongs. The value is in the format of the UUID. You can obtain the VPC ID from the management console or by following the instructions provided in "Querying VPCs" in Virtual Private Cloud API Reference. |
nics |
Yes |
Array of objects |
Specifies the NIC information of the ECS. For details, see Table 4. Constraints:
|
publicip |
No |
Object |
Specifies the EIP of the ECS, which can be configured in the following ways:
For details, see Table 1. |
count |
No |
Integer |
Specifies the number of ECSs to be created. Constraints:
|
root_volume |
Yes |
Object |
Specifies ECS system disk configurations. For details, see Table 5. |
data_volumes |
No |
Array of objects |
Specifies ECS data disk configurations. Each data structure represents a data disk to be created. An ECS can be attached with a maximum of 59 data disks (certain flavors support only 23 data disks). For details, see Table 6. |
security_groups |
No |
Array of objects |
Specifies the security groups of the ECS. If this parameter is left blank, the default security group is bound to the ECS by default. For details, see Table 2. |
availability_zone |
No |
String |
Specifies the name of the AZ where the ECS is located. NOTE:
If this parameter is not specified, the system automatically selects an AZ. See Querying AZs. |
extendparam |
No |
Object |
Provides the supplementary information about the ECS to be created. For details, see Table 6. |
metadata |
No |
Object |
Specifies the metadata of the ECS to be created. You can use metadata to customize key-value pairs. NOTE:
For details about reserved key-value pairs, see Table 8. |
os:scheduler_hints |
No |
Object |
Schedules ECSs, for example, by configuring an ECS group. For details, see Table 9. |
tags |
No |
Array of strings |
Specifies ECS tags. A tag is in the format of "key.value", where the maximum lengths of key and value are 36 and 43 characters, respectively. When adding a tag to an ECS, ensure that the tag complies with the following requirements:
NOTE:
|
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
subnet_id |
Yes |
String |
Specifies the subnet of the ECS. The value must be the ID of the subnet created in the VPC specified by vpcid and in the format of the UUID. |
ip_address |
No |
String |
Specifies the IP address of the NIC used by the ECS. The value is an IPv4 address. Constraints:
|
binding:profile |
No |
Object |
Allows you to customize data. Configure this parameter when creating a HANA ECS. For details, see Table 11. |
extra_dhcp_opts |
No |
Array of objects |
Indicates extended DHCP options. For details, see Table 12. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
volumetype |
Yes |
String |
Specifies the ECS system disk type, which must be one of available disk types. Currently, the value can be SSD, SAS, SATA, co-p1, or uh-l1.
If the specified disk type is not available in the AZ, the disk will fail to create. NOTE:
|
size |
No |
Integer |
Specifies the system disk size, in GB. The value ranges from 1 to 1024. Constraints:
|
hw:passthrough |
No |
Boolean |
Pay attention to this parameter if your ECS is SDI-compliant. If the value of this parameter is true, the created disk is of SCSI type. NOTE:
This parameter is of boolean type. If a non-boolean character is imported, the parameter value is set to false. |
metadata |
No |
Object |
Specifies the EVS disk metadata. Ensure that key and value in the metadata contain at most 255 bytes. This field is used only when an encrypted disk is created. For details, see metadata Field Description for Creating Disks. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
volumetype |
Yes |
String |
Specifies the type of the ECS data disk, which must be one of available disk types. Currently, the value can be SSD, SAS, SATA, co-p1, or uh-l1.
If the specified disk type is not available in the AZ, the disk will fail to create. NOTE:
|
size |
Yes |
Integer |
Specifies the data disk size, in GB. The value ranges from 10 to 32768. When you use a data disk image to create a data disk, ensure that the value of this parameter is greater than or equal to the size of the source data disk that is used to create the data disk image. |
shareable |
No |
Boolean |
Specifies whether the disk is shared. The value can be true (specifies a shared disk) or false (a common EVS disk). NOTE:
This field has been discarded. Use multiattach. |
multiattach |
No |
Boolean |
Specifies the shared disk information.
NOTE:
The shareable field is not used anymore. If both shareable and multiattach must be used, ensure that the values of the two fields are the same. If this parameter is not specified, common EVS disks are created by default. |
hw:passthrough |
No |
Boolean |
Indicates whether the data volume uses a SCSI lock.
NOTE:
This parameter is of boolean type. If a non-boolean character is imported, the parameter value is set to false. |
extendparam |
No |
Object |
Provides the disk information. For details, see Table 5. |
data_image_id |
No |
String |
Specifies ID of the data image. The value is in UUID format. If data disks are created using a data disk image, this parameter is mandatory and it does not support metadata. |
metadata |
No |
Object |
Specifies the EVS disk metadata. Ensure that key and value in the metadata contain at most 255 bytes. This field is used only when an encrypted disk is created. If data disks are created using a data disk image, this field cannot be used. For details, see metadata Field Description for Creating Disks. |
Parameter |
Type |
Description |
---|---|---|
job_id |
String |
Specifies the returned task ID after delivering the task. You can query the task progress using this ID. For details about how to query the task execution status based on job_id, see Task Status Management. |
For details about abnormal responses, see Responses (Task).
The public cloud platform provides various ECS types. The flavor name/ID varies depending on ECS types and specifications. When you use APIs to create ECSs with different specifications, the request bodies are the same. You only need to change the parameter values in the following request example based on the parameters described in Request.
POST https://{endpoint}/v1/{project_id}/cloudservers
{ "server": { "availability_zone":"az1-dc1", "name": "newserver", "imageRef": "imageid_123", "root_volume": { "volumetype": "SSD" }, "data_volumes": [ { "volumetype": "SSD", "size": 100 }, { "volumetype": "SSD", "size": 100, "multiattach": true, "hw:passthrough": true } ], "flavorRef": "m3.larger", "vpcid": "0dae26c9-9a70-4392-93f3-87d53115d171", "security_groups": [ { "id": "507ca48f-814c-4293-8706-300564d54620" } ], "nics": [ { "subnet_id": "157ee789-03ea-45b1-a698-76c92660dd83", "extra_dhcp_opts":[ { "opt_value": 8888, "opt_name": "26" } ] } ], "publicip": { "eip": { "iptype": "5_bgp", "bandwidth": { "size": 10, "sharetype": "PER" } } }, "key_name": "sshkey-123", "count": 1 } }
{ "server": { "availability_zone":"az1-dc1", "name": "wholeImageServer", "imageRef": "ff49b1f1-3e3e-4913-89c6-a026041661e8", "root_volume": { "volumetype": "SSD", "metadata": { "__system__encrypted": "1", "__system__cmkid": "83cdb52d-9ebf-4469-9cfa-e7b5b80da846" } }, "data_volumes": [ { "volumetype": "SSD", "size": 100, "extendparam":{ "snapshotId": "ef020653-9742-4d24-8672-10af42c9702b" } }, { "volumetype": "SSD", "size": 50 } ], "flavorRef": "s2.large.2", "vpcid": "0dae26c9-9a70-4392-93f3-87d53115d171", "security_groups": [ { "id": "507ca48f-814c-4293-8706-300564d54620" } ], "nics": [ { "subnet_id": "157ee789-03ea-45b1-a698-76c92660dd83" } ], "key_name": "sshkey-123" } }
{ "dry_run": true "server": { "availability_zone":"az1-dc1", "name": "newserver", "imageRef": "1189efbf-d48b-46ad-a823-94b942e2a000", "root_volume": { "volumetype": "SSD" }, "data_volumes": [ ], "flavorRef": "s3.xlarge.2", "vpcid": "0dae26c9-9a70-4392-93f3-87d53115d171", "security_groups": [ { "id": "507ca48f-814c-4293-8706-300564d54620" } ], "nics": [ { "subnet_id": "157ee789-03ea-45b1-a698-76c92660dd83" } ], "key_name": "sshkey-123", "count": 1 } }
{ "job_id": "93c82933d6b7827d3016b8771f2070873" }
Or
{ "error": { "code": "request body is illegal.", "message": "Ecs.0005" } }
See Error Codes.