The are 2 situations when the VM contextualization CD-ROM is refreshed – when OpenNebula boots the VM and on NIC hot-attach.
We assume you have already made your changes in the VNET template.
1. ONE VM boot
If you are able to do a quick maintenance on the affected VMs, the easiest solution is to put the VMs into poweroff state (onevm poweroff $VMID) and boot them again (onevm resume $VMID). It’s not enough to do a reboot initiated from inside the operating system of VM, the VM has to go through the OpenNebula state BOOT.
2. Dummy NIC hot-attach
You can create a dedicated single-purpose ONE vnet and hot-attach NIC from this network to each affected running VM one by one. The parameters of the network aren’t very important, but needs to be valid (i.e. valid bridge). If NIC is attached successfully to the VM, the OpenNebula refreshes the contextualization CD-ROM and udev hooks trigger network reconfiguration inside the VM. You can detach the NIC right after the requested change is applied.
NOTE: You can detach and attach the current NIC that the VM has, but keep in mind that the IP may change. So we recommend using a dummy NIC like the one we propose. Network contextualization is triggered for all NICs when a network value changes, regardless of the affected NIC.
Workaround
Another option is, instead of having the context update naturally within OpenNebula’s operating cycles, is to manually force it to update. To achieve that, you can go inside the VM through ssh or vnc and execute the following command: DEBUG=1 /usr/sbin/one-contextd all force it will force the execution of the context scripts and will show a debug log so you can check that everything goes well.
Thanks for the detailed answer, it’s very appreciated ! I can confirm attaching a dummy nic does refresh the ETHX context instantly, I’ll prepare a little script to do that in bulk on multiple vms.
If that’s possible, I’d like to add to my demand a feature request to regenerate the network context vars from the ONE frontend with the onevm binary for example, that’d be great !
About the DEBUG=1 /usr/sbin/one-contextd all force though, it does re-play the contextualization scripts but it doesn’t refresh the network variables. Although thanks for the tip because I was using the systemd one-context-force unit to do that for now and I was looking for a way to have debug logs