network-programmingkvmopennebula

Opennebula VM not persisting network config


I've created a VM with a VNET attached on Opennebula, after a while I changed the params of the VNET but those changes do not persist on the VM after my (physical)host is restarted.

I’ve changed the /var/lib/one/vms/{$VM_ID}/context.sh file but still no luck persisting the changes.

Do you know what it could be?

I'm using OpenNebula with KVM on a Debian8 host.


Solution

  • After a while I figure out how to do this myself.

    It seems that when the VM is started, the file /var/lib/one/datastores/0/$VM_ID/disk.1 is attached as /dev/sr0.

    During boot process /usr/sbin/one-contextd mounts this unit an uses the variables inside it, they usually look like this:

    DISK_ID='1'
    ETH0_IP='192.168.168.217'
    ETH0_MAC='02:00:c0:a8:a8:d9'
    ETH0_DNS='192.168.168.217'
    ETH0_GATEWAY='192.168.168.254'
    

    This info are used to export ENV variables (the exported variables can be found on /tmp/one_env) which are used by the script /etc/one-context.d/00-network to set network configuration.

    OpenNebula doesn't provide a simple way of replacing this configs after the VM is created, but you can do the following:

    Hope this is useful to someone :)