Motivation

In order to support network metadata we have to rely on services, installed in the VM of user. The most common tool for instance initialization is cloud-init. There are set of images supporting it out-of-the-box: https://docs.openstack.org/image-guide/obtain-images.html. It supports several DataStores (from cloud), and as a variant of datasource we can use OpenStack one. It is open source and documented.

Сloud-init OpenStack DataSource requirements

In order to start communication with OpenStack DataSource, cloud-init do some checks of environment:

We can set product_name in smbios for our VMs to tell cloud-init to fire communication with endpoints.


Also we should take into account, that there are an order of DataSource observation inside cloud-init. By default NoCloud (drive we use now) has priority.

Сloud-init OpenStack DataSource endpoints

OpenStack metadata serves several endpoints https://docs.openstack.org/nova/latest/user/metadata.html#metadata-openstack-format:

Those endpoints should be accessible from VM and serve separate information for different VMs.


Cloud-init EC2 DataStore

We can also try to implement EC2-compatible datastore described here: https://docs.openstack.org/nova/latest/user/metadata.html#ec2-compatible-metadata. It will be called in case of image has no OpenStack datasource inside and forced to skip check (Cirros image for example).