From: Konrad Rzeszutek Wilk Date: Tue, 24 Jan 2012 05:10:43 +0000 (-0500) Subject: network-setup: don't create bridge for test=net[|static] bootup option. X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=09b2549d69ca3829e7772a9b1e8679c328fe9724;p=xentesttools%2Fbootstrap.git network-setup: don't create bridge for test=net[|static] bootup option. 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 --- diff --git a/root_image/etc/init.d/primary_network b/root_image/etc/init.d/primary_network index f3b1694..37be553 100755 --- a/root_image/etc/init.d/primary_network +++ b/root_image/etc/init.d/primary_network @@ -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 diff --git a/root_image/etc/init.d/rcS b/root_image/etc/init.d/rcS index a893b5c..c5e03a2 100755 --- a/root_image/etc/init.d/rcS +++ b/root_image/etc/init.d/rcS @@ -122,6 +122,9 @@ if [ $? == 0 ]; then netserver iperf -s -D -w 256000 ;; + netstatic) + netserver + ;; benchmark) if [ -e /test ]; then /test