Updated on 2024-06-03 GMT+08:00

Modifying the Specifications of an ECS

Function

This API is used to modify ECS specifications.

This API is an asynchronous API. After the specifications modification request is successfully delivered, a job ID is returned. This does not mean the modification is complete. You need to call the API by referring to Querying Task Execution Status to query the job status. The SUCCESS status indicates that the modification is successful.

The V1.1 API supports all functions (see Modifying the Specifications of an ECS (Pay-per-Use)) provided by the V1 API. Additionally, the V1.1 API supports the modification of yearly/monthly ECSs.

Huawei Cloud no longer provides Windows images. This API cannot be used to modify the specifications of Windows ECSs.

Constraints

  • You can modify the ECS specifications only when the ECS is stopped.
  • Spot ECSs do not support specifications modification.

URI

POST /v1.1/{project_id}/cloudservers/{server_id}/resize

Table 1 Parameter description

Parameter

Mandatory

Description

project_id

Yes

Specifies the project ID.

For details about how to obtain the ID, see Obtaining a Project ID.

server_id

Yes

Specifies the ECS ID.

You can obtain the ECS ID from the console or by following the instructions provided in "Querying Details About an ECS".

Request

Table 2 Parameter description

Parameter

Mandatory

Type

Description

resize

Yes

Object

Specifies the operation to modify ECS specifications. For details, see Table 3.

dry_run

No

Boolean

Specifies whether to only check the request and not modify the ECS specifications.

true: The request is sent and the ECS specifications will not be modified. Check items include mandatory parameters and request format.

  • If the check fails, the system returns an error.
  • If the check is successful, the system returns status code 202.

false: The request is sent and the ECS specifications will be modified if the check is successful.

Table 3 resize field description

Parameter

Mandatory

Type

Description

flavorRef

Yes

String

Specifies the flavor ID of the ECS after the modification.

You can view Querying the Target ECS Flavors to Which a Flavor Can Be Changed to query the target flavors to which a specified ECS flavor can be changed.

NOTE:
  • Modifications between the same flavor are not supported.

dedicated_host_id

No

String

Specifies the DeH ID after the modification.

This parameter is mandatory only for ECSs deployed on DeHs.

extendparam

No

Object

Specifies the extended information about an ECS after the modification. For details, see Table 4.

cpu_options

No

Object

Specifies the CPU options.

For details, see Table 5.

Table 4 extendparam field description

Parameter

Mandatory

Type

Description

isAutoPay

No

String

Specifies whether the order is automatically or manually paid.

  • true: The order will be automatically paid.
  • false: The order must be manually paid.
NOTE:

This parameter is valid only for yearly/monthly ECSs. When this parameter is left blank, the order must be manually paid by default.

Table 5 cpu_options field description

Parameter

Mandatory

Type

Description

hw:cpu_threads

No

integer

Specifies whether to enable CPU hyper-threading.

Values: 1 and 2

  • 1: Disable hyper-threading.
  • 2: Enable hyper-threading.

This parameter can be set to 1 (disabling hyper-threading) only when all of the following conditions are met:

  • The ECS is being created or resized.
  • The extra_specs parameter of the target flavor contains:
    • hw:cpu_policy, whose value is set to dedicated
    • hw:cpu_threads, whose value is set to 2

Response

Table 6 Parameter description

Parameter

Mandatory

Type

Description

job_id

No

String

Specifies the task ID. This parameter is returned when you modify the specifications of a pay-per-use ECS.

For details about task statuses, see Querying Task Execution Status.

order_id

No

String

Specifies the order ID. This parameter is returned when you modify the specifications of a yearly/monthly ECS.

Example Request

Change the flavor of an ECS on a DeH to s3.large.2, enable automatic payment, and allow specifications to be modified when the ECS is running.

POST https://{endpoint}/v1.1/{project_id}/cloudservers/{server_id}/resize

{
    "resize": {
        "flavorRef": "s3.large.2",
        "dedicated_host_id": "459a2b9d-804a-4745-ab19-a113bb1b4ddc",
        "extendparam":{
             "isAutoPay": "true"
        },
       
    }
}

Example Response

{
    "job_id": "ff80808288d41e1b018990260955686a"
}

Or

{
    "order_id": "CS1711152257C60TL",
    "job_id": "ff80808288d41e1b018990260955686a"
}

Or

{
    "error": {
        "message": "XXXX", 
        "code": "XXX"
    }
}

Error Codes

See Error Codes.