diff options
author | 2008-08-15 00:10:04 -0400 | |
---|---|---|
committer | 2008-08-15 00:10:04 -0400 | |
commit | b23e2fe13acae1af0e81041ac1299387222011d1 (patch) | |
tree | b113314ee2f28e629dec6e8ca552e812c71a9513 | |
parent | Adding provision for using template files instead of explicitely defining the... (diff) | |
download | clustering-livecd-b23e2fe13acae1af0e81041ac1299387222011d1.tar.gz clustering-livecd-b23e2fe13acae1af0e81041ac1299387222011d1.tar.bz2 clustering-livecd-b23e2fe13acae1af0e81041ac1299387222011d1.zip |
Adding infrastructure for node management automation
- node-manager : this is the script called by dnsmasq (see dhcp-script).
- *-add and *-del files are "modules" which are called by node-manager on addition and deletion of nodes as per dnsmasq.
-rwxr-xr-x | overlay/sys-cluster/beowulf-head/files/c3-add | 31 | ||||
-rwxr-xr-x | overlay/sys-cluster/beowulf-head/files/c3-del | 8 | ||||
-rwxr-xr-x | overlay/sys-cluster/beowulf-head/files/node-manager | 66 | ||||
-rwxr-xr-x | overlay/sys-cluster/beowulf-head/files/torque-add | 7 | ||||
-rwxr-xr-x | overlay/sys-cluster/beowulf-head/files/torque-del | 7 |
5 files changed, 119 insertions, 0 deletions
diff --git a/overlay/sys-cluster/beowulf-head/files/c3-add b/overlay/sys-cluster/beowulf-head/files/c3-add new file mode 100755 index 0000000..71782e9 --- /dev/null +++ b/overlay/sys-cluster/beowulf-head/files/c3-add @@ -0,0 +1,31 @@ +#!/bin/bash + +C3CONF=./c3.conf +TMP=/tmp/$0-$$ +NODES=${TMP}_NODES + +exec > $TMP + +shopt -s xpg_echo + +echo "# This files was automatically created by $PWD/$0 and shouldn't be manually modified unless $0 is disabled." +echo "# This file descriptor is inefficient for the sake of code simplicity" + +# define the cluster +echo "cluster gentoo {" + +# The master node is the first one to be defined...we are the master node: +echo "\t$HOSTNAME" + +# Extract the pre-defined nodes from the existing file +egrep -v -e"({|}|#|$HOSTNAME)" $C3CONF > $NODES +echo "\t$4" >> $NODES +cat $NODES | sort -g + +# End of config file: +echo "}" + +mv $TMP $C3CONF + +rm -f $NODES + diff --git a/overlay/sys-cluster/beowulf-head/files/c3-del b/overlay/sys-cluster/beowulf-head/files/c3-del new file mode 100755 index 0000000..33990ee --- /dev/null +++ b/overlay/sys-cluster/beowulf-head/files/c3-del @@ -0,0 +1,8 @@ +#!/bin/bash + +C3CONF=./c3.conf +TMP=/tmp/$0-$$ + +grep -v $4 $C3CONF > $TMP + +mv $TMP $C3CONF diff --git a/overlay/sys-cluster/beowulf-head/files/node-manager b/overlay/sys-cluster/beowulf-head/files/node-manager new file mode 100755 index 0000000..4b6c9b0 --- /dev/null +++ b/overlay/sys-cluster/beowulf-head/files/node-manager @@ -0,0 +1,66 @@ +#!/bin/bash +# This script is meant to be called automatically by dnsmasq's dhcp-script directive +# but it can also be used to manage the manual insertion and deletion of nodes. +# Make sure dnsmasq doesn't come an play against you though. + +%%MODULESPATH +BEEPS=%%BEEPS + +run_modules(){ + for I in ${MODULESPATH}/*-${COMMAND} + do + $I $@ + done + eval \$BEEP_$COMMAND +} + +# Yes, it's crude but we'll elaborate later on something more functionnal +# ...say something based on Avahi with live beakons +node_is_alive(){ + ping -c 1 -w 1 $HNAME + return $? +} + +# Nodes can either be added or removed. For a thorough description of the mechanism, see +# dnsmasq's manpage section concerning dhcp-script +old_node(){ + if [[ ! node_is_alive ]]; then + shift + $0 del $* + fi +} + +usage(){ + echo "$0 is called as follows:" + echo "$0 <add|del|old> <MAC address> <IP address> <hostname>" +} + +(( $# != 3 )) && { usage; exit 1 }; + +##### Variables ####### +COMMAND=$1 +MACADDR=$2 +IP=$3 +HNAME=$4 + +### Beeps: +PAUSE=20 +START=200 +STOP=2000 +STEP=200 +BEEP_add="$(for I in `seq $START $STEP $STOP`; do echo -n " -f $I -l $PAUSE -r 1 -n"; done)" +BEEP_del="$(for I in `seq $STOP -$STEP $START`; do echo -n " -f $I -l $PAUSE -r 1 -n"; done)" +BEEP_add="beep ${BEEPS_add%%-n}" +BEEP_del="beep ${BEEPS_del%%-n}" + +##### Variables END ### + +if [[ $COMMAND == "old" ]] +then + old_node $@ +else + run_modules $@ +fi + +exit 0 + diff --git a/overlay/sys-cluster/beowulf-head/files/torque-add b/overlay/sys-cluster/beowulf-head/files/torque-add new file mode 100755 index 0000000..73d8957 --- /dev/null +++ b/overlay/sys-cluster/beowulf-head/files/torque-add @@ -0,0 +1,7 @@ +#!/bin/bash +TMP=/tmp/$0-$$ +NODES=$PBS_SERVER_HOME/server_priv/nodes + +echo $4 >> $TMP +cat $TMP | sort -g > $NODES + diff --git a/overlay/sys-cluster/beowulf-head/files/torque-del b/overlay/sys-cluster/beowulf-head/files/torque-del new file mode 100755 index 0000000..09a8935 --- /dev/null +++ b/overlay/sys-cluster/beowulf-head/files/torque-del @@ -0,0 +1,7 @@ +#!/bin/bash +TMP=/tmp/$0-$$ +NODES=$PBS_SERVER_HOME/server_priv/nodes + +grep -v $4 $NODES > $TMP +mv $TMP $NODES + |