Custom routes for VMs

Hi,
I’m trying to generate a “/etc/sysconfig/network-scripts/route-eth0” to add custom routes to my VM. The reason why I need to do this, is simply because we have 2 sets of FW/Routers. 1 is the public firewall, 2 is the internal firewall providing network access to private subnets.
The way I was hoping to achieve this is by adding a custom attribute named “INTERNAL_GATEWAY” (in this case 10.4.4.4) to the virtual network. And using the the START_SCRIPT in the VM template, I would populate the file like this:

# File generated by opennebula
10.0.0.0/8 via 10.4.4.4
192.168.0.0/16 via 10.4.4.4

I was trying to access the network templates values from the start script but it doesn’t seem possible as $NETWORK is empty. I also tried to create a custom var in the VM template like this
INTERNAL_GATEWAY=$NETWORK[INTERNAL_GATEWAY, NETWORK_ID=$NIC[NETWORK_ID]]
but is seems the nested variables are not supported, see the following error:

one.template.instantiate result FAILURE [one.template.instantiate] Error allocatin
g a new virtual machine template. Error parsing: DISK_ID=1@^_^@INTERNAL_GATEWAY=$NETWORK[INTERNAL_GATEWAY, NETWORK_ID=$NIC[NETWORK_ID]]
@^_^@NETWORK=YES... syntax error, unexpected OBRACK
ET, expecting CBRACKET at line 1869902689, columns 74:75

What would be way to achieve what I am trying to do here ?

Thank you


**Versions of the related components and OS (frontend, hypervisors, VMs): 5.4.13 **

I found how to do this, but I believe the instructions on how to do this should be included relevant sections like this one: http://docs.opennebula.org/5.0/operation/network_management/manage_vnets.html

I found the info here: https://github.com/OpenNebula/one/issues/959

A workaround, probably not the most elegant one, would be this:

In the OS template used to instantiate a new VM, go to the Context section and there, in the startup script do something like:

cat > /etc/sysconfig/network-scripts/route-eth <<EOF
# File generated by opennebula
10.0.0.0/8 via 10.4.4.4
192.168.0.0/16 via 10.4.4.4
EOF

Click Update. Now, the newly deployed VMS, using the above mentioned template, will have this as default.

What I’m usually doing is this. Deploy a new VM from a standard template, customizing that VM the way I like or need, updating all the packages, add/create any custom configuration that I need. When I’m done with that VM, I power it off, save it as a template and then I deploy the new virtual machines from that template (saves time and I have it customized the way I like or need).

Hope it helps!

Thx for the tips. Works well !