Help Center > Elastic Cloud Server > User Guide > Management > Managing ECS Metadata

Managing ECS Metadata

ECS metadata is used to configure or manage running ECSs. Table 1 lists the two sets of APIs that ECS metadata supports.
Table 1 ECS metadata types

API Type

Metadata Type

Description

Compatibility

OpenStack metadata API

Metadata

Displays ECS metadata.

Supported

GET Password

Displays the password for logging in to an ECS.

Supported

User Data

Displays ECS user data.

Supported

POST Password

Stores the password for logging in to an ECS.

Supported

Security Key

Obtains temporary AKs and SKs.

Supported

EC2 compatible API

ami-id

Displays the image ID of an ECS.

Supported

ami-launch-index

Displays an ECS launching sequence.

Supported

ami-manifest-path

Displays the path where an image list is stored.

Supported

block-device-mapping

Displays the block device of an ECS.

Supported

hostname

Displays the name of the host accommodating an ECS.

Supported

instance-id

Displays an ECS ID.

Supported

instance-type

Displays an ECS flavor name.

Supported

local-ipv4

Displays the fixed IP address of an ECS.

Supported

availability-zone

Displays the AZ accommodating an ECS.

Supported

public-ipv4

Displays the floating IP address of an ECS.

Supported

public-keys

Displays the public key of an ECS.

Supported

reservation-id

Displays an ECS reservation ID.

Supported

user-data

Displays ECS user data.

Supported

instance-action

Displays ECS actions.

Not supported

kernel-id

Displays an ECS kernel image ID.

Not supported

local-hostname

Displays the local name of an ECS.

Not supported

public-hostname

Displays the external name of an ECS.

Not supported

ramdisk-id

Displays an ECS ramdisk image ID.

Not supported

security-groups

Displays the security group to which an ECS belongs.

Not supported

The following describes the URI and methods of using the supported ECS metadata.

Prerequisites

Security group rules in the outbound direction meet the following requirements:

  • Protocol: TCP
  • Port Range: 80
  • Remote End: 169.254.0.0/16
NOTE:

If you use the default security group rules in the outbound direction, the preceding requirements are met, and the metadata can be accessed. Default security group rules in the outbound direction are as follows:

  • Protocol: ANY
  • Port Range: ANY
  • Remote End: 0.0.0.0/16

Metadata (OpenStack Metadata API)

