update the nodelist.status to installing/netbooting via feedback from node during provision
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.8@16642 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
d1b41732b5
commit
a55349b5af
@ -180,6 +180,8 @@ sub mknetboot
|
||||
my $installroot;
|
||||
$installroot = "/install";
|
||||
my $xcatdport = "3001";
|
||||
my $xcatiport = "3002";
|
||||
my $nodestatus = "y";
|
||||
|
||||
#if ($sitetab)
|
||||
#{
|
||||
@ -190,6 +192,12 @@ sub mknetboot
|
||||
{
|
||||
$installroot = $site_ent;
|
||||
}
|
||||
@ents = xCAT::TableUtils->get_site_attribute("nodestatus");
|
||||
$site_ent = $ents[0];
|
||||
if ( defined($site_ent) )
|
||||
{
|
||||
$nodestatus = $site_ent;
|
||||
}
|
||||
# ($ref) = $sitetab->getAttribs({key => 'xcatdport'}, 'value');
|
||||
@ents = xCAT::TableUtils->get_site_attribute("xcatdport");
|
||||
$site_ent = $ents[0];
|
||||
@ -197,6 +205,12 @@ sub mknetboot
|
||||
{
|
||||
$xcatdport = $site_ent;
|
||||
}
|
||||
@ents = xCAT::TableUtils->get_site_attribute("xcatiport");
|
||||
$site_ent = $ents[0];
|
||||
if ( defined($site_ent) )
|
||||
{
|
||||
$xcatiport = $site_ent;
|
||||
}
|
||||
# ($ref) = $sitetab->getAttribs({key => 'tftpdir'}, 'value');
|
||||
@ents = xCAT::TableUtils->get_site_attribute("tftpdir");
|
||||
$site_ent = $ents[0];
|
||||
@ -679,8 +693,10 @@ sub mknetboot
|
||||
} else {
|
||||
$xcatmasterip = $xcatmaster;
|
||||
}
|
||||
$kcmdline .=
|
||||
"XCAT=$xcatmasterip:$xcatdport ";
|
||||
|
||||
$kcmdline .= "XCAT=$xcatmaster:$xcatdport ";
|
||||
|
||||
|
||||
if ($rootfstype ne "ramdisk") {
|
||||
# BEGIN service node
|
||||
my $isSV = xCAT::Utils->isServiceNode();
|
||||
@ -701,9 +717,14 @@ sub mknetboot
|
||||
else {
|
||||
$kcmdline =
|
||||
"imgurl=$httpmethod://$imgsrv:$httpport/$rootimgdir/rootimg.$suffix ";
|
||||
$kcmdline .= "XCAT=$xcatmaster:$xcatdport ";
|
||||
$kcmdline .= "XCAT=$xcatmaster:$xcatdport ";
|
||||
$kcmdline .= "NODE=$node ";
|
||||
}
|
||||
#inform statelite/stateless node not to update the nodestatus during provision
|
||||
if(($nodestatus eq "n") or ($nodestatus eq "N") or ($nodestatus eq "0")){
|
||||
$kcmdline .= " nonodestatus ";
|
||||
}
|
||||
|
||||
|
||||
# add one parameter: ifname=<eth0>:<mac address>
|
||||
# which is used for dracut
|
||||
|
@ -64,7 +64,8 @@ sub mknetboot
|
||||
$installroot = "/install";
|
||||
|
||||
my $xcatdport = "3001";
|
||||
|
||||
my $xcatiport = "3002";
|
||||
my $nodestatus = "y";
|
||||
#if ($sitetab)
|
||||
#{
|
||||
#(my $ref) = $sitetab->getAttribs({key => 'installdir'}, 'value');
|
||||
@ -79,6 +80,17 @@ sub mknetboot
|
||||
if ( defined($t_entry) ) {
|
||||
$xcatdport = $t_entry;
|
||||
}
|
||||
@entries = xCAT::TableUtils->get_site_attribute("xcatiport");
|
||||
$t_entry = $entries[0];
|
||||
if ( defined($t_entry) ) {
|
||||
$xcatiport = $t_entry;
|
||||
}
|
||||
@entries = xCAT::TableUtils->get_site_attribute("nodestatus");
|
||||
$t_entry = $entries[0];
|
||||
if ( defined($t_entry) ) {
|
||||
$nodestatus = $t_entry;
|
||||
}
|
||||
|
||||
#}
|
||||
|
||||
my $ntents = $ostab->getNodesAttribs($req->{node}, ['os', 'arch', 'profile', 'provmethod']);
|
||||
@ -553,6 +565,13 @@ sub mknetboot
|
||||
"imgurl=$httpmethod://$imgsrv/$rootimgdir/rootimg.$suffix ";
|
||||
}
|
||||
$kcmdline .= "XCAT=$xcatmaster:$xcatdport quiet ";
|
||||
|
||||
#if site.nodestatus="n", append "nonodestatus" to kcmdline
|
||||
#to inform the statelite/stateless node not to update the nodestatus during provision
|
||||
if(($nodestatus eq "n") or ($nodestatus eq "N") or ($nodestatus eq "0")){
|
||||
$kcmdline .= " nonodestatus ";
|
||||
}
|
||||
|
||||
$kcmdline .= "NODE=$node ";
|
||||
|
||||
# add the kernel-booting parameter: netdev=<eth0>, or BOOTIF=<mac>
|
||||
|
@ -13,6 +13,24 @@ if [ -r /tmp/updates/etc/pki/tls/certs/ca-bundle.crt ]; then
|
||||
cp -f /tmp/updates/etc/pki/tls/certs/ca-bundle.crt /etc/pki/tls/certs/
|
||||
fi
|
||||
|
||||
cat >/tmp/baz.py <<EOF
|
||||
#!/usr/bin/python
|
||||
import socket
|
||||
import sys
|
||||
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
sock.connect(('#XCATVAR:XCATMASTER#',#TABLE:site:key=xcatiport:value#))
|
||||
|
||||
print sys.argv[1]
|
||||
response = sock.recv(100)
|
||||
if(response == "ready\n"):
|
||||
sock.send(sys.argv[1]+"\n")
|
||||
response = sock.recv(100)
|
||||
|
||||
sock.close()
|
||||
EOF
|
||||
|
||||
|
||||
|
||||
cat >/tmp/foo.py <<EOF
|
||||
#!/usr/bin/python
|
||||
@ -123,6 +141,14 @@ finally:
|
||||
EOF
|
||||
|
||||
chmod 755 /tmp/foo.py
|
||||
chmod 755 /tmp/baz.py
|
||||
|
||||
NODESTATUS=#TABLEBLANKOKAY:site:key=nodestatus:value#
|
||||
|
||||
if [ -z "$NODESTATUS" ] || [ "$NODESTATUS" != "0" -a "$NODESTATUS" != "N" -a "$NODESTATUS" != "n" ]; then
|
||||
/tmp/baz.py "installstatus installing" &
|
||||
fi
|
||||
|
||||
|
||||
/tmp/foo.py >/foo.log 2>&1 &
|
||||
#time to ascertain fstype and PReP/UEFI/legacy
|
||||
|
@ -14,28 +14,30 @@ cat >/tmp/bar.awk <<EOF
|
||||
#!$AWK -f
|
||||
|
||||
BEGIN {
|
||||
xcatdport = "#TABLE:site:key=xcatiport:value#"
|
||||
xcatdhost = "#XCATVAR:XCATMASTER#"
|
||||
|
||||
ns = "/inet/tcp/0/" xcatdhost "/" xcatiport
|
||||
xcatiport = "#TABLE:site:key=xcatiport:value#"
|
||||
xcatdhost = "#XCATVAR:XCATMASTER#"
|
||||
|
||||
print "xCAT_xcatd" |& ns
|
||||
ns = "/inet/tcp/0/" xcatdhost "/" xcatiport
|
||||
print ARGV[1]
|
||||
print "xCAT_xcatd" |& ns
|
||||
|
||||
while(1) {
|
||||
ns |& getline
|
||||
while(1) {
|
||||
ns |& getline
|
||||
|
||||
if(\$0 == "ready")
|
||||
print "installmonitor" |& ns
|
||||
if(\$0 == "done")
|
||||
break
|
||||
}
|
||||
if(\$0 == "ready")
|
||||
print ARGV[1] |& ns
|
||||
if(\$0 == "done")
|
||||
break
|
||||
}
|
||||
|
||||
close(ns)
|
||||
close(ns)
|
||||
|
||||
exit 0
|
||||
exit 0
|
||||
}
|
||||
EOF
|
||||
|
||||
|
||||
if [ ! -c /dev/vcs ]; then
|
||||
mknod /dev/vcs c 7 0
|
||||
fi
|
||||
@ -111,8 +113,17 @@ EOF
|
||||
chmod 755 /tmp/foo.awk
|
||||
chmod 755 /tmp/bar.awk
|
||||
|
||||
/tmp/bar.awk &
|
||||
|
||||
/tmp/bar.awk "installmonitor" &
|
||||
|
||||
NODESTATUS=#TABLEBLANKOKAY:site:key=nodestatus:value#
|
||||
|
||||
if [ -z "$NODESTATUS" ] || [ "$NODESTATUS" != "0" -a "$NODESTATUS" != "N" -a "$NODESTATUS" != "n" ]; then
|
||||
/tmp/bar.awk "installstatus installing" &
|
||||
fi
|
||||
|
||||
/tmp/foo.awk >/tmp/foo.log 2>&1 &
|
||||
|
||||
shopt -s nullglob
|
||||
for disk in /dev/vd*[^0-9];do
|
||||
if [ -z "$firstdirectdisk" ]; then firstdirectdisk=$disk; fi #remember first disk as a guess of medium resort
|
||||
|
@ -4,5 +4,6 @@ dracut_install wget cpio gzip dash modprobe touch echo cut wc
|
||||
dracut_install grep ifconfig hostname awk egrep grep dirname expr
|
||||
dracut_install mount.nfs
|
||||
dracut_install parted mke2fs bc mkswap swapon chmod
|
||||
inst "$moddir/xcat-updateflag" "/tmp/updateflag"
|
||||
inst "$moddir/xcatroot" "/sbin/xcatroot"
|
||||
inst_hook cmdline 10 "$moddir/xcat-cmdline.sh"
|
||||
|
@ -3,4 +3,6 @@ echo $drivers
|
||||
dracut_install wget cpio gzip dash modprobe wc touch echo cut
|
||||
dracut_install grep ifconfig hostname awk egrep grep dirname expr
|
||||
dracut_install parted mke2fs bc mkswap swapon chmod
|
||||
inst "$moddir/xcat-updateflag" "/tmp/updateflag"
|
||||
inst_hook pre-mount 5 "$moddir/xcat-premount.sh"
|
||||
inst_hook pre-pivot 5 "$moddir/xcat-prepivot.sh"
|
||||
|
@ -5,6 +5,22 @@ XCATMASTER=$XCAT
|
||||
|
||||
. /lib/dracut-lib.sh
|
||||
rootlimit="$(getarg rootlimit=)"
|
||||
|
||||
|
||||
getarg nonodestatus
|
||||
NODESTATUS=$?
|
||||
|
||||
MASTER=`echo $XCATMASTER |awk -F: '{print $1}'`
|
||||
XCATIPORT="$(getarg XCATIPORT=)"
|
||||
if [ $? -ne 0 ]; then
|
||||
XCATIPORT="3002"
|
||||
fi
|
||||
|
||||
|
||||
if [ $NODESTATUS -ne 0 ];then
|
||||
/tmp/updateflag $MASTER $XCATIPORT "installstatus netbooting"
|
||||
fi
|
||||
|
||||
if [ ! -z "$imgurl" ]; then
|
||||
if [ xhttp = x${imgurl%%:*} ]; then
|
||||
NFS=0
|
||||
|
@ -771,11 +771,19 @@ sub mkinitrd_dracut {
|
||||
$perm = (stat("$fullpath/$dracutdir/install.statelite"))[2];
|
||||
chmod($perm&07777, "$dracutmpath/install");
|
||||
|
||||
cp("$fullpath/$dracutdir/xcat-updateflag",$dracutmpath);
|
||||
$perm = (stat("$fullpath/$dracutdir/xcat-updateflag"))[2];
|
||||
chmod($perm&07777, "$dracutmpath/xcat-updateflag");
|
||||
|
||||
cp("$fullpath/$dracutdir/xcat-prepivot.sh",$dracutmpath);
|
||||
$perm = (stat("$fullpath/$dracutdir/xcat-prepivot.sh"))[2];
|
||||
chmod($perm&07777, "$dracutmpath/xcat-prepivot.sh");
|
||||
|
||||
# update etc/dracut.conf
|
||||
cp("$fullpath/$dracutdir/xcat-premount.sh",$dracutmpath);
|
||||
$perm = (stat("$fullpath/$dracutdir/xcat-premount.sh"))[2];
|
||||
chmod($perm&07777, "$dracutmpath/xcat-premount.sh");
|
||||
|
||||
#update etc/dracut.conf
|
||||
open($DRACUTCONF, '>', "$rootimg_dir/etc/dracut.conf");
|
||||
if (-d glob("$rootimg_dir/usr/share/dracut/modules.d/[0-9]*fadump")){
|
||||
print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules fadump"\n};
|
||||
@ -795,6 +803,10 @@ sub mkinitrd_dracut {
|
||||
$perm = (stat("$fullpath/$dracutdir/xcat-cmdline.sh"))[2];
|
||||
chmod($perm&07777, "$dracutmpath/xcat-cmdline.sh");
|
||||
|
||||
cp("$fullpath/$dracutdir/xcat-updateflag",$dracutmpath);
|
||||
$perm = (stat("$fullpath/$dracutdir/xcat-updateflag"))[2];
|
||||
chmod($perm&07777, "$dracutmpath/xcat-updateflag");
|
||||
|
||||
if ($prinic) {
|
||||
my $optspec;
|
||||
open($optspec,'>>',"$dracutmpath/xcat-cmdline.sh");
|
||||
@ -1051,6 +1063,7 @@ grep '\(debug\)' /proc/cmdline > /dev/null && export DEBUG=1
|
||||
# TODO: does "anaconda.busybox sh" support "set " ?
|
||||
|
||||
PRINIC=$prinic
|
||||
NODESTATUS='y'
|
||||
|
||||
for i in `cat /proc/cmdline`; do
|
||||
KEY=`echo \$i |awk -F= '{print \$1}'`
|
||||
@ -1063,6 +1076,14 @@ for i in `cat /proc/cmdline`; do
|
||||
VALUE=`echo \$i |awk -F= '{print \$2}'`
|
||||
# format: XCAT=xcatmaster:3001
|
||||
XCATSERVER=\$VALUE
|
||||
elif [ "\$KEY" == 'XCATIPORT' ]; then
|
||||
VALUE=`echo \$i |awk -F= '{print \$2}'`
|
||||
# format: XCAT=xcatmaster:3001
|
||||
XCATIPORT=\$VALUE
|
||||
fi
|
||||
#if "nonodestatus" specified,do not update the nodestatus
|
||||
if [ \$i == 'nonodestatus' ]; then
|
||||
NODESTATUS='n'
|
||||
fi
|
||||
done
|
||||
|
||||
@ -1091,6 +1112,18 @@ while ! ifconfig | grep inet; do
|
||||
done
|
||||
ifconfig lo 127.0.0.1
|
||||
ifconfig lo up
|
||||
|
||||
XCATMASTER=`echo \$XCATSERVER|awk -F: '{print \$1}'`
|
||||
|
||||
if [ -z \$XCATIPORT ]; then
|
||||
XCATIPORT="3002"
|
||||
fi
|
||||
|
||||
#update nodelist.nodestatus to "netbooting"
|
||||
if [ \$NODESTATUS != 'n' ]; then
|
||||
/tmp/updateflag \$XCATMASTER \$XCATIPORT "installstatus netbooting"
|
||||
fi
|
||||
|
||||
cd /
|
||||
for i in `cat /proc/cmdline`; do
|
||||
KEY=`echo \$i |awk -F= '{print \$1}'`
|
||||
@ -1137,6 +1170,10 @@ for i in `cat /proc/cmdline`; do
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# show xCAT logo
|
||||
fancydisplay
|
||||
|
||||
@ -1346,8 +1383,38 @@ EOMS
|
||||
open($inifile,">"."/tmp/xcatinitrd.$$/bin/netstart");
|
||||
print $inifile "#!/sbin/nash\n";
|
||||
close($inifile);
|
||||
|
||||
#/tmp/updateflag: a script to feedback node provision status to xcatd
|
||||
system("mkdir -p /tmp/xcatinitrd.$$/tmp/");
|
||||
open($inifile, ">","/tmp/xcatinitrd.$$/tmp/updateflag");
|
||||
|
||||
print $inifile <<EOMS;
|
||||
#!/bin/sh
|
||||
if [ \$# -eq 3 ]; then
|
||||
echo \$3 > /tmp/ncarg
|
||||
nc \$1 \$2 -w 60 -e /tmp/updateflag
|
||||
else
|
||||
retrytimes=0
|
||||
cmd=""
|
||||
while [ "\$cmd" != "done" ]; do
|
||||
retrytimes=`expr \$retrytimes + 1`
|
||||
if [ \$retrytimes -eq 60 ]; then
|
||||
break;
|
||||
fi
|
||||
read -t 60 cmd
|
||||
if [ "\$cmd" == "ready" ]; then
|
||||
head -n 1 /tmp/ncarg
|
||||
rm -rf /tmp/ncarg
|
||||
fi
|
||||
done
|
||||
|
||||
fi
|
||||
EOMS
|
||||
close($inifile);
|
||||
|
||||
chmod(0755,"/tmp/xcatinitrd.$$/init");
|
||||
chmod(0755,"/tmp/xcatinitrd.$$/bin/netstart");
|
||||
chmod(0755,"/tmp/xcatinitrd.$$/tmp/updateflag");
|
||||
@filestoadd=();
|
||||
foreach (@ndrivers) {
|
||||
if (-f "$customdir/$_") {
|
||||
|
@ -1032,6 +1032,7 @@ EOMS
|
||||
# check the kernel parameters firstly
|
||||
# if one parameter for the booting device is here, it will be used
|
||||
PRINIC=$prinic
|
||||
NODESTATUS='y'
|
||||
XCATMNTOPTS='nolock,tcp'
|
||||
for i in `cat /proc/cmdline`; do
|
||||
KEY=`echo \$i |awk -F= '{print \$1}'`
|
||||
@ -1050,6 +1051,11 @@ for i in `cat /proc/cmdline`; do
|
||||
XCATMNTOPTS=\$VALUE
|
||||
|
||||
fi
|
||||
|
||||
|
||||
if [ \$i == 'nonodestatus' ]; then
|
||||
NODESTATUS='n'
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "\$IFACE" ]; then
|
||||
@ -1083,6 +1089,18 @@ echo "STARTMODE=nfsroot" > /tmp/ifcfg-\$IFACE
|
||||
|
||||
ip addr add dev lo 127.0.0.1/8
|
||||
ip link set lo up
|
||||
|
||||
|
||||
XCATMASTER=`echo \$XCATSERVER|awk -F: '{print \$1}'`
|
||||
|
||||
if [ -z \$XCATIPORT ]; then
|
||||
XCATIPORT="3002"
|
||||
fi
|
||||
|
||||
if [ \$NODESTATUS != 'n' ]; then
|
||||
/tmp/updateflag \$XCATMASTER \$XCATIPORT "installstatus netbooting"
|
||||
fi
|
||||
|
||||
cd /
|
||||
for i in `cat /proc/cmdline`; do
|
||||
KEY=`echo \$i |awk -F= '{print \$1}'`
|
||||
@ -1373,8 +1391,43 @@ cat /var/lib/dhcpcd/*info | grep HOSTNAME | uniq | awk -F= '{print \$2}'| sed \"
|
||||
END
|
||||
|
||||
close($inifile);
|
||||
|
||||
#if "nonodestatus" specified,do not update the nodestatus
|
||||
system("mkdir -p /tmp/xcatinitrd.$$/tmp/");
|
||||
open($inifile, ">","/tmp/xcatinitrd.$$/tmp/updateflag");
|
||||
|
||||
print $inifile <<EOMS;
|
||||
#!/usr/bin/awk -f
|
||||
BEGIN {
|
||||
|
||||
xcatdhost = ARGV[1]
|
||||
xcatiport = ARGV[2]
|
||||
|
||||
|
||||
ns = "/inet/tcp/0/" xcatdhost "/" xcatiport
|
||||
print "xCAT_xcatd" |& ns
|
||||
|
||||
while(1) {
|
||||
ns |& getline
|
||||
|
||||
if(\$0 == "ready")
|
||||
print ARGV[3] |& ns
|
||||
if(\$0 == "done")
|
||||
break
|
||||
}
|
||||
|
||||
close(ns)
|
||||
|
||||
exit 0
|
||||
}
|
||||
|
||||
EOMS
|
||||
|
||||
|
||||
chmod(0755,"/tmp/xcatinitrd.$$/init");
|
||||
chmod(0755,"/tmp/xcatinitrd.$$/bin/netstart");
|
||||
chmod(0755,"/tmp/xcatinitrd.$$/tmp/updateflag");
|
||||
|
||||
@filestoadd=();
|
||||
foreach (@ndrivers) {
|
||||
if (-f "$customdir/$_") {
|
||||
|
Loading…
x
Reference in New Issue
Block a user