• Native OpenStack API

noa
  1. Help Center
  2. Native OpenStack API
  3. API Reference
  4. Nova
  5. Metadata
  6. Updating Metadata

Updating Metadata

Function Description

This interface is used to update metadata of ECSs.

  • If the metadata does not contain the target field, the field is automatically added to the metadata.
  • If the metadata contains the target field, the field value is automatically updated.
  • If the request does not contain a field already in the metadata, the field value remains the same.

Interface Format

Method

URI

Description

POST

/v2/{tenant_id}/servers/{server_id}/metadata

/v2.1/{tenant_id}/servers/{server_id}/metadata

Updates metadata of ECSs.

Restrictions

The ECS must be in the active, stopped, paused, or suspended state. That is, the value of the OS-EXT-STS:vm_state attribute of the ECS must be active, stopped, paused, or suspended.

Expanded Interface

N/A

Request Parameter

Table 1 Request Parameter

Parameter

Type

Mandatory

Description

metadata

Dict

Yes

Specifies the user-defined metadata key-value pair.

Table 2 Data structure description of the metadata field

Parameter

Mandatory

Type

Description

key

Yes

String

Specifies the key name.

The value contains a maximum of 255 Unicode characters and cannot be empty. It can contain letters in upper or lower cases, digits, hyphens (-), underscores (_), colons (:), and decimal points (.).

value

Yes

String

Specifies the key value.

The value can contain a maximum of 255 Unicode characters.

Response Parameter

Parameter

Type

Mandatory

Description

metadata

Dict

Yes

Specifies the user-defined metadata key-value pair.

Request Example

POST /v2/9c53a566cb3443ab910cf0daebca90c4/servers/998af54b-5762-4041-abc1-f98a2c27b3a2/metadata
POST /v2.1/9c53a566cb3443ab910cf0daebca90c4/servers/998af54b-5762-4041-abc1-f98a2c27b3a2/metadata
{
"metadata": {
            "key1": "value1",
            "key2": "value2"
  }
}

Response Example

{
"metadata": {
            "key1": "value1",
            "key2": "value2"
 }
}

Returned Values

For details, see section General Request Returned Values.

Error Code

Table 3 Task error code

Error Code

Description

404

Server does not exist.

The target ECS does not exist.