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:
- Edit
/var/lib/one/datastores/0/$VM_ID/disk.1
and make the required
changes
- Restart opennebula service
- Restart the VM
Hope this is useful to someone :)