Allocating DeHs

Function

This API is used to allocate one or more DeHs and set required parameters, such as the flavor, AZ, and quantity.

Constraints

The number of allocatable DeHs depends on the DeH quota owned by the tenant.

URI

POST /v1.0/{project_id}/dedicated-hosts

Table 1 describes the parameters.

Table 1 Parameters description

Parameter

Type

Mandatory

Description

project_id

String

Yes

Specifies the project ID.

For details about how to obtain the project ID, see Obtaining Required Information.

Request

Table 2 Request parameters

Parameter

In

Type

Mandatory

Description

name

body

String

Yes

Specifies the DeH name.

auto_placement

body

String

No

Specifies whether to allow an ECS to be placed on any available DeH if its DeH ID is not specified during its creation.

The value can be on or off.

The default value is on.

availability_zone

body

String

Yes

Specifies the AZ to which the DeH belongs.

host_type

body

String

Yes

Specifies the DeH type.

quantity

body

Integer

Yes

Specifies the number of allocatable DeHs.

tags

body

Array of objects

No

Specifies the DeH tags.

For details, see Table 3.

Table 3 tag field description

Parameter

Type

Mandatory

Description

key

String

Yes

Specifies the tag key.

  • It contains a maximum of 36 Unicode characters.

  • The value cannot be empty.

  • It cannot contain the following ASCII characters: =*<>\|/,

  • It can contain letters, digits, hyphens (-), and underscores (_).

value

String

Yes

Specifies the tag value.

  • It contains a maximum of 43 Unicode characters.

  • It cannot contain the following ASCII characters: =*<>\|/,

  • It can contain letters, digits, hyphens (-), and underscores (_).

Response

Table 4 Response parameters

Parameter

In

Type

Description

dedicated_host_ids

body

Array of strings

Specifies a group of IDs of allocated DeHs. The tenant can create ECSs on these DeHs.

Example Request

Two s3 DeHs are allocated in az1, and the DeH name is General Computing server1.

POST https://{Endpoint}/v1.0/9c53a566cb3443ab910cf0daebca90c4/dedicated-hosts
{
     "availability_zone": "dc1.az1",
     "name": "General-Purpose server1",
     "auto_placement": "off",
     "host_type":"s2",
     "quantity": 2,
     "tags": [
         {
             "key": "key1",
             "value": "value1"
         }
     ]
}

Example Response

{
    "dedicated_host_ids": ["xxxxxxx1","xxxxxxx2"]
}

Status Code

Table 5 Returned error codes

Error Code

Description

403 Forbidden

  1. Insufficient quota.

  2. The flavor is not supported.

404 FlavorNotFound

Invalid flavor.

For more status codes, see Status Codes.