# Metadata

Metadata refers to a collection of essential information about 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 UHost instance's self-information within the host. 

The Metadata Server address for SCloud (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)

| Metadata Items | Description |
| -- | -- |
| /project-id | Project ID |
| /region | Region |
| /zone   | Available Zone |
| /uhost-id  | UHost ID |
| /name | UHost Name |
| /remark | UHost Remarks |
| /tag  | UHost UGroup |
| /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 | System Disk or Not|
| /disks/N/disk-type | Disk Type |
| /disks/N/size | Disk Capacity (GB)|
| /disks/N/drive | Disk Drive Letter |
| /disks/N/encrypted | Encrypted Disk or Not |
| /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

## Integrate with Cloud-Init

The following example shows how to write user-defined data (user-data) to automatically report the host ID to a server (1.2.3.4) once the host is created and available:

```bash
#!/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
```
