Updated on 2025-08-20 GMT+08:00

Modifying ECS Details

Function

This API is used to modify ECS details. Only the name and description of an ECS can be modified.

This API supports checking fine-grained permissions for enterprise projects. For details, see ecs:cloudServers:updateServer.

Constraints

This API is used to change the name of an ECS. For details about how to change the hostname of the ECS, see How Can a Changed Static Hostname Take Effect Permanently?

URI

PUT /v1/{project_id}/cloudservers/{server_id}

Table 1 describes the parameters in the URI.
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.

Request

Table 2 describes the request parameters.
Table 2 Request parameters

Parameter

Mandatory

Type

Description

server

Yes

Object

Definition

Specifies the data structure.

For details, see Table 3.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 3 server field description

Parameter

Mandatory

Type

Description

name

No

String

Definition

Specifies the name of the modified ECS.

Constraints

The parameter value consists of 1 to 128 characters, including letters, digits, underscores (_), hyphens (-), and periods (.).

Range

N/A

Default Value

N/A

description

No

String

Definition

Specifies the ECS description.

Constraints

Angle brackets (<>) are not allowed.

Range

0 to 85 characters

Default Value

N/A

hostname

No

String

Definition

Specifies the new hostname of the ECS.

Constraints

The name consists of 1-64 characters. It can be segmented using periods (.). Only letters, digits, and hyphens (-) are allowed in each segment. A name cannot contain consecutive periods (.) or hyphens (-), and cannot start or end with a period (.) or hyphen (-). Additionally, the combinations of (.-) and (-.) are not allowed.

NOTE:

This parameter is discarded. For details about how to change the hostname of the ECS, see How Can a Changed Static Hostname Take Effect Permanently?

Range

N/A

Default Value

N/A

user_data

No

String

Definition

Specifies the user data to be injected during the ECS modification. Text and text files can be injected.

Examples

Before base64 encoding:

  • Linux
    #!/bin/bash
    echo user_test > /home/user.txt
  • Windows
    rem cmd
    echo 111 > c:\aaa.txt

After base64 encoding:

  • Linux
    IyEvYmluL2Jhc2gKZWNobyB1c2VyX3Rlc3QgPiAvaG9tZS91c2VyLnR4dA==
  • Windows
    cmVtIGNtZA0KZWNobyAxMTEgJmd0OyBjOlxhYWEudHh0

For more information about the user data to be injected, see Injecting User Data into ECSs in Elastic Cloud Server User Guide.

Constraints

  • The content of user_data must be encoded with base64.
  • The maximum size of the content to be injected (before encoding) is 32 KB.

Range

N/A

Default Value

N/A

Response

Table 4 describes the response parameters.

Table 4 Response parameters

Parameter

Type

Description

server

Object

Definition

Specifies the ECS.

For details, see Table 5.

Range

N/A

Table 5 server field description

Parameter

Type

Description

tenant_id

String

Definition

Specifies the tenant or project ID.

Range

N/A

image

String

Definition

Specifies the image ID.

Range

N/A

accessIPv4

String

Definition

This is a reserved parameter.

Range

N/A

addresses

Object

Definition

Specifies the attributed network information of the ECS.

The structure is Map<String, Object>.

For details, see Table 6.

Range

N/A

metadata

Object

Definition

Specifies the ECS metadata.

Range

N/A

accessIPv6

String

Definition

This is a reserved parameter.

Range

N/A

created

String

Definition

Specifies the time when the ECS was created. The time is in the format of "2019-05-22T03:19:19Z".

Range

N/A

OS-EXT-SRV-ATTR:user_data

String

Definition

Specifies the user data (information after encoding) configured during ECS creation.

Range

N/A

hostId

String

Definition

Specifies the host ID of the ECS.

Range

N/A

flavor

Object

Definition

Specifies the ECS flavor. For details, see Table 7.

Range

N/A

OS-DCF:diskConfig

String

Definition

Specifies the disk configuration mode. This is an extended attribute. This field is valid for the ECS started using an image.

Range

N/A

user_id

String

Definition

Specifies the ID of the user to which an ECS belongs.

Range

N/A

name

String

Definition

Specifies the name of the modified ECS.

Range

N/A

progress

Integer

Definition

This is a reserved parameter.

Range

N/A

links

Array of Object

