Generalize xen network config

Allow dhcp for IP addresses.
dhclient3 bug workaround.
Refactor code to improve network creation logic.

Change-Id: Ia3e2e65bbe8b68cf4832595cb7c283c3dc84db19
diff --git a/tools/xen/templates/interfaces.in b/tools/xen/templates/interfaces.in
index 49c3d68..e315a8c 100644
--- a/tools/xen/templates/interfaces.in
+++ b/tools/xen/templates/interfaces.in
@@ -1,8 +1,15 @@
 auto lo
 iface lo inet loopback
 
-auto eth0
-iface eth0 inet dhcp
+# If eth3 is static, the order should not matter
+# and eth0 will have the default gateway. If not,
+# we probably want the default gateway to be
+# what is on the public interface. Hence changed
+# the order here.
+auto eth3
+iface eth3 inet static
+        address @ETH3_IP@
+        netmask @ETH3_NETMASK@
 
 auto eth1
 iface eth1 inet static
@@ -15,7 +22,5 @@
         address @ETH2_IP@
         netmask @ETH2_NETMASK@
 
-auto eth3
-iface eth3 inet static
-        address @ETH3_IP@
-        netmask @ETH3_NETMASK@
+auto eth0
+iface eth0 inet dhcp