
#!/bin/sh
# File	cdot_top_test_interclusters.sh
# By	: Maarten.deBoer@Atos.net, 221206
# Subject	: Script to test InterCluster interfaces
PGM=`basename $0|cut -d\. -f1`
VER="0.1"
LOG="${HOME}/log/${PGM}.log"
SSH="/usr/bin/ssh -n"

CLUSTER="nlnaf102"
#NODE="nlnaf102-09"
NODE="nlnaf102-10"
PINGNODE="nlnaf102-05"
PORTA="a108a"
PORTB="a108b"
VLAN="1530"

echo "=============================================="|tee -a ${LOG}
echo "`date` ${PGM} v${VER} started."|tee -a ${LOG}

${SSH} ${CLUSTER} "network interface show -home-node ${NODE} -lif *ic*"|tee -a ${LOG}
DEST_ADDR=`${SSH} ${CLUSTER} "network interface show -home-node ${NODE} -lif ${NODE}_ic1 -field address"|grep ${CLUSTER}|awk '{print $3}'|head -1`

${SSH} ${CLUSTER} "network interface migrate -vserver ${CLUSTER} -lif ${NODE}_ic1 -destination-port ${PORTB}-${VLAN} -destination-node ${NODE}"
echo "InterCluster interface 1 via ${PORTB}"|tee -a ${LOG}
${SSH} ${CLUSTER} "network interface show -home-node ${NODE} -lif *ic*"|tee -a ${LOG}

echo "ping to ${DEST_ADDR}"|tee -a ${LOG}
${SSH} ${CLUSTER} "ping -node ${PINGNODE} -destination ${DEST_ADDR}"|tee -a ${LOG}

${SSH} ${CLUSTER} "network interface show -home-node ${NODE} -lif *ic*"|tee -a ${LOG}
echo "InterCluster interface 1 back via ${PORTA}"|tee -a ${LOG}
${SSH} ${CLUSTER} "network interface migrate -vserver ${CLUSTER} -lif ${NODE}_ic1 -destination-port ${PORTA}-${VLAN} -destination-node ${NODE}"|tee -a ${LOG}

${SSH} ${CLUSTER} "network interface show -home-node ${NODE} -lif *ic*"|tee -a ${LOG}
DEST_ADDR=`${SSH} ${CLUSTER} "network interface show -home-node ${NODE} -lif ${NODE}_ic2 -field address"|grep ${CLUSTER}|awk '{print $3}'|head -1`

${SSH} ${CLUSTER} "network interface migrate -vserver ${CLUSTER} -lif ${NODE}_ic2 -destination-port ${PORTA}-${VLAN} -destination-node ${NODE}"
echo "InterCluster interface 2 via ${PORTA}"|tee -a ${LOG}
${SSH} ${CLUSTER} "network interface show -home-node ${NODE} -lif *ic*"|tee -a ${LOG}

echo "ping to ${DEST_ADDR}"|tee -a ${LOG}
${SSH} ${CLUSTER} "ping -node ${PINGNODE} -destination ${DEST_ADDR}"|tee -a ${LOG}

${SSH} ${CLUSTER} "set -prompt-timestamp none; network interface migrate -vserver ${CLUSTER} -lif ${NODE}_ic2 -destination-port ${PORTB}-${VLAN} -destination-node ${NODE}"|tee -a ${LOG}
echo "InterCluster interface 2 back via ${PORTA}"|tee -a ${LOG}
${SSH} ${CLUSTER} "network interface show -home-node ${NODE} -lif *ic*"|tee -a ${LOG}

echo "`date` ${PGM} v${VER} finished"|tee -a ${LOG}
echo "=============================================="|tee -a ${LOG}
exit 0


