Retrieving Metadata

Introduction

The BMS metadata includes BMS basic information on the cloud platform, such as the BMS ID, hostname, and network information. The BMS metadata can be retrieved using compatible OpenStack and EC2 APIs listed in Table 1.

Table 1 BMS metadata types

Metadata Type

Metadata Item

Description

OpenStack type

/meta_data.json

This interface is used to query BMS metadata.

For the key fields in the BMS metadata, see Table 2.

/password

This interface is used to query the BMS password.

If a key pair is selected during the creation of a Windows BMS, Cloudbase-Init is used to save the ciphertext password when the BMS is initialized.

/user_data

This interface is used to query BMS user data.

This metadata allows you to specify scripts and configuration files for initializing BMSs. For details, see Injecting User Data.

For password-authenticated Linux BMSs, save the password injection script.

/network_data.json

This interface is used to query network information of a BMS.

/securitykey

This interface is used to obtain temporary security credentials: Access Key ID (AK) and Secret Access Key (SK).

Before obtaining temporary AK/SK on a BMS, you need to create an agency for BMS on IAM and assign required resource permissions to BMS.

EC2 type

/meta-data/hostname

This interface is used to query the host name of a BMS.

To remove the suffix .novalocal from a BMS, see:

Is the BMS Host Name with Suffix novalocal Normal?

/meta-data/instance-type

This interface is used to query the flavor name of a BMS.

/meta-data/local-ipv4

This interface is used to query the fixed IP address of a BMS.

If there are multiple NICs, only the IP address of the primary NIC is displayed.

/meta-data/placement/availability-zone

This interface is used to query AZ information about a BMS.

/meta-data/public-ipv4

This interface is used to query the EIP of a BMS.

If there are multiple NICs, only the EIP of the primary NIC is displayed.

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

This interface is used to query the public key of a BMS.

/user-data

This interface is used to query BMS user data.

/meta-data/security-groups

This interface is used to query the name of the security group of the BMS.

Table 2 Metadata key fields

Parameter

Type

Description

uuid

String

Specifies the BMS ID.

availability_zone

String

Specifies the AZ where the BMS is located.

meta

Dict

Specifies the metadata information, including the image name, image ID, and VPC ID.

hostname

String

Specifies the hostname of the BMS.

To remove the suffix .novalocal from a BMS, see:

Is the BMS Host Name with Suffix novalocal Normal?

vpc_id

String

Specifies the ID of the VPC where the BMS is located.

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

Prerequisites

Metadata (OpenStack Metadata API)

This interface is used to query BMS metadata.

User Data (OpenStack Metadata API)

This interface is used to query BMS user data. The value is configured when you create a BMS. It cannot be changed after the configuration.

Network Data (OpenStack Metadata API)

This interface is used to query network information of a BMS.

Security Key (OpenStack Metadata API)

This interface is used to obtain temporary security credentials: Access Key ID (AK) and Secret Access Key (SK).

  • To obtain temporary AK/SK on a BMS, you need to create an agency for BMS on IAM and assign required resource permissions to BMS.
  • The temporary AK/SK pair expires an hour later but is updated 10 minutes ahead of the expiration time. During the 10 minutes, both the new and old temporary AK/SK pairs can be used.
  • When using temporary AK/SK, add 'X-Security-Token':securitytoken in the message header. securitytoken is the value returned when a call is made to the API.

User Data (EC2 Compatible API)

This interface is used to query BMS user data. The value is configured when you create a BMS. It cannot be changed after the configuration.

Hostname (EC2 Compatible API)

This interface is used to query the name of the host accommodating a BMS. The .novalocal suffix will be added later.

Instance Type (EC2 Compatible API)

This interface is used to query the flavor name of a BMS.

Local IPv4 (EC2 Compatible API)

This interface is used to query the fixed IP address of a BMS. If there are multiple NICs, only the IP address of the primary NIC is displayed.

Availability Zone (EC2 Compatible API)

This interface is used to query AZ information about a BMS.

Public IPv4 (EC2 Compatible API)

This interface is used to query the EIP of a BMS. If there are multiple NICs, only the EIP of the primary NIC is displayed.

Public Keys (EC2 Compatible API)

This interface is used to query the public key of a BMS.