Device tagging in OpenStack Nova is a mechanism to communicate to the guest OS the intended usage of virtual network interfaces and disks. For example, if an instance has two virtual network interfaces, one connected to a public network and the other to a private management network, the interfaces can be tagged with ‘pub’ and ‘pvt’ respectively. An application in the guest OS can fetch the tags and provision each interface accordingly.
With python-novaclient, in order to boot an instance with tagged devices, use the tag key in the –nic and –block-device arguments to the nova boot command. For example:
$ nova boot --flavor 1 --image cirros \ --nic net-id=149f5beb-2be5-4be6-9f0e-5290049945ab,tag=pub \ --nic net-id=bda05031-7651-41bd-825c-29ba89a4f08b,tag=pvt \ --block-device \ id=e44d2fee-f3df-4a2c-9e2b-e016855b5522,\ source=volume,dest=volume,bootindex=1,tag=db \ --block-device \ id=6dab970b-3777-4ace-84ee-82829041084e,\ source=volume,dest=volume,bootindex=1,tag=cache \ device-tagging-guest
You can also take a look at the full REST API reference.
As a reminder, an instance can access metadata in two ways. The first is to curl http://169.254.169.254/openstack/latest/meta_data.json. The second is to look on the configdrive under openstack/latest/meta_data.json (if the configdrive is enabled). In the above example, a devices section will appear in the metadata, looking something like this:
"devices": [ { "type": "nic", "bus": "pci", "address": "00:01.0", "mac": "d5:d9:b3:0d:c8:b0", "tags": ["pub"] }, { "type": "nic", "bus": "pci", "address": "00:02.0", "mac": "df:8b:d6:58:9b:b1", "tags": ["pvt"] }, { "type": "disk", "bus": "ide", "address": "0:1", "tags": ["db"] }, { "type": "disk", "bus": "ide", "address": "1:0", "tags": ["cache"] } ]
In the Ocata cycle we plan on implementing attaching tagged interfaces and volumes.
If you’re interested in diving deeper, you can take a look at the full spec as it was approved in Newton, and if you’re really crazy you can search for the review topic in Gerrit.
2 thoughts on “Device tagging, new in Newton”