From 10ad3b6945840ff4714314787bf1b7dfdc0debe3 Mon Sep 17 00:00:00 2001 From: linggao Date: Wed, 13 Mar 2013 19:05:27 +0000 Subject: [PATCH] fix sf bug #3422 updatenode -P fails to resolve name of mypostscript file on the MN git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@15484 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- .../share/xcat/install/scripts/post.debian | 2 - .../xcat/install/scripts/post.rhel5.s390x | 2 - .../xcat/install/scripts/post.rhel6.s390x | 2 - .../xcat/install/scripts/post.sles10.s390x | 2 - .../xcat/install/scripts/post.sles11.s390x | 2 - .../share/xcat/install/scripts/post.ubuntu | 2 - .../share/xcat/install/scripts/post.xcat | 2 - xCAT/postscripts/xcatdsklspost | 82 +++++++++---------- 8 files changed, 39 insertions(+), 57 deletions(-) diff --git a/xCAT-server/share/xcat/install/scripts/post.debian b/xCAT-server/share/xcat/install/scripts/post.debian index 740185945..08dea2719 100644 --- a/xCAT-server/share/xcat/install/scripts/post.debian +++ b/xCAT-server/share/xcat/install/scripts/post.debian @@ -90,8 +90,6 @@ do touch /opt/xcat/xcatinfo fi echo "XCATSERVER=$i" > /opt/xcat/xcatinfo - NODE=#TABLE:nodelist:THISNODE:node# - echo "NODE=$NODE" >> /opt/xcat/xcatinfo break fi RAND=$(perl -e 'print int(rand(5)). "\n"') diff --git a/xCAT-server/share/xcat/install/scripts/post.rhel5.s390x b/xCAT-server/share/xcat/install/scripts/post.rhel5.s390x index 26fc7fbf9..9f30feaaf 100644 --- a/xCAT-server/share/xcat/install/scripts/post.rhel5.s390x +++ b/xCAT-server/share/xcat/install/scripts/post.rhel5.s390x @@ -83,8 +83,6 @@ do fi echo "XCATSERVER=$i" > /opt/xcat/xcatinfo echo "REBOOT=TRUE" >> /opt/xcat/xcatinfo - NODE=#TABLE:nodelist:THISNODE:node# - echo "NODE=$NODE" >> /opt/xcat/xcatinfo break fi RAND=$(perl -e 'print int(rand(5)). "\n"') diff --git a/xCAT-server/share/xcat/install/scripts/post.rhel6.s390x b/xCAT-server/share/xcat/install/scripts/post.rhel6.s390x index 2ec7f9963..61ce1477a 100644 --- a/xCAT-server/share/xcat/install/scripts/post.rhel6.s390x +++ b/xCAT-server/share/xcat/install/scripts/post.rhel6.s390x @@ -82,8 +82,6 @@ do touch /opt/xcat/xcatinfo fi echo "XCATSERVER=$i" > /opt/xcat/xcatinfo - NODE=#TABLE:nodelist:THISNODE:node# - echo "NODE=$NODE" >> /opt/xcat/xcatinfo break fi RAND=$(perl -e 'print int(rand(5)). "\n"') diff --git a/xCAT-server/share/xcat/install/scripts/post.sles10.s390x b/xCAT-server/share/xcat/install/scripts/post.sles10.s390x index 3658e06bb..3902c8917 100644 --- a/xCAT-server/share/xcat/install/scripts/post.sles10.s390x +++ b/xCAT-server/share/xcat/install/scripts/post.sles10.s390x @@ -88,8 +88,6 @@ do echo "XCATSERVER=$i" > /opt/xcat/xcatinfo echo "REBOOT=TRUE" >> /opt/xcat/xcatinfo - NODE=#TABLE:nodelist:THISNODE:node# - echo "NODE=$NODE" >> /opt/xcat/xcatinfo break fi diff --git a/xCAT-server/share/xcat/install/scripts/post.sles11.s390x b/xCAT-server/share/xcat/install/scripts/post.sles11.s390x index bedb9a6b8..3e84ad99b 100644 --- a/xCAT-server/share/xcat/install/scripts/post.sles11.s390x +++ b/xCAT-server/share/xcat/install/scripts/post.sles11.s390x @@ -89,8 +89,6 @@ do echo "XCATSERVER=$i" > /opt/xcat/xcatinfo echo "REBOOT=TRUE" >> /opt/xcat/xcatinfo - NODE=#TABLE:nodelist:THISNODE:node# - echo "NODE=$NODE" >> /opt/xcat/xcatinfo break fi diff --git a/xCAT-server/share/xcat/install/scripts/post.ubuntu b/xCAT-server/share/xcat/install/scripts/post.ubuntu index aae157b1d..b1709b23d 100644 --- a/xCAT-server/share/xcat/install/scripts/post.ubuntu +++ b/xCAT-server/share/xcat/install/scripts/post.ubuntu @@ -90,8 +90,6 @@ do touch /opt/xcat/xcatinfo fi echo "XCATSERVER=$i" > /opt/xcat/xcatinfo - NODE=#TABLE:nodelist:THISNODE:node# - echo "NODE=$NODE" >> /opt/xcat/xcatinfo break fi RAND=$(perl -e 'print int(rand(5)). "\n"') diff --git a/xCAT-server/share/xcat/install/scripts/post.xcat b/xCAT-server/share/xcat/install/scripts/post.xcat index 977df68c9..e7938a530 100644 --- a/xCAT-server/share/xcat/install/scripts/post.xcat +++ b/xCAT-server/share/xcat/install/scripts/post.xcat @@ -98,8 +98,6 @@ do sleep $RAND done echo "INSTALLDIR=$INSTALLDIR" >> /opt/xcat/xcatinfo -NODE=#TABLE:nodelist:THISNODE:node# -echo "NODE=$NODE" >> /opt/xcat/xcatinfo #echo "REBOOT=TRUE" >> /opt/xcat/xcatinfo cd /xcatpost diff --git a/xCAT/postscripts/xcatdsklspost b/xCAT/postscripts/xcatdsklspost index 822fc1e17..436f5a4f0 100755 --- a/xCAT/postscripts/xcatdsklspost +++ b/xCAT/postscripts/xcatdsklspost @@ -341,41 +341,50 @@ fi # finish the postscripts download rm -rf /xcatpost/mypostscript -#get node name -if [ -f /opt/xcat/xcatinfo ]; then - node=`grep 'NODE' /opt/xcat/xcatinfo |cut -d= -f2` -fi - +#get node name and download the mypostscript.$node file #try to get the node ip address that connects to the server. #then resolve the name of the ip -if [ -z "$node" ]; then - #find out the ip address of the node for the management nic - NIP=`ip route get $SIP | head -n 1 | sed 's/^.*src//g' | awk {'print $1'} -` - if [ -n "$NIP" ]; then - #relsove the name of the node from ip address - node=`host $NIP | awk {'print $5'} | sed '$s/\.$//'` +NIP=`ip route get $SIP | head -n 1 | sed 's/^.*src//g' | awk {'print $1'}` +if [ $? -eq 0 ] && [ -n "$NIP" ]; then + #relsove the name of the node from ip address + result=`getent hosts $NIP` + if [ $? -eq 0 ]; then + node1=`echo $result | awk {'print $2'}` + node2=`echo $result | awk {'print $3'}` + if [ ${#node1} -gt ${#node2} ]; then + node=$node1 + node_short=$node2 + else + node=$node2 + node_short=$node1 + fi + if [ -z "$node_short" ]; then + node_short=`echo $node |awk -F. {'print $1'}` + fi + else + if [ -z "$node" ]; then + node=`hostname` + node_short=`hostname -s` + fi fi -fi - -if [ -z "$node" ]; then +else node=`hostname` + node_short=`hostname -s` fi - -#try the short name first -node_short=`echo $node |awk -F. {'print $1'}` + max_retries=2 postfix=0 -download_mypostscript $SIP $node_short $postfix $max_retries $TFTPDIR -if [ $? -ne 0 ]; then - if [ "$node" != "node_short" ]; then - download_mypostscript $SIP $node $postfix $max_retries $TFTPDIR +if [ -n "$node_short" ]; then + download_mypostscript $SIP $node_short $postfix $max_retries $TFTPDIR + if [ $? -ne 0 ]; then + if [ "$node" != "$node_short" ]; then + download_mypostscript $SIP $node $postfix $max_retries $TFTPDIR + fi fi fi - if grep 'rw /rw tmpfs ' /proc/mounts >/dev/null 2>&1; then touch /var/lock/subsys/xcatmounts echo '#!/bin/bash' > /etc/rc6.d/K10xcatmounts @@ -410,10 +419,12 @@ if [ ! -x /xcatpost/mypostscript ]; then /xcatpost/getpostscript.awk version2 > /dev/null max_retries=1 postfix=1 -download_mypostscript $SIP $node $postfix $max_retries $TFTPDIR -if [ $? -ne 0 ]; then - if [ "$node" != "node_short" ]; then - download_mypostscript $SIP $node $postfix $max_retries $TFTPDIR +if [ -n "$node_short" ]; then + download_mypostscript $SIP $node_short $postfix $max_retries $TFTPDIR + if [ $? -ne 0 ]; then + if [ "$node" != "node_short" ]; then + download_mypostscript $SIP $node $postfix $max_retries $TFTPDIR + fi fi fi @@ -443,7 +454,7 @@ while [ -z "$MYCONT" ]; do postfix=1 download_mypostscript $SIP $node $postfix $max_retries $TFTPDIR if [ $? -ne 0 ]; then - if [ "$node" != "node_short" ]; then + if [ "$node" != "$node_short" ]; then download_mypostscript $SIP $node $postfix $max_retries $TFTPDIR fi fi @@ -473,20 +484,6 @@ if [ -n "$new_ms" ]; then fi fi -#save the NODE into xcatinfo -new_node=`grep '^NODE=' /xcatpost/mypostscript |cut -d= -f2` -if [ -n "$new_node" ]; then - if [ ! -f /opt/xcat/xcatinfo ]; then - mkdir -p /opt/xcat - touch /opt/xcat/xcatinfo - fi - grep '^NODE=' /opt/xcat/xcatinfo 2>&1 > /dev/null - if [ $? -eq 0 ]; then - sed -i "s/NODE=.*/NODE=$new_node/" /opt/xcat/xcatinfo - else - echo "NODE=$new_node" >> /opt/xcat/xcatinfo - fi -fi # when called by the updatenode command #modify the UPDATENODE flag to 1 @@ -540,7 +537,6 @@ if ( pmatch $POSTSCRIPTS "*start-here*" ); then #remove all the postbootscripts TMP=`sed "/# postbootscripts-start-here/,/# postbootscripts-end-here/ d" /xcatpost/mypostscript` echo "$TMP" > /xcatpost/mypostscript - fi if ( pmatch $POSTSCRIPTS "*postbootscripts-start-here" ); then #remove all the postscripts