Changes to pl_netinit and pl_sysinit support pxe booting nodes. cluster cluster
authorMarc Fiuczynski <mef@cs.princeton.edu>
Tue, 24 May 2005 16:11:57 +0000 (16:11 +0000)
committerMarc Fiuczynski <mef@cs.princeton.edu>
Tue, 24 May 2005 16:11:57 +0000 (16:11 +0000)
Added dhclient-exit-hooks to write out /etc/planetlab/nfs_server for cluster
nodes and also a fix to add a host route if the default gw router is on the
same link yet its ip address is not on the same subnet as the eth interface.

conf_files/dhclient-exit-hooks [new file with mode: 0644]
conf_files/pl_netinit
conf_files/pl_sysinit

diff --git a/conf_files/dhclient-exit-hooks b/conf_files/dhclient-exit-hooks
new file mode 100644 (file)
index 0000000..739ec2d
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+if [ x$new_planetlab_nfs_cluster_server != x ] ; then
+       echo "$new_planetlab_nfs_cluster_server" > /etc/planetlab/nfs_server
+fi
+
+if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
+     [ x$reason = xBOUND ] || [ x$reason = xREBOOT ] || [ x$reason = xTIMEOUT ] ; then
+    read i0 i1 i2 i3 < \
+        <(IFS=. ; echo $new_ip_address)
+    read m0 m1 m2 m3 < \
+        <(IFS=. ; echo $new_subnet_arg)
+    #realmask="$(($i0 & $m0)).$(($i1 & $m1)).$(($i2 & $m2)).$(($i3 & $m3))"
+    realmask="0"
+    
+    for router in $new_routers; do
+      read i0 i1 i2 i3 < \
+        <(IFS=. ; echo $router)
+      #routermask="$(($i0 & $m0)).$(($i1 & $m1)).$(($i2 & $m2)).$(($i3 & $m3))"
+      routermask="1"
+      if [ "$realmask" != "$routermask" ] ; then
+        route add -host $router gw $new_ip_address $interface
+      fi
+      route add default gw $router
+    done
+fi
index b3934f6..b5851b5 100644 (file)
@@ -208,7 +208,12 @@ find_node_config()
        return 1
     fi
 
-    return 0
+    echo "pl_netinit: using default network configuration from initrd"
+    echo 'IP_METHOD="dhcp"' > $USED_NET_CONF
+    echo 'HOST_NAME="planetlabnode"' >> $USED_NET_CONF
+    echo 'DOMAIN_NAME="localhost"' >> $USED_NET_CONF
+    DEFAULT_NET_CONF=1
+    return 1
 }
 
 
@@ -297,8 +302,11 @@ if [[ "$IP_METHOD" == "dhcp" ]]; then
 
     # setup a dhclient conf file for this device (used to send
     # our hostname to the dhcp server)
-    echo "interface \"$ETH_DEVICE\" {" > $DHCLIENT_CONF_FILE
+    echo "# generated by pl_netinit" > $DHCLIENT_CONF_FILE
+    echo "option planetlab-nfs-cluster-server code 200 = ip-address;" >> $DHCLIENT_CONF_FILE
+    echo "interface \"$ETH_DEVICE\" {" >> $DHCLIENT_CONF_FILE
     echo "send host-name \"$HOST_NAME.$DOMAIN_NAME\";" >> $DHCLIENT_CONF_FILE
+    echo "request subnet-mask,broadcast-address,domain-name,host-name,routers,domain-name-servers,planetlab-nfs-cluster-server;" >> $DHCLIENT_CONF_FILE
     echo "}" >> $DHCLIENT_CONF_FILE
 
     # touch the redhat net device configuration file so 
index 50a6b5c..3e8f6e5 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 echo "pl_sysinit: bringing system online"
 
@@ -44,6 +44,51 @@ for device in $test_devices; do
     fi
 done
 
+echo "pl_sysinit: configuring kernel parameters"
+/sbin/sysctl -e -p /etc/sysctl.conf
+
+echo "pl_sysinit: bringing network online"
+/etc/init.d/pl_netinit
+
+# check for nfs mount
+if [ $mounted -eq 0 -a -f "/etc/planetlab/nfs_server" ]; then
+       echo "pl_sysinit: starting portmap"
+       /sbin/portmap
+       sleep 3
+       nfs_server=$(cat /etc/planetlab/nfs_server)
+       /bin/mount -t nfs -o nfsvers=2 ${nfs_server}:/planetlab/bootcd /usr
+       if [ $? -ne 0 ]; then
+               bash
+       else
+               # it mounted, but we should probably make sure its our boot cd
+               # this can be done by making sure the /pl_version file (on initrd)
+               # matches /usr/isolinux/pl_version
+               cd_version=$(/bin/cat /usr/isolinux/pl_version)
+
+               if [ "$initrd_version" != "$cd_version" ]; then
+                       # eh, wrong cd, keep trying
+                       echo "pl_sysinit: wrong version $initrd_version != $cd_version"
+                       /bin/umount /usr 2>&1 /dev/null
+               else
+                       echo "pl_sysinit: found cd on nfs server and mounted on /usr"
+                       mounted=1
+               fi
+               if [ $mounted -eq 1 ] ; then
+                       read i0 i1 i2 i3 m0 m1 m2 m3 < \
+                               <(IFS=. ; echo $(ifconfig eth0 | sed -ne "s/.*inet addr:\([^ ]*\).*Mask:\([^ ]*\).*/\1.\2/p"))
+                       realaddr="$i0.$i1.$i2.$i3"
+                       mkdir -p /tmp/conffilemount
+                       /bin/mount -t nfs -o nfsvers=2 ${nfs_server}:/planetlab/nodes/${realaddr} /tmp/conffilemount
+                       if [ $? -eq 0 ] ; then
+                               cp /tmp/conffilemount/plnode.txt /tmp
+                       else
+                               /bin/umount /usr 2>&1 /dev/null
+                               mounted=0
+                       fi
+               fi
+       fi
+fi
+
 if [ $mounted -eq 0 ]; then
     echo "pl_sysinit: unable to find boot cdrom, cannot continue."
     # todo: maybe we can put a staticly linked sshd here
@@ -72,9 +117,3 @@ else
     echo "pl_sysinit: unable to create device mapper control node, continuing"
 fi
 
-echo "pl_sysinit: configuring kernel parameters"
-/sbin/sysctl -e -p /etc/sysctl.conf
-
-echo "pl_sysinit: bringing network online"
-/etc/init.d/pl_netinit
-