Modifying ECS Details

Function

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

Constraints

The modification on the hostname takes effect only after the ECS is restarted.

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.

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

Specifies the data structure.

For details, see Table 3.

Table 3 server field description

Parameter

Mandatory

Type

Description

name

No

String

Specifies the name of the modified ECS.

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

description

No

String

Specifies the ECS description.

The value consists of 0-85 characters and cannot contain brackets (<>).

hostname

No

String

Specifies the modified host name of the ECS.

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 field is no longer used. For details about how to modify the host name of the ECS, see "How Can a Changed Static Hostname Take Effect Permanently?" in Elastic Cloud Server User Guide.

Response

Table 4 describes the response parameters.

Table 4 Response parameters

Parameter

Type

Description

server

Object

Specifies the ECS.

For details, see Table 5.

Table 5 server field description

Parameter

Type

Description

tenant_id

String

Specifies the tenant or project ID.

image

String

Specifies the image ID.

accessIPv4

String

Reserved

addresses

Object

Specifies the attributed network information of the ECS.

The structure is Map<String, Object>.

For details, see Table 6.

metadata

Object

Specifies the ECS metadata.

accessIPv6

String

Reserved

created

String

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

hostId

String

Specifies the host ID of the ECS.

flavor

Object

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

OS-DCF:diskConfig

String

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

user_id

String

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

name

String

Specifies the name of the modified ECS.

progress

Integer

Reserved

links

Array of Object

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

id

String

Specifies the unique ID of an ECS.

updated

String

Specifies the time when the ECS was updated last time.

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

locked

Boolean

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.

description

String

Describes the ECS.

This parameter is supported in microversion 2.19 and later.

tags

Array of strings

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.

For more details about upgraded tag functions, see Tag Types.

status

String

Specifies the ECS status.

Options:

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

Specifies the new host name of the ECS.

Table 6 Data structure of the network which an ECS accesses

Parameter

Type

Description

addr

String

Specifies the IP address.

version

Integer

Specifies the type of an IP address. The value of this parameter can be 4 or 6.

  • 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

Specifies the ECS ID.

links

Array of objects

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

Table 8 links field description

Parameter

Type

Description

rel

String

Specifies the shortcut link marker name.

href

String

Provides the shortcut link.

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",
    "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"
  }
}

Returned Values

See Returned Values for General Requests.

Error Codes

See Error Codes.