Metadata
Metadata refers to a collection of essential information about a cloud host UHost, including host id, configuration, imaging, ip, etc. All related metadata of an instance can be acquired through a metadata server.
Metadata Server
The metadata server is an intranet service. It allows retrieval of the current cloud host instance's self-information within the host.
The Metadata Server address for SurferCloud (consistent across all available zones) is:
http://100.80.80.80/meta-data/
Metadata Items
(Relative to: http://100.80.80.80/meta-data/latest/uhost (opens in a new tab))
Metadata Items | Description |
---|---|
/project-id | Project ID |
/region | Region |
/zone | Available Zone |
/uhost-id | UHost ID |
/name | UHost Name |
/remark | UHost Remark |
/tag | UHost Business Group |
/image-id | Image ID |
/os-name | Image Operating System Name |
/machine-type | Machine Type |
/cpu | Number of CPUs |
/memory | Memory Capacity (MB) |
/gpu | Number of GPUs |
/isolation-group | Hardware Isolation Group ID |
/net-capability | Enhanced Network Feature |
/hotplug | Hot Upgrade Feature |
/disks/N/ | (Array) Disk |
/disks/N/disk-id | Disk id |
/disks/N/name | Disk Name |
/disks/N/is-boot | Is System Disk |
/disks/N/disk-type | Disk Type |
/disks/N/size | Disk Capacity (GB) |
/disks/N/drive | Disk Drive Letter |
/disks/N/encrypted | Is Encrypted Disk |
/disks/N/backup-type | Backup Type |
/network-interfaces/N/ | (Array) Virtual Network Interface Cards |
/network-interfaces/N/vpc-id | VPC ID |
/network-interfaces/N/subnet-id | Subnet ID |
/network-interfaces/N/mac | MAC Address |
/network-interfaces/N/ips/N/ | (Array) IP Address |
/network-interfaces/N/ips/N/ip-id | (Only valid for EIP) EIP ID |
/network-interfaces/N/ips/N/ip-address | IP Address |
/network-interfaces/N/ips/N/type | IP Type |
/network-interfaces/N/ips/N/width | Bandwidth Size (MB) |
View Metadata
The following command can be used to obtain corresponding project information under the related directory level of the metadata server:
[root@192-168-1-1]# curl http://100.80.80.80/meta-data/latest/uhost/uhost-id
uhost-vjfsj2db
The following command can be used to obtain the corresponding directory level of the metadata server:
[root@192-168-1-1]# curl http://100.80.80.80/meta-data/latest/uhost/disks/0/
/backup-type
/encrypted
/disk-id
/disk-type
/drive
/is-boot
/name
/size
Combining with Cloud-Init
The following example shows the writing of user-defined data (user-data) with the objective of automatically reporting host id information to the server (1.2.3.4) once the host is created and available:
#!/bin/sh
md=http://100.80.80.80/meta-data/v1
myserver=http://1.2.3.4/
ID=$(curl -s $md/instance-id)
curl -s $myserver/?id=$ID