]> xenbits.xensource.com Git - xentesttools/bootstrap.git/commitdiff
network-setup: don't create bridge for test=net[|static] bootup option.
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tue, 24 Jan 2012 05:10:43 +0000 (00:10 -0500)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Wed, 25 Jan 2012 03:06:53 +0000 (22:06 -0500)
The test=net will setup DHCP entries for up to two ethX interfaces.
The test=netstatic will read the MAC address and from xx:xx:xx:xx:QQ:ZZ
set $QQ.0.0.$ZZ.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
root_image/etc/init.d/primary_network
root_image/etc/init.d/rcS

index f3b1694d4168d5342ff2dbef079be17282185aba..37be55356faa68309b7a13926a1be0080b3e0438 100755 (executable)
@@ -1,5 +1,7 @@
 #!/bin/bash
 
+. /etc/init.d/functions
+
 function create_bridge() {
 
        local name=$1
@@ -36,13 +38,75 @@ function create_bridge_if() {
                echo "BOOTPROTO=dhcp" >> $FILE
                COUNT=$(($COUNT+1))
                # We only want at max two DHCP interfaces.
+               # switch and ethX
                if [ $COUNT -ge 1 ]; then
                        break;
                fi
        done
 }
+function create_dhcp_if() {
+
+       COUNT=0
+       NICS=`ls -1 /sys/class/net/ | grep -v lo | grep -v sit`
+       # The rest
+       for NIC in $NICS
+       do
+               FILE=/etc/sysconfig/network-scripts/ifcfg-$NIC
+               echo "DEVICE=$NIC" > $FILE
+               echo "ONBOOT=yes" >> $FILE
+               echo "BOOTPROTO=dhcp" >> $FILE
+               COUNT=$(($COUNT+1))
+               # We only want at max two DHCP interfaces.
+               if [ $COUNT -ge 2 ]; then
+                       break;
+               fi
+       done
+}
+function create_static_if() {
 
+       COUNT=0
+       NICS=`ls -1 /sys/class/net/ | grep -v lo | grep -v sit`
+       # The rest
+       for NIC in $NICS
+       do
+               X=`cat /sys/class/net/$NIC/address | sed 's/.*\(..\)$/\1/'`
+               Y=`cat /sys/class/net/$NIC/address | sed 's/.*\(..\):..$/\1/'`
+               let I=0x$X
+               let J=0x$Y
+
+               # So xx:xx:xx:xx:10:01 will mean I=10, J=01
+               FILE=/etc/sysconfig/network-scripts/ifcfg-$NIC
+               echo "DEVICE=$NIC" > $FILE
+               echo "ONBOOT=yes" >> $FILE
+               echo "BOOTPROTO=static" >> $FILE
+               echo "IPADDR=$J.0.0.$I" >> $FILE
+               echo "GATEWAY=$J.0.0.1" >> $FILE
+               echo "NETMASK=255.255.255.0" >> $FILE
+               echo "DNS_1=$J.0.0.1" >> $FILE
+               echo "NM_CONTROLLED=no" >> $FILE
+               COUNT=$(($COUNT+1))
+               # We only want at max two interfaces.
+               if [ $COUNT -ge 2 ]; then
+                       break;
+               fi
+       done
+}
 mkdir -p /etc/sysconfig
 echo "NETWORKING=yes" > /etc/sysconfig/network
-create_bridge_if switch
+
+NETWORK_SETUP_DONE=0
+
+TEST=$(boot_parameter 'test')
+if [ $? == 0 ]; then
+       case "$TEST" in
+               netstatic)
+                       create_static_if
+                       ;;
+               net)
+                       create_dhcp_if
+                       ;;
+       esac
+else
+       create_bridge_if switch
+fi
 /etc/init.d/network start
index a893b5cbaee1eb8405e5f4116a202a95c8bcf8f0..c5e03a2f50471f78e27320ff00a997907b86025c 100755 (executable)
@@ -122,6 +122,9 @@ if [ $? == 0 ]; then
                        netserver
                        iperf -s -D -w 256000
                        ;;
+               netstatic)
+                       netserver
+                       ;;
                benchmark)
                        if [ -e /test ]; then
                                /test