Metadata
Metadata is a collection of basic information about the UHost cloud host, including host id, configuration, image, ip, etc. All relevant metadata of the instance can be obtained through the metadata server.
Metadata Server
The metadata server is an intranet service. Through this service, you can obtain the self-information of the current cloud host instance within the host.
The metadata server address for UCloud-Global is (consistent across all available zones):
http://100.80.80.80/meta-data/
Metadata Item
(Compared to:http://100.80.80.80/meta-data/latest/uhost (opens in a new tab) )
Metadata Item | Description |
---|---|
/project-id | Project ID |
/region | Region |
/zone | Availability 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 | Network Enhancement Features |
/hotplug | Hot Upgrade Features |
/disks/N/ | (Array) Disk |
/disks/N/disk-id | Disk ID |
/disks/N/name | Disk Name |
/disks/N/is-boot | Is it a System Disk |
/disks/N/disk-type | Disk Type |
/disks/N/size | Disk Capacity (GB) |
/disks/N/drive | Disk Drive |
/disks/N/encrypted | Is it an Encrypted Disk |
/disks/N/backup-type | Backup Type |
/network-interfaces/N/ | (Array) Virtual Network Interface |
/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 when it is an 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
You can obtain the corresponding project information under the relevant directory level of the metadata server through the following command:
[root@192-168-1-1]# curl http://100.80.80.80/meta-data/latest/uhost/uhost-id
uhost-vjfsj2db
You can obtain the corresponding directory hierarchy of the metadata server through the following command:
[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 Cloud-Init
The following example is a piece of user-defined data (user-data) writing method, the purpose of which is to automatically report the host id information to the server (1.2.3.4) after 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