OpenNebula / one-apps

Toolchain to build OpenNebula appliances
Apache License 2.0
12 stars 10 forks source link

Add contextualization options for allowing 'Q in Q' openvswitch networks #59

Open brodriguez-opennebula opened 6 months ago

brodriguez-opennebula commented 6 months ago

When openvswitch is configured to set up Q in Q, the network interfaces of the VMs need to be configured as a regular VLAN interface. This can be overridden with some tricks in the context of the VM, for instance setting up a variable composed with at tuple interface, VLAN id, IP address, netmask separated by ;

VLAN_IFACES="eth1,120,10.120.1.5,24;eth1,130,10.130.1.5,24"

And then modifying the init script, with

source /var/run/one-context/context.sh.local

for vlan_info in $(echo $VLAN_IFACES | tr ";" "\n"); do 
  IFS=, read -r iface vlan addr mask <<< $vlan_info; 
  ip link add link $iface name $iface.$vlan type vlan id $vlan; 
  ip addr add $addr/$mask dev $iface.$vlan; 
  ip link set dev $iface.$vlan up;  
done

Anyways, this could be a bit less tricky if it was set as a contextualization option