Displays ECS metadata.

  • URI

    /169.254.169.254/openstack/{version}/meta_data.json

  • Usage method

    Supports GET requests.

  • Example

    The following section describes how to use the tool cURL to view ECS metadata.

    curl http://169.254.169.254/openstack/latest/meta_data.json

    {
        "admin_pass": "sWs9YVAiytTs",
        "availability_zone": "manage-az",
        "files": [
            {
                "content_path": "/content/0000",
                "path": "/etc/litao.ini"
            }
        ],
        "hostname": "lt-test-01.novalocal",
        "launch_index": 0,
        "meta": {
            "test_key": "test_vaule"
        },
        "name": "lt-test-01",
        "public_keys": {
            "novakey": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCr4Mk6fRqbPRXE3lq9NivYvrysz0/D+gAWCgKCG46lU+x3aLRRtUwpSoX4W7FtRegHAp7EpIhmW40vM+9HrKEZbQsaiyfe0VP/cHZFKJLU9cnDJNMIb0WoIjLWDORnUnsfZL1tFaYyIcAdIl6TuB92sj4Bg8xrYCn3nfNtSSfHHszvHIc0kys7AC+ellL4NWlyeGDSkmsHS0vnIP0mpRgpB2QShmx/ZEIQQ+YxMoL8z+A44+v/V+/R8K7aJK3LbQ8Yu8vwky9M1OLG176s9pQnTmdlrKNWc4dYC8zNRxaFvyuUO9FD71OSEkmoZwkbhYHmIVIw49d0OIr63ok8mMij root@6B1AA2D2-3B57-11DA-8567-000000821800\n"
        },
        "random_seed": "ptvKzBu5SNFrWKAiar62VT7KOGZS38T3VdpEjRDmBOwF0RGKvjNGXasAXZo8KfzBPCq+MupA4Ig9mUyHWJiAcI7IvOQV7EWubJ4pxQn2tNxrwRR7VdSR8WJUqeZV1FjxxgxjJkQtnWmrT57J+SEaqzRP64ONYdikPnBlOIpnsj+gKMXxDmFL3tQ0ljC2vKdZdbjc8QkT84/dnbJpx/DaatkiLWVVTmlGhP72j/0NH1JbAnv5EECS5z51h2YFnRxJOJFlSCwnl5UuFRjsO82T+7usRjK0IXAvDIKcqQlzrV5WWXrWc1e+yejIjjVvAGad5PcjLeaGaEEBNo5eBJ9e4FZHLkkUV7naYGsLiOLjO3qZjvFM1gcaKsrv92/Ys2DbwHFfV0Xo/uNA9Jx7MFIXELdNOfDP8nS4fVp52w6KOUvQ1iEhEBaOlQVKENJ6jfbSYCoYe4JGK/UeGCaVhjZPpe8L9nVjn2QYfe6e/p1TxRk1MFe6LgrpQXR8SzEJ71+X6j+pRvP8Ui8W1M88esq+ZqbjjIpAxR9ISmd/aTM7WGa7OLOXxDsWQDBAH7J/86u4P1Zebs6vFgORM+RUc2PFAOMSEQ2Ak0UlhX9FrqoK9plol7x9m8aQAj0Sd89lMiCDTgVbk8DSZA4qT5lnYzqZYAvg9XWItCLkeM+C05P7748=",
        "uuid": "32274de3-6efe-45b3-86a8-46c4335ffeb7"
    }

Password (OpenStack Metadata API)

Configures and displays the password for logging in to an ECS.

  • URI

    /169.254.169.254/openstack/{version}/password

  • Usage method

    Supports both GET and POST requests, where

    • The GET request is used to obtain the password.
    • The POST request is used to store the password. Exercise caution when sending a POST request.
  • Examples
    • Example 1: View the password for logging in to an ECS.

      curl http://169.254.169.254/openstack/latest/password

      v59nTqCebJKtNnDu
    • Example 2: Store the password for logging in to an ECS.

      curl -X POST http://169.254.169.254/openstack/latest/password -d "v59nTqCebJKtNnDu"

User data (OpenStack Metadata API)

Displays ECS user data. The value is configured when you create an ECS. It cannot be changed after the configuration.

  • URI

    /169.254.169.254/openstack/{version}/user_data

  • Usage method

    Supports GET requests.

  • Example

    curl http://169.254.169.254/openstack/latest/user_data

    ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA==

Security Key (OpenStack Metadata API)

Obtains temporary AKs and SKs.

NOTE:
  • If you need to obtain temporary AKs ad SKs on ECSs, authorize the op_svc_ecs account on the IAM service.
  • Temporary AKs and SKs expire an hour later.
  • When using temporary AKs and SKs, add 'X-Security-Token':securitytoken in the message header. securitytoken is the value returned when a call is made to the API.
  • URI

    /openstack/{version}/securitykey

  • Usage method

    Supports GET requests.

  • Examples

    curl http://169.254.169.254/openstack/{version}/securitykey

User Data (EC2 Compatible API)

Displays ECS user data. The value is configured when you create an ECS. It cannot be changed after the configuration.

  • URI

    /169.254.169.254/{version}/meta-data/user-data

  • Usage method

    Supports GET requests.

  • Example

    curl http://169.254.169.254/latest/meta-data/user-data

    ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA==

Ami ID (EC2 Compatible API)

Displays an ECS image ID.

  • URI

    /169.254.169.254/{version}/meta-data/ami-id

  • Usage method

    Supports GET requests.

  • Example

    curl http://169.254.169.254/latest/meta-data/ami-id

    ami-00000003

Ami Launch Index (EC2 Compatible API)

