This API is used to create ECS.
This API does not support automatic rollback after creating an ECS failed. If automatic rollback is required, call the API POST /v1/{project_id}/cloudservers. For details, see Creating an ECS.
POST /v2.1/{project_id}/servers
POST /v2/{project_id}/servers
Alias of the API for creating ECSs: /v2/{project_id}/os-volumes_boot
This calling mode can only be used in OpenStack client.
provider:network_type being set to geneve indicates the internal high-speed network for BMSs.
Table 2 describes the request parameters.
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
server |
Yes |
Object |
Specifies the ECS information. For details, see Table 3. |
os:scheduler_hints |
No |
Object |
Specifies the ECS scheduling information. For details, see Table 8. This parameter is not available for BMSs. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
imageRef |
No |
String |
Specifies the ECS image ID or URL.
NOTE:
|
flavorRef |
Yes |
String |
Specifies the flavor ID or URL. For example: c3.2xlarge |
name |
Yes |
String |
Specifies the ECS name. The value contains 1 to 255 characters. |
metadata |
No |
Map<String,String> |
Specifies the ECS metadata. For details, see Table 4.
|
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. |
block_device_mapping_v2 |
No |
Array of objects |
Indicates the V2 API for specifying the ECS storage device. This is an extended attribute. This is the storage resource API of the new version. You are not allowed to create ECSs in batches when the volume is specified. For details, see Table 5. This parameter is not available for BMSs. |
config_drive |
No |
String |
Specifies the config_drive disk to be attached to the ECS during the ECS creation for transferring information to the ECS. This is an extended attribute. This function is not supported. |
security_groups |
No |
Array of objects |
Specifies the security group that the ECS belongs to. This parameter is an extended attribute. The default parameter value is default. This parameter is valid when you create an ECS on a specified network. For an existing port, the requested security groups are invalid. For details, see Table 6. |
networks |
Yes |
Array of objects |
Specifies information about the ECS NIC. This parameter is an extended attribute. This parameter must be specified if multiple tenant networks are used. For details, see Table 7. |
key_name |
No |
String |
Specifies the name of a key pair. This parameter is an extended attribute. |
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:
|
availability_zone |
No |
String |
Specifies the AZ of a specified ECS. This is an extended attribute. This parameter is mandatory when you create an ECS. |
return_reservation_id |
No |
Boolean |
Specifies whether the reservation IDs of the ECSs created in a batch are returned. This is an extended attribute. You can query the ECSs created this time based on the returned reservation IDs.
|
min_count |
No |
Integer |
Specifies the minimum number of ECSs that can be created. This is an extended attribute. The default value is 1. NOTE:
When you use a specified image to create ECSs, this parameter is available. |
max_count |
No |
Integer |
Specifies the maximum number of ECSs that can be created. The default value of max_count is the same as that of min_count. Note:
NOTE:
When you use a specified image to create ECSs, this parameter is available. |
OS-DCF:diskConfig |
No |
String |
Specifies the disk configuration mode. The value can be AUTO or MANUAL.
This function is not supported. |
description |
No |
String |
Specifies the description of an ECS, which is a null string by default. This is an extended attribute. This parameter is supported in microversion 2.19 and later.
|
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
admin_pass |
No |
String |
Specifies the password of user Administrator for logging in to a Windows ECS. NOTE:
This parameter is mandatory when a Windows ECS using password authentication is created. |
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
source_type |
String |
Yes |
Specifies the source type of the volume device. Its value can be volume, image, snapshot, or blank. If you use a volume to create an ECS, set source_type to volume. If you use an image to create an ECS, set source_type to image. If you use a snapshot to create an ECS, set source_type to snapshot. If you create an empty data volume, set source_type to blank. NOTE:
If source_type is snapshot and boot_index is 0, the EVS disk of this snapshot must be the system disk. |
destination_type |
String |
No |
Specifies the target type of the disk device. Its value can only be volume.
|
guest_format |
String |
No |
Specifies the local file system format. Its value can be swap or ext4. This function is not supported. |
device_name |
String |
No |
Specifies the disk device name. NOTE:
This field has been discarded. The specified device_name does not take effect. The system generates a device name by default. |
delete_on_termination |
Boolean |
No |
Specifies whether disks are deleted when an ECS is deleted. Its default value is false.
|
boot_index |
String |
No |
Specifies whether it is a boot disk. 0 specifies a boot disk, and -1 specifies a non-boot disk. If this parameter is not specified, the default value is -1. NOTE:
If source_type of the volume device is volume, there must be one boot_index whose value is 0. |
uuid |
String |
No |
|
volume_size |
Integer |
No |
Specifies the volume size. The value is an integer. This parameter is mandatory when source_type is set to image or blank, and destination_type is set to volume. Unit: GB |
volume_type |
String |
No |
Specifies the volume type. This parameter is recommended when source_type is set to image and destination_type is set to volume. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
No |
String |
Specifies the security group name or UUID. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
port |
No |
String |
Specifies the network port UUID. This parameter must be set when the network UUID is not specified. |
uuid |
No |
String |
Specifies the network UUID. This parameter must be set when the network port is not specified. |
fixed_ip |
No |
String |
Specifies the fixed IP address. Parameter port in the three network parameters (port, uuid, and fixed_ip) has the highest priority. If parameter fixed_ip is set, you must specify the UUID. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
group |
No |
String |
Specifies the anti-affinity group. The value is in UUID format. NOTE:
Ensure that the ECS group uses the anti-affinity policy. You are not advised to use other policies. |
different_host |
No |
Array of strings |
The function has not been supported, and this field is reserved. |
same_host |
No |
Array of strings |
The function has not been supported, and this field is reserved. |
cidr |
No |
String |
The function has not been supported, and this field is reserved. |
build_near_host_ip |
No |
String |
The function has not been supported, and this field is reserved. |
tenancy |
No |
String |
Specifies whether the ECS is created on a Dedicated Host (DeH) or in a shared pool (default). The value can be shared or dedicated.
The parameter value also takes effect for ECS query operations. |
dedicated_host_id |
No |
String |
Specifies the DeH ID. This parameter takes effect only when the value of tenancy is dedicated. If you do not specify this parameter, the system will automatically assign a DeH to you to deploy ECSs. The parameter value also takes effect for ECS query operations. |
check_resources |
No |
String |
Specifies whether to check resource sufficiency when creating an ECS. If this parameter is not configured, the system does not check resource sufficiency by default. The value can be true or false. The default value is false.
NOTE:
Since the resource usage is dynamic, the resource sufficiency check result is not accurate. |
Table 9 describes the response parameters.
Parameter |
Type |
Description |
---|---|---|
server |
Object |
Specifies ECS information. For details, see Table 10. |
Parameter |
Type |
Description |
---|---|---|
id |
String |
Specifies the ECS ID in UUID format. |
links |
Array of objects |
Specifies the URI of the ECS. For details, see Table 11. |
security_groups |
Array of objects |
Specifies the security groups to which the ECS belongs. For details, see Table 12. |
OS-DCF:diskConfig |
String |
Specifies the disk configuration mode.
|
reservation_id |
String |
Specifies a filtering criteria to query the created ECSs.
NOTE:
When you create ECSs in a batch, this parameter is available. |
adminPass |
String |
Specifies the password of user Administrator for logging in to a Windows ECS. |
Creating an ECS
POST https://{endpoint}/v2/9c53a566cb3443ab910cf0daebca90c4/servers POST https://{endpoint}/v2.1/9c53a566cb3443ab910cf0daebca90c4/servers
Example 1: Use an image to create an ECS through the API block_device_mapping_v2.
{ "server": { "flavorRef": "2", "name": "wjvm48", "metadata": { "name": "name_xx1", "id": "id_xxxx1" }, "block_device_mapping_v2": [{ "source_type": "image", "destination_type": "volume", "uuid": "b023fe17-11db-4efb-b800-78882a0e394b", "delete_on_termination": "False", "boot_index": "0", "volume_type": "SAS", "volume_size": "40" }], "security_groups": [{ "name": "name_xx5_sg" }], "networks": [{ "uuid": "fd40e6f8-942d-4b4e-a7ae-465287b02a2c", "port": "e730a11c-1a19-49cc-8797-cee2ad67af6f", "fixed_ip": "10.20.30.137" }], "key_name": "test", "user_data": "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA==", "availability_zone":"az1-dc1" } }
When source_type is snapshot, boot_index is 0, and the EVS disk corresponding to the snapshot must be a system disk.
{ "server":{ "name":"wjvm48", "availability_zone":"az1-dc1", "block_device_mapping_v2": [ { "source_type":"snapshot", "boot_index":"0", "uuid":"df51997d-ee35-4fb3-a372-e2ac933a6565", //Specifies the snapshot ID, which is returned by the API for creating a snapshot. "destination_type":"volume" } ], "flavorRef":"s3.xlarge.2", "max_count":1, "min_count":1, "networks": [ { "uuid":"79a68cef-0936-4e21-b1f4-b800ecb70246" } ] } }
{ "server": { "flavorRef": "2", "name": "wjvm48", "metadata": { "name": "name_xx1", "id": "id_xxxx1" }, "block_device_mapping_v2": [{ "source_type": "volume", "destination_type": "volume", "uuid": "bd7e4f86-b004-4745-bea2-a55b1085f107", "delete_on_termination": "False", "boot_index": "0", "volume_type": "dsware", "volume_size": "40" }], "security_groups": [{ "name": "name_xx5_sg" }], "networks": [{ "uuid": "fd40e6f8-942d-4b4e-a7ae-465287b02a2c", "port": "e730a11c-1a19-49cc-8797-cee2ad67af6f", "fixed_ip": "10.20.30.137" }], "key_name": "test", "user_data": "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA==", "availability_zone":"az1-dc1" } }
{ "server": { "flavorRef": "2", "name": "wjvm48", "metadata": { "name": "name_xx1", "id": "id_xxxx1" }, "adminPass": "name_xx1", "imageRef": "6b344c54-d606-4e1a-a99e-a7d0250c3d14", "security_groups": [{ "name": "name_xx5_sg" }], "networks": [{ "uuid": "fd40e6f8-942d-4b4e-a7ae-465287b02a2c", "port": "e730a11c-1a19-49cc-8797-cee2ad67af6f", "fixed_ip": "10.20.30.137" }], "key_name": "test", "user_data": "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA==", "availability_zone":"az1-dc1" } }
Creating ECSs in a batch:
{ "server": { "availability_zone":"az1.dc1", "name": "test", "imageRef": "10ff4f01-35b6-4209-8397-359cb4475fa0", "flavorRef": "s3.medium", "return_reservation_id": "true", "networks": [ { "uuid": "51bead38-d1a3-4d08-be20-0970c24b7cab" } ], "min_count": "2", "max_count": "3" } }
Creating an ECS
{ "server": { "security_groups": [ { "name": "name_xx5_sg" } ], "OS-DCF:diskConfig": " MANUAL", "id": "567c1557-0eca-422c-bfce-149d6b8f1bb8", "links": [ { "href": "http://xxx/v2/dc4059e8e7994f2498b514ca04cdaf44/servers/567c1557-0eca-422c-bfce-149d6b8f1bb8", "rel": "self" }, { "href": "http://xxx/dc4059e8e7994f2498b514ca04cdaf44/servers/567c1557-0eca-422c-bfce-149d6b8f1bb8", "rel": "bookmark" } ], "adminPass": "name_xx1" } }
Creating ECSs in a batch:
{ "reservation_id": "r-3fhpjulh" }