Regenerate Nics context from virtual network change

Hello !

I updated the DNS of a virtual network and I’m trying regenerate the context attribute ETHX_DNS on the related NICS, for now I found 2 possibilities :

  • full power off cycle on each vm (which is not convenient for a little dns change)
  • onevm updateconf on each vm, which is pretty long with a lot of vms

I’m using terraform and NETWORK context atttribute is set to YES everywhere. I don’t use VM Templates (because my template is the terraform code).

Is there any way to “bulk regenerate” the network context of my nics ?

Thanks !

Hi @zeylos :smiley:

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.

Best,
Victor.

Hi Victor,

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 :slight_smile:

Thanks for the product ! See ya
Zeylos