2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-29 09:13:08 +00:00

add support for site.httpport for post.xcat and updatenode

This commit is contained in:
yangsbj 2018-11-01 05:00:05 -04:00
parent cb9b8c0a51
commit 5c910eca26
3 changed files with 80 additions and 24 deletions

View File

@ -1564,6 +1564,11 @@ sub updatenoderunps
if ($fc[0] && ($fc[0] =~ /1|Yes|yes|YES|Y|y/)) {
$flowcontrol = 1;
}
my $httpport="80";
my @hports=xCAT::TableUtils->get_site_attribute("httpport");
if ($hports[0]){
$httpport=$hports[0];
}
# if running postscript report status here, if requested.
if ((defined($request->{status})) && ($request->{status} eq "yes")) {
@ -1625,10 +1630,10 @@ sub updatenoderunps
if ($::SETSERVER) { # update the xcatinfo file on the node and run setuppostbootscripts
$runpscmd =
"$installdir/postscripts/xcatdsklspost $mode -M $snkey '$postscripts' --tftp $tftpdir --installdir $installdir --nfsv4 $nfsv4 -c";
"$installdir/postscripts/xcatdsklspost $mode -M $snkey:$httpport '$postscripts' --tftp $tftpdir --installdir $installdir --nfsv4 $nfsv4 -c";
} else {
$runpscmd =
"$installdir/postscripts/xcatdsklspost $mode -m $snkey '$postscripts' --tftp $tftpdir --installdir $installdir --nfsv4 $nfsv4 -c"
"$installdir/postscripts/xcatdsklspost $mode -m $snkey:$httpport '$postscripts' --tftp $tftpdir --installdir $installdir --nfsv4 $nfsv4 -c"
}
# add flowcontrol flag
@ -2084,6 +2089,12 @@ sub updatenodesoftware
$flowcontrol = 1;
}
my $httpport="80";
my @hports=xCAT::TableUtils->get_site_attribute("httpport");
if ($hports[0]){
$httpport=$hports[0];
}
# this drives getdata to report status complete for software updatees
$::TYPECALL = "S";
@ -2117,7 +2128,7 @@ sub updatenodesoftware
my $cmd;
my $args1;
$cmd =
"$installdir/postscripts/xcatdsklspost 2 -m $snkey 'ospkgs,otherpkgs,syscloneimgupdate' --tftp $tftpdir --installdir $installdir --nfsv4 $nfsv4 -c";
"$installdir/postscripts/xcatdsklspost 2 -m $snkey:$httpport 'ospkgs,otherpkgs,syscloneimgupdate' --tftp $tftpdir --installdir $installdir --nfsv4 $nfsv4 -c";
# add flowcontrol flag
if ($flowcontrol == 1) {
@ -3301,6 +3312,12 @@ sub updateOS
# Get install directory
my $installDIR = xCAT::TableUtils->getInstallDir();
my $httpport="80";
my @hports=xCAT::TableUtils->get_site_attribute("httpport");
if ($hports[0]){
$httpport=$hports[0];
}
# Get HTTP server
my $http;
my @httpd = xCAT::NetworkUtils->my_ip_facing($node);
@ -3372,7 +3389,7 @@ sub updateOS
{
# SUSE repository path - http://10.1.100.1/install/sles10.3/s390x/1/
$path = "http://$http$installDIR/$os/$arch/1/";
$path = "http://$http:$httpport$installDIR/$os/$arch/1/";
if (!(-e "$installDIR/$os/$arch/1/"))
{
push @{ $rsp->{data} },
@ -3406,7 +3423,7 @@ sub updateOS
{
# SUSE repository path - http://10.1.100.1/install/sles10.3/s390x/1/
$path = "http://$http$installDIR/$os/$arch/1/";
$path = "http://$http$httpport$installDIR/$os/$arch/1/";
if (!(-e "$installDIR/$os/$arch/1/"))
{
push @{ $rsp->{data} },
@ -3438,7 +3455,7 @@ sub updateOS
my $verifyOS = $os;
$verifyOS =~ s/^\D+([\d.]+)$/$1/;
if (xCAT::Utils->version_cmp($verifyOS, "7.0") < 0) {
$path = "http://$http$installDIR/$os/$arch/Server/";
$path = "http://$http:$httpport$installDIR/$os/$arch/Server/";
if (!(-e "$installDIR/$os/$arch/Server/"))
{
push @{ $rsp->{data} },
@ -3449,7 +3466,7 @@ sub updateOS
}
else
{
$path = "http://$http$installDIR/$os/$arch/";
$path = "http://$http:$httpport$installDIR/$os/$arch/";
if (!(-e "$installDIR/$os/$arch/"))
{
push @{ $rsp->{data} },

View File

@ -8,6 +8,7 @@ export XCATIPORT=#TABLE:site:key=xcatiport:value#
export INSTALLDIR=#TABLE:site:key=installdir:value#
export TFTPDIR=#TABLE:site:key=tftpdir:value#
export XCATDEBUGMODE="#TABLEBLANKOKAY:site:key=xcatdebugmode:value#"
export HTTPPORT="#TABLE:site:key=httpport:value#"
#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/scriptlib#
@ -27,6 +28,9 @@ fi
if [[ $TFTPDIR != /* ]]; then
TFTPDIR="/"$TFTPDIR
fi
if [ -z "$HTTPPORT" ]; then
HTTPPORT="80"
fi
NODESTATUS=$(echo "$NODESTATUS"| tr -d \'\"| tr A-Z a-z)
@ -89,7 +93,7 @@ if [ ! -x /usr/bin/wget ]; then
sleep 36500d
fi
wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -e robots=off -nH --cut-dirs=2 --reject "index.html*" --no-parent -t 20 -T 60 http://$MASTER_IP$INSTALLDIR/postscripts/ -P /xcatpost 2> /tmp/wget.log
wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -e robots=off -nH --cut-dirs=2 --reject "index.html*" --no-parent -t 20 -T 60 http://${MASTER_IP}:${HTTPPORT}${INSTALLDIR}/postscripts/ -P /xcatpost 2> /tmp/wget.log
if [ "$?" != "0" ]; then
msgutil_r "$MASTER_IP" "error" "failed to download postscripts from http://$MASTER_IP$INSTALLDIR/postscripts/,check /tmp/wget.log on the node, halt ..." "/var/log/xcat/xcat.log" "$log_label"
/tmp/updateflag $MASTER $XCATIPORT "installstatus failed"
@ -106,7 +110,7 @@ export NODE=#TABLE:nodelist:THISNODE:node#
msgutil_r "$MASTER_IP" "info" "trying to get mypostscript from $MASTER_IP..." "/var/log/xcat/xcat.log" "$log_label"
wget -N --waitretry=10 --random-wait --retry-connrefused -t 20 -T 60 http://$MASTER_IP$TFTPDIR/mypostscripts/mypostscript.$NODE -P /xcatpost 2> /tmp/wget.log
wget -N --waitretry=10 --random-wait --retry-connrefused -t 20 -T 60 http://${MASTER_IP}:${HTTPPORT}${TFTPDIR}/mypostscripts/mypostscript.$NODE -P /xcatpost 2> /tmp/wget.log
if [ "$?" = "0" ]; then
if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
msgutil_r "$MASTER_IP" "debug" "precreated mypostscript downloaded successfully" "/var/log/xcat/xcat.log" "$log_label"

View File

@ -210,6 +210,30 @@ pmatch ()
return 1 # non-zero return code means string not matched by pattern
}
#parse the http server "<ip/hostname>:<port>"
#usgae: parsehttpserver(<http server string>,<what to return? 'server' or 'port'>)
parsehttpserver ()
{
rawserver=$1
option=$2
server=$(echo "$rawserver"|cut -d: -f1 -s 2>/dev/null)
port="80"
if [ -z "$server" ];then
server=$rawserver
else
port=$(echo "$rawserver"|cut -d: -f2 -s 2>/dev/null)
fi
if [ "$option" = "server" ];then
return $server
fi
if [ "$option" = "port" ];then
return $port
fi
}
# Main
# parse the arguments
ARGNUM=$#;
@ -226,10 +250,14 @@ else
MODE=$1
if [ $ARGNUM -gt 1 ]; then
if [ $2 = "-m" ]; then
P_SIP=$3
P_SVR=$3
P_SIP=parsehttpserver "$P_SVR" 'server'
HTTPPORT=parsehttpserver "$P_SVR" 'port'
else
if [ $2 = "-M" ]; then
P_SIP=$3
P_SVR=$3
P_SIP=parsehttpserver "$P_SVR" 'server'
HTTPPORT=parsehttpserver "$P_SVR" 'port'
new_ms=$P_SIP # -M means we will update xcatinfo file XCATSERVER
fi
fi
@ -395,7 +423,7 @@ else # for common mode MODE=1,2,3,5 (updatenode,moncfg,node deployment)
# also update the XCATSERVER in the /etc/xcat/xcatinfo file with this
# address
if [ -n "$P_SIP" ]; then # passed in with updatenode on -M/-m
SIP=$P_SIP
SIP="${P_SIP}:${HTTPPORT}"
download_postscripts $SIP
if [ $? -eq 0 ]; then
downloaded=1
@ -420,8 +448,10 @@ else # for common mode MODE=1,2,3,5 (updatenode,moncfg,node deployment)
# if not updatenode, then look in xcatinfo for the xcatmaster
if [ -f /opt/xcat/xcatinfo ]; then
SIP=`grep 'XCATSERVER' /opt/xcat/xcatinfo |cut -d= -f2`
HTTPPORT=`grep 'HTTPPORT' /opt/xcat/xcatinfo |cut -d= -f2`
[ -z "$HTTPPORT" ] && HTTPPORT="80"
if [ -n "$SIP" ]; then
download_postscripts $SIP
download_postscripts ${SIP}:${HTTPPORT}
if [ $? -eq 0 ]; then
downloaded=1
fi
@ -438,15 +468,20 @@ else # for common mode MODE=1,2,3,5 (updatenode,moncfg,node deployment)
if [ "$KEY" = "XCAT" ]; then
TMP=`echo $i | awk -F= '{print $2}'`
SIP=`echo $TMP | cut -d: -f1`
if [ -n "$SIP" ]; then
download_postscripts $SIP
if [ $? -eq 0 ]; then
downloaded=1
break
fi
fi
fi
done
elif [ "$KEY" = "HTTPPORT" ];then
HTTPPORT=$(echo $i | awk -F= '{print $1}')
[ -z "$HTTPPORT" ] && HTTPPORT="80"
fi
done
if [ -n "$SIP" ]; then
download_postscripts "${SIP}:${HTTPPORT}"
if [ $? -eq 0 ]; then
downloaded=1
break
fi
fi
fi
# download poscripts has not worked yet
@ -549,11 +584,11 @@ echolog "info" "trying to get mypostscript from $SIP..."
max_retries=2
# try short hostname first
if [ -n "$node_short" ]; then
download_mypostscript $SIP $node_short $max_retries $TFTPDIR
download_mypostscript "${SIP}:${HTTPPORT}" $node_short $max_retries $TFTPDIR
if [ $? -ne 0 ]; then
# try long hostname
if [ "$node" != "$node_short" ]; then
download_mypostscript $SIP $node $postfix $max_retries $TFTPDIR
download_mypostscript "${SIP}:${HTTPPORT}" $node $postfix $max_retries $TFTPDIR
fi
fi
fi