Definition

Specifies ECS shortcut links for ECS. For details, see Table 8.

Range

N/A

id

String

Definition

Specifies the unique ID of an ECS.

Range

N/A

updated

String

Definition

Specifies the time when the ECS was updated last time.

The time is in the format of "2019-05-22T03:19:19Z".

Range

N/A

locked

Boolean

Definition

Specifies the ECS lock status, which is True when the ECS is locked and False when the ECS is unlocked.

This parameter is supported in microversion 2.9 and later.

Range

N/A

description

String

Definition

Describes the ECS.

This parameter is supported in microversion 2.19 and later.

Range

N/A

tags

Array of strings

Definition

Specifies ECS tags.

This parameter is supported in microversion 2.26 and later. If the microversion is not used for query, the response does not contain the tags field.

Tag functions have been upgraded on the cloud platform. After the upgrade, the tag values returned by the system comply with the following rules:
  • The key and value of a tag are connected using an equal sign (=), for example, key=value.
  • If the value is empty, only the key is returned.

Range

N/A

status

String

Definition

Specifies the ECS status.

Range

ACTIVE, BUILD, ERROR, HARD_REBOOT, MIGRATING, REBOOT, RESIZE, REVERT_RESIZE, SHELVED, SHELVED_OFFLOADED, SHUTOFF, UNKNOWN, and VERIFY_RESIZE

For details, see ECS Statuses.

OS-EXT-SRV-ATTR:hostname

String

Definition

Specifies the new host name of the ECS.

Range

N/A

Table 6 Data structure of the network which an ECS accesses

Parameter

Type

Description

addr

String

Definition

Specifies the IP address.

Range

N/A

version

Integer

Definition

Specifies the IP address type.

Range

  • 4: The type of the IP address is IPv4.
  • 6: The type of the IP address is IPv6.
Table 7 flavor field description

Parameter

Type

Description

id

String

Definition

Specifies the ECS ID.

Range

N/A

links

Array of objects

Definition

Specifies shortcut links for ECS types. For details, see Table 8.

Range

N/A

Table 8 links field description

Parameter

Type

Description

rel

String

Definition

Specifies the shortcut link marker name.

Range

N/A

href

String

Definition

Provides the shortcut link.

Range

N/A

Example Request

Change the ECS name to new-server-test.

PUT  https://{endpoint}/v1/{project_id}/cloudservers/{server_id}

{
    "server": {
        "name": "new-server-test"
    }
}

Example Response

{
  "server": {
    "tenant_id": "66c860cb130b465fbafcdee43fb09c64",
    "image": "",
    "accessIPv4": "",
    "addresses": {
      "01d7aef8-442b-408e-b82f-13afff51e4e4": [
        {
          "addr": "192.168.26.22",
          "version": 4
        }
      ]
    },
    "metadata": {
      "virtual_env_type": "FusionCompute"
    },
    "description": "",
    "accessIPv6": "",
    "created": "2019-04-25T11:52:53Z",
    "OS-EXT-SRV-ATTR:user_data": "",
    "hostId": "57d278e7c53d07cd34fad3ba4fdc9f3d779017d0879726d83b45a22a",
    "OS-EXT-SRV-ATTR:hostname": "new-test-hostname",
    "flavor": {
      "links": [
        {
          "rel": "bookmark",
          "href": "https://None/66c860cb130b465fbafcdee43fb09c64/flavors/s2.large.2"
        }
      ],
      "id": "s2.large.2"
    },
    "OS-DCF:diskConfig": "MANUAL",
    "user_id": "f88581d53be64716a985c66ca28c75f6",
    "name": "new-test-hostname",
    "progress": 0,
    "links": [
      {
        "rel": "self",
        "href": "https://None/v2/66c860cb130b465fbafcdee43fb09c64/servers/24930df0-db4c-4a8b-8914-d0bd558564b0"
      },
      {
        "rel": "bookmark",
        "href": "https://None/66c860cb130b465fbafcdee43fb09c64/servers/24930df0-db4c-4a8b-8914-d0bd558564b0"
      }
    ],
    "id": "24930df0-db4c-4a8b-8914-d0bd558564b0",
    "updated": "2019-04-28T08:15:36Z",
    "status": "ACTIVE"
  }
}

Error Codes

See Error Codes.