2008-06-20 17:51:55 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
|
|
|
|
|
|
|
|
##########################################################################################
|
|
|
|
# This script is used for RMC node configuration
|
|
|
|
# usage:
|
|
|
|
# To add node to the cluster:
|
2008-06-24 20:45:27 +00:00
|
|
|
# NODE=nodename NODEID=fbb5ec1f64dd299c \
|
2008-08-06 18:14:52 +00:00
|
|
|
# MONMASTER=msname_or_ip MS_NODEID=fbb5ec1f64dd299c \
|
2008-06-20 17:51:55 +00:00
|
|
|
# configrmcnode 1
|
|
|
|
# To remove node to the cluster
|
|
|
|
# NODE=nodename configrmcnode -1
|
|
|
|
##########################################################################################
|
2008-06-25 14:50:11 +00:00
|
|
|
if [ -n "$1" ]; then
|
|
|
|
ADD=$1
|
|
|
|
else
|
|
|
|
ADD=1
|
|
|
|
fi
|
2008-06-20 17:51:55 +00:00
|
|
|
|
2008-10-17 13:41:14 +00:00
|
|
|
if [ -z "$NODE" ]; then
|
|
|
|
NODE=`hostname`
|
|
|
|
fi
|
|
|
|
|
2008-08-06 18:14:52 +00:00
|
|
|
logger xCAT "configrmcnode: ADD=$ADD, NODE=$NODE, NODEID=$NODEID MONMASTER=$MONMASTER,MS_NODEID=$MS_NODEID"
|
2008-06-20 17:51:55 +00:00
|
|
|
|
|
|
|
#check if rsct is installed and running
|
|
|
|
if [ ! -e /usr/bin/lsrsrc ]; then
|
2008-08-06 18:14:52 +00:00
|
|
|
echo "RMC setup on node $NODE: RSCT is not is not installed."
|
2008-06-20 17:51:55 +00:00
|
|
|
logger xCAT "RMC setup on node $NODE: RSCT is not is not installed."
|
|
|
|
exit 1;
|
|
|
|
fi
|
2008-08-06 18:14:52 +00:00
|
|
|
|
|
|
|
#check if the resource is defined
|
|
|
|
result=`/usr/bin/lsrsrc-api -s IBM.MCP::"NodeID=0x$MS_NODEID"::MNName 2>&1`
|
|
|
|
if [ $? -gt 0 ]; then
|
|
|
|
# echo $result
|
|
|
|
p="2612-023" #resource not found
|
|
|
|
result1=`awk -v a="$result" -v b="$p" 'BEGIN{print index(a,b)}'`
|
|
|
|
if [ $result1 -gt 0 ]; then
|
|
|
|
if [ $ADD -eq -1 ]; then
|
|
|
|
exit 0; #resource already removed, do nothing
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "$result"
|
|
|
|
logger xCAT "$result"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ $ADD -eq 1 ]; then
|
|
|
|
exit 0; #resource already defined, do nothing
|
|
|
|
fi
|
|
|
|
fi
|
2008-06-24 20:45:27 +00:00
|
|
|
|
|
|
|
#ask RMC take the new nodeid
|
|
|
|
if [[ $NODEID != "" ]]; then
|
2008-08-06 18:14:52 +00:00
|
|
|
oldid=`/usr/sbin/rsct/bin/lsnodeid`
|
|
|
|
oldidU=`echo "$oldid" | awk '{ print toupper($1) }'`
|
|
|
|
newidU=`echo "$NODEID" | awk '{ print toupper($1) }'`
|
|
|
|
if [ $oldidU != $newidU ]; then
|
|
|
|
if [ -e /usr/sbin/rsct/install/bin/recfgctnid ]; then
|
|
|
|
result=`/usr/sbin/rsct/install/bin/recfgctnid $NODEID 2>&1`
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Reset nodeid: $result"
|
|
|
|
logger xCAT "Reset nodeid: $result"
|
|
|
|
fi
|
2008-06-27 14:35:20 +00:00
|
|
|
else
|
2008-08-06 18:14:52 +00:00
|
|
|
#stop all rmc daemons
|
|
|
|
/usr/sbin/rsct/bin/rmcctrl -z
|
2008-06-27 14:35:20 +00:00
|
|
|
|
2008-08-06 18:14:52 +00:00
|
|
|
#get new nodeid into id files
|
|
|
|
if [ -e /var/ct/cfg/ct_node_id ]; then
|
|
|
|
sed s/^[^\#].*$/$NODEID/ /var/ct/cfg/ct_node_id > /tmp/id.tmp
|
|
|
|
else
|
|
|
|
if [ -e /etc/ct_node_id ]; then
|
|
|
|
sed s/^[^\#].*$/$NODEID/ /etc/ct_node_id > /tmp/id.tmp
|
|
|
|
else
|
|
|
|
echo $NODEID > /tmp/id.tmp
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
cp /tmp/id.tmp /var/ct/cfg/ct_node_id
|
|
|
|
cp /tmp/id.tmp /etc/ct_node_id
|
|
|
|
rm /tmp/id.tmp
|
|
|
|
|
|
|
|
#reconfig RMC
|
|
|
|
result=`/usr/sbin/rsct/install/bin/recfgct -s 2>&1`
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "RMC setup on node $NODE: Cannot reconfig RSCT with new node id"
|
|
|
|
logger xCAT "RMC setup on node $NODE: Cannot reconfig RSCT with new node id"
|
|
|
|
fi
|
|
|
|
fi
|
2008-06-24 20:45:27 +00:00
|
|
|
fi
|
|
|
|
fi
|
2008-06-20 17:51:55 +00:00
|
|
|
|
|
|
|
PID=`/bin/ps -ef | /bin/grep rmcd | /bin/grep -v grep | /bin/awk '{print $2}'`
|
|
|
|
if [ !$PID ]; then
|
|
|
|
#restart rmc daemon
|
|
|
|
result=`startsrc -s ctrmc 2>&1`;
|
|
|
|
if [ $? -gt 0 ]; then
|
2008-08-06 18:14:52 +00:00
|
|
|
echo "RMC deamon cannot be started on node $NODE:$result"
|
2008-06-20 17:51:55 +00:00
|
|
|
logger xCAT "RMC deamon cannot be started on node $NODE:$result"
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ $ADD -eq 1 ]; then
|
2008-06-24 20:45:27 +00:00
|
|
|
#enable remote client connection
|
|
|
|
/usr/bin/rmcctrl -p; /usr/bin/refrsrc IBM.MCP
|
|
|
|
|
|
|
|
#get IP address of MS
|
2008-08-06 18:14:52 +00:00
|
|
|
ms_ip=$MONMASTER
|
|
|
|
result=`ping -c1 $MONMASTER 2>&1`
|
2008-06-24 20:45:27 +00:00
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
index1=`expr index "$result" "\("`
|
|
|
|
index2=`expr index "$result" "\)"`
|
2008-06-27 04:26:52 +00:00
|
|
|
#ms_ip=${result:$index1+1:$index2-$index1-2}
|
|
|
|
pos=`expr $index1 + 1`
|
|
|
|
length=`expr $index2 - $index1`
|
2008-06-27 14:35:20 +00:00
|
|
|
length=`expr $length - 1`
|
2008-06-27 04:26:52 +00:00
|
|
|
ms_ip=`expr substr "$result" $pos $length`
|
2008-06-24 20:45:27 +00:00
|
|
|
else
|
2008-08-06 18:14:52 +00:00
|
|
|
echo "RMC setup on node $NODE:$result"
|
2008-06-24 20:45:27 +00:00
|
|
|
logger xCAT "RMC setup on node $NODE:$result"
|
|
|
|
fi
|
|
|
|
|
2008-06-20 17:51:55 +00:00
|
|
|
#define resource in IBM.MCP class on node
|
2008-08-06 18:14:52 +00:00
|
|
|
result1=`/usr/bin/mkrsrc-api IBM.MCP::MNName::"$NODE"::KeyToken::"$MONMASTER"::IPAddresses::"{\"$ms_ip\"}"::NodeID::0x$MS_NODEID 2>&1`
|
2008-06-20 17:51:55 +00:00
|
|
|
if [ $? -gt 0 ]; then
|
2008-08-06 18:14:52 +00:00
|
|
|
echo "Define resource in IBM.MCP class on node $NODE. result=$result1"
|
2008-06-21 21:12:33 +00:00
|
|
|
logger xCAT "Define resource in IBM.MCP class on node $NODE. result=$result1"
|
2008-06-20 17:51:55 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2008-06-21 21:12:33 +00:00
|
|
|
|
2008-06-20 17:51:55 +00:00
|
|
|
#TODO: create predefined sensors
|
|
|
|
else
|
|
|
|
#remove resource in IBM.MCP class on the node
|
2008-08-06 18:14:52 +00:00
|
|
|
result2=`/usr/bin/rmrsrc-api -s IBM.MCP::"NodeID=0x$MS_NODEID" 2>&1`
|
2008-06-20 17:51:55 +00:00
|
|
|
if [ $? -gt 0 ]; then
|
2008-08-06 18:14:52 +00:00
|
|
|
echo "Remove resource in IBM.MCP class on noderesult=$result2"
|
2008-06-20 17:51:55 +00:00
|
|
|
logger xCAT "Remove resource in IBM.MCP class on noderesult=$result2"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
exit 0;
|
|
|
|
|
|
|
|
|