root / trunk / shell / stop-compute-node @ 21
Historique | Voir | Annoter | Télécharger (1,56 ko)
| 1 | 3 | storres | #! /bin/bash |
|---|---|---|---|
| 2 | 3 | storres | # |
| 3 | 3 | storres | # Stop and delete a node |
| 4 | 3 | storres | # |
| 5 | 3 | storres | # Get the directory of the script. |
| 6 | 3 | storres | SCRIPT_PATH=`dirname $0` |
| 7 | 3 | storres | # Get the script name. |
| 8 | 3 | storres | SCRIPT_NAME=`basename $0` |
| 9 | 3 | storres | if [ "x$1" == "x" ] |
| 10 | 3 | storres | then |
| 11 | 3 | storres | echo |
| 12 | 3 | storres | echo Missing parametre. Aborting! |
| 13 | 3 | storres | echo |
| 14 | 3 | storres | echo Usage: $SCRIPT_NAME node_number |
| 15 | 3 | storres | echo |
| 16 | 3 | storres | exit 1 |
| 17 | 3 | storres | else |
| 18 | 3 | storres | NODE_NUMBER=$(($1)) |
| 19 | 3 | storres | NODE_NUMBER_STRING=$NODE_NUMBER |
| 20 | 3 | storres | while [ ${#NODE_NUMBER_STRING} -lt 3 ]
|
| 21 | 3 | storres | do |
| 22 | 3 | storres | NODE_NUMBER_STRING="0$NODE_NUMBER_STRING" |
| 23 | 3 | storres | done |
| 24 | 3 | storres | fi |
| 25 | 3 | storres | # Source the common configuration variables. |
| 26 | 3 | storres | . $SCRIPT_PATH/c-i-a-b.common |
| 27 | 3 | storres | # |
| 28 | 3 | storres | # Check that the virtual machine exists. |
| 29 | 3 | storres | # |
| 30 | 3 | storres | CURRENT_HOST_NAME=${COMPUTE_NODE_NAME_PREFIX}${NODE_NUMBER_STRING}
|
| 31 | 3 | storres | IS_RUNNING=`xm list | grep $CURRENT_HOST_NAME` |
| 32 | 3 | storres | if [ -z "$IS_RUNNING" ] |
| 33 | 3 | storres | then |
| 34 | 3 | storres | echo |
| 35 | 3 | storres | echo The \"$CURRENT_HOST_NAME\" domU does not exist. Aborting! |
| 36 | 3 | storres | echo |
| 37 | 3 | storres | exit 1 |
| 38 | 3 | storres | fi |
| 39 | 3 | storres | # |
| 40 | 3 | storres | # Stop the virutal machine |
| 41 | 3 | storres | # |
| 42 | 3 | storres | xm shutdown $CURRENT_HOST_NAME |
| 43 | 3 | storres | IS_RUNNING=1 |
| 44 | 3 | storres | while [ -n "$IS_RUNNING" ] |
| 45 | 3 | storres | do |
| 46 | 3 | storres | IS_RUNNING=`xm list | grep $CURRENT_HOST_NAME` |
| 47 | 3 | storres | echo waiting for $CURRENT_HOST_NAME to shutdown... |
| 48 | 3 | storres | sleep 4 |
| 49 | 3 | storres | done |
| 50 | 3 | storres | |
| 51 | 3 | storres | # If necessary, unmount the mounted disks |
| 52 | 3 | storres | if [ -f $COMPUTE_NODE_DISK_MOUNT_POINT/etc/network/interfaces ] |
| 53 | 3 | storres | then |
| 54 | 3 | storres | umount -f $COMPUTE_NODE_DISK_MOUNT_POINT |
| 55 | 3 | storres | fi |
| 56 | 3 | storres | # Delete the swap disk. |
| 57 | 3 | storres | COMPUTE_NODE_SWAP_DISK="${SWAP_DISK_PREFIX}${NODE_NUMBER_STRING}${SWAP_DISK_POSTFIX}"
|
| 58 | 3 | storres | lvremove -f $SWAP_DISK_LOGICAL_VOLUME/$COMPUTE_NODE_SWAP_DISK |
| 59 | 3 | storres | # Delete the system disk |
| 60 | 3 | storres | COMPUTE_NODE_SYSTEM_DISK="${SYSTEM_DISK_CLONE_PREFIX}${NODE_NUMBER_STRING}${SYSTEM_DISK_CLONE_POSTFIX}"
|
| 61 | 3 | storres | lvremove -f $SYSTEM_DISK_LOGICAL_VOLUME/$COMPUTE_NODE_SYSTEM_DISK |