Displays an ECS launching sequence. The value of the first launched ECS is 0.

  • URI

    /169.254.169.254/{version}/meta-data/ami-launch-index

  • Usage method

    Supports GET requests.

  • Example

    curl http://169.254.169.254/latest/meta-data/ami-launch-index

Ami Manifest Path (EC2 Compatible API)

Displays the path where an image list is stored.

  • URI

    /169.254.169.254/{version}/meta-data/ami-manifest-path

  • Usage method

    Supports GET requests.

  • Example

    curl http://169.254.169.254/latest/meta-data/ami-manifest-path

    FIXME

Block Device Mapping (EC2 Compatible API)

Displays the block device of an ECS.

  • URI

    /169.254.169.254/{version}/meta-data/block-device-mapping/ami

  • Usage method

    Supports GET requests.

  • Example

    curl http://169.254.169.254/latest/meta-data/block-device-mapping/ami

    vda

Hostname (EC2 Compatible API)

Displays the name of the host accommodating an ECS. The .novalocal suffix will be added later.

  • URI

    /169.254.169.254/{version}/meta-data/hostname

  • Usage method

    Supports GET requests.

  • Example

    curl http://169.254.169.254/latest/meta-data/hostname

    vm-test.novalocal

Instance ID (EC2 Compatible API)

Displays an ECS ID.

  • URI

    /169.254.169.254/{version}/meta-data/instance-id

  • Usage method

    Supports GET requests.

  • Example

    curl http://169.254.169.254/latest/meta-data/instance-id

    i-00000001

Instance Type (EC2 Compatible API)

Displays an ECS flavor name.

  • URI

    /169.254.169.254/{version}/meta-data/instance-type

  • Usage method

    Supports GET requests.

  • Example

    curl http://169.254.169.254/latest/meta-data/instance-type

    flavor_test

Local IPv4 (EC2 Compatible API)

Displays the fixed IP address of an ECS.

  • URI

    /169.254.169.254/{version}/meta-data/local-ipv4

  • Usage method

    Supports GET requests.

  • Example

    curl http://169.254.169.254/latest/meta-data/local-ipv4

    192.1.1.2

Availability Zone (EC2 Compatible API)

Displays the AZ accommodating an ECS.

  • URI

    /169.254.169.254/{version}/meta-data/placement/availability-zone

  • Usage method

    Supports GET requests.

  • Example

    curl http://169.254.169.254/latest/meta-data/placement/availability-zone

    az1.dc1

Public IPv4 (EC2 Compatible API)

Displays the floating IP address of an ECS.

  • URI

    /169.254.169.254/{version}/meta-data/public-ipv4

  • Usage method

    Supports GET requests.

  • Example

    curl http://169.254.169.254/latest/meta-data/public-ipv4

    46.1.1.2

Public Keys (EC2 Compatible API)

Displays the public key of an ECS.

  • URI

    /169.254.169.254/latest/meta-data/public-keys/0/openssh-key

  • Usage method

    Supports GET requests.

  • Example

    curl http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key

    ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDI5Fw5k8Fgzajn1zJwLoV3+wMP+6CyvsSiIc/hioggSnYu/AD0Yqm8vVO0kWlun1rFbdO+QUZKyVr/OPUjQSw4SRh4qsTKf/+eFoWTjplFvd1WCBZzS/WRenxIwR00KkczHSJro763+wYcwKieb4eKRxaQoQvoFgVjLBULXAjH4eKoKTVNtMXAvPP9aMy2SLgsJNtMb9ArfziAiblQynq7UIfLnN3VclzPeiWrqtzjyOp6CPUXnL0lVPTvbLe8sUteBsJZwlL6K4i+Y0lf3ryqnmQgC21yW4Dzu+kwk8FVT2MgWkCwiZd8gQ/+uJzrJFyMfUOBIklOBfuUENIJUhAB Generated-by-Nova

Reservation ID (EC2 Compatible API)

Displays an ECS reservation ID.

  • URI

    /169.254.169.254/{version}/meta-data/reservation-id

  • Usage method

    Supports GET requests.

  • Example

    curl http://169.254.169.254/latest/meta-data/reservation-id

    r-kso0e196
Registration