code is committed for kdump feature

the "dump" attribute is added for the linuximage table

/install/kdump/tmp directory will be created by default when xCAT rpm package is installed;

the "enablekdump" postscript is added for kdump feature

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@8396 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
mxi1 2010-12-14 07:15:45 +00:00
parent 16b219091a
commit dd661c6aa0
10 changed files with 124 additions and 13 deletions

View File

@ -593,7 +593,7 @@ osimage => {
},
},
linuximage => {
cols => [qw(imagename template pkglist pkgdir otherpkglist otherpkgdir exlist postinstall rootimgdir nodebootif otherifce netdrivers kernelver permission comments disable)],
cols => [qw(imagename template pkglist pkgdir otherpkglist otherpkgdir exlist postinstall rootimgdir nodebootif otherifce netdrivers kernelver permission dump comments disable)],
keys => [qw(imagename)],
table_desc => 'Information about a Linux operating system image that can be used to deploy cluster nodes.',
descriptions => {
@ -611,6 +611,7 @@ linuximage => {
netdrivers => 'the ethernet device drivers of the nodes which will use this linux image, at least the device driver for the nodes\' installnic should be included',
kernelver => 'the version of linux kernel used in the linux image. If the kernel version is not set, the default kernel in rootimgdir will be used',
permission => 'the mount permission of /.statelite directory is used, its default value is 755',
dump => qq{The NFS directory to hold the Linux kernel dump file (vmcore) when the node with this image crashes, its format is "nfs://<nfs_server_ip>/<kdump_path>". If you want to use the node's "xcatmaster" (its SN or MN), <nfs_server_ip> can be left blank. For example, "nfs:///<kdump_path>" means the NFS directory to hold the kernel dump file is on the node's SN, or MN if there's no SN.},
comments => 'Any user-written notes.',
disable => "Set to 'yes' or '1' to comment out this row.",
},
@ -1886,6 +1887,11 @@ push(@{$defspec{node}->{'attrs'}}, @nodeattrs);
tabentry => 'linuximage.permission',
access_tabentry => 'linuximage.imagename=attr:imagename',
},
{attr_name => 'dump',
only_if => 'imagetype=linux',
tabentry => 'linuximage.dump',
access_tabentry => 'linuximage.imagename=attr:imagename',
},
####################
# nimimage table#
####################

View File

@ -223,7 +223,7 @@ sub mknetboot
my $machash = $mactab->getNodesAttribs(\@nodes, ['interface','mac']);
my $reshash = $restab->getNodesAttribs(\@nodes, ['primarynic','tftpserver','xcatmaster','nfsserver','nfsdir', 'installnic']);
my $reshash = $restab->getNodesAttribs(\@nodes, ['primarynic','tftpserver','xcatmaster','nfsserver','nfsdir', 'installnic', 'dump']);
my $hmhash =
$hmtab->getNodesAttribs(\@nodes,
['serialport', 'serialspeed', 'serialflow']);
@ -243,6 +243,7 @@ sub mknetboot
my $platform;
my $rootimgdir;
my $nodebootif; # nodebootif will be used if noderes.installnic is not set
my $dump; # for kdump, its format is "nfs://<nfs_server_ip>/<kdump_path>"
my $ent = $oents{$node}->[0]; #ostab->getNodeAttribs($node, ['os', 'arch', 'profile']);
if ($ent and $ent->{provmethod} and ($ent->{provmethod} ne 'install') and ($ent->{provmethod} ne 'netboot') and ($ent->{provmethod} ne 'statelite')) {
@ -261,13 +262,18 @@ sub mknetboot
if (!$linuximagetab) {
$linuximagetab=xCAT::Table->new('linuximage', -create=>1);
}
(my $ref1) = $linuximagetab->getAttribs({imagename => $imagename}, 'rootimgdir', 'nodebootif');
(my $ref1) = $linuximagetab->getAttribs({imagename => $imagename}, 'rootimgdir', 'nodebootif', 'dump');
if (($ref1) && ($ref1->{'rootimgdir'})) {
$img_hash{$imagename}->{rootimgdir}=$ref1->{'rootimgdir'};
}
if (($ref1) && ($ref1->{'nodebootif'})) {
$img_hash{$imagename}->{nodebootif} = $ref1->{'nodebootif'};
}
if ( $ref1 ) {
if ($ref1->{'dump'}) {
$img_hash{$imagename}->{dump} = $ref1->{'dump'};
}
}
} else {
$callback->(
{error => ["The os image $imagename does not exists on the osimage table for $node"],
@ -276,16 +282,19 @@ sub mknetboot
}
}
my $ph=$img_hash{$imagename};
$osver = $ph->{osver};
$arch = $ph->{osarch};
$profile = $ph->{profile};
$rootimgdir=$ph->{rootimgdir};
unless ($rootimgdir) {
$rootimgdir="$installroot/netboot/$osver/$arch/$profile";
}
$nodebootif = $ph->{nodebootif};
$dump = $ph->{dump};
}
else {
$osver = $ent->{os};
@ -620,7 +629,12 @@ sub mknetboot
# turn off the selinux
if ($osver =~ m/fedora12/ || $osver =~ m/fedora13/) {
$kcmdline .= " selinux=0";
$kcmdline .= " selinux=0 ";
}
# if kdump service is enbaled, add "crashkernel=" and "kdtarget="
if ($dump) {
$kcmdline .= " crashkernel=256M\@32M dump=$dump ";
}
# add the addkcmdline attribute to the end

View File

@ -199,8 +199,8 @@ sub process_request {
}
}
# TODO: following the old genimage code, to update the stateles-only files/directories
# another file should be /opt/xcat/xcatdsklspost, but it seems not necessary
# TODO: following the old genimage code, to update the stateles-only files/directories
# # another file should be /opt/xcat/xcatdsklspost, but it seems not necessary
xCAT::Utils->runcmd("mv $rootimg_dir/etc/init.d/statelite $rootimg_dir/.statebackup/statelite ", 0, 1) if ( -e "$rootimg_dir/etc/init.d/statelite");
if ( -e "$rootimg_dir/usr/share/dracut" ) {
# currently only used for redhat families, not available for SuSE families

View File

@ -109,7 +109,6 @@ sub process_request {
$callback->({error=>["The linuximage table cannot be opened."],errorcode=>[1]});
return;
}
# get the os, arch, and profile from the image name table.
(my $ref) = $osimagetab->getAttribs({imagename => $imagename}, 'osvers', 'osarch', 'profile');
if (!$ref) {

View File

@ -518,6 +518,38 @@ ResolveLinks
# make sure mtab points to the right place:
/bin/ln -sf /proc/mounts ${TMPFS}/etc/mtab
# create /etc/sysconfig/network-scripts/
for i in `/bin/cat /proc/cmdline`; do
KEY=`/bin/echo $i | /bin/awk -F= '{print $1}'`
if [ "$KEY" = "ifname" ]; then
ifname=`/bin/echo $i | /bin/awk -F= '{print $2}'`
MACX=${ifname#*:}
ETHX=${ifname%:$MACX*}
break
elif [ "$KEY" = "netdev" ]; then
ETHX=$netdev
MACX=`/sbin/ip link show $netdev | /bin/grep ether | /bin/awk '{print $2}'`
break
elif [ "$KEY" = "BOOTIF" ]; then
MACX=$BOOTIF
ETHX=`/sbin/ifconfig | /bin/grep -i $BOOTIF | /bin/awk '{print $1}'`
break
fi
done
if [ ! -z "$MACX" ] && [ ! -z "$ETHX" ]; then
if [ ! -e $MNTDIR/etc/sysconfig/network-scripts/ifcfg-$ETHX ]; then
/bin/touch $MNTDIR/etc/sysconfig/network-scripts/ifcfg-$ETHX
fi
echo "DEVICE=$ETHX" > $MNTDIR/etc/sysconfig/network-scripts/ifcfg-$ETHX
echo "BOOTPROTO=dhcp" >> $MNTDIR/etc/sysconfig/network-scripts/ifcfg-$ETHX
echo "HWADDR=$MACX" >> $MNTDIR/etc/sysconfig/network-scripts/ifcfg-$ETHX
echo "ONBOOT=yes" >> $MNTDIR/etc/sysconfig/network-scripts/ifcfg-$ETHX
fi
/bin/cat /etc/resolv.conf > $MNTDIR/etc/resolv.conf
# catch all hack for debugging:
#cp -r -a ${DEFAULT}/* /.snapshot/tmpfs/
# foo

View File

@ -1,6 +1,7 @@
#!/bin/sh
echo $drivers
dracut_install wget cpio gzip dash modprobe touch
dracut_install wget cpio gzip dash modprobe touch echo cut
dracut_install grep ifconfig hostname awk egrep grep dirname
dracut_install fsck.ext3 fsck.ext4
inst "$moddir/xcatroot" "/sbin/xcatroot"
inst_hook cmdline 10 "$moddir/xcat-cmdline.sh"

View File

@ -1,5 +1,6 @@
#!/bin/sh
echo $drivers
dracut_install wget cpio gzip dash modprobe wc touch
dracut_install wget cpio gzip dash modprobe wc touch echo cut
dracut_install grep ifconfig hostname awk egrep grep dirname expr
dracut_install fsck.ext3 fsck.ext4
inst_hook pre-pivot 5 "$moddir/xcat-prepivot.sh"

View File

@ -72,7 +72,7 @@ GetOptions(
'l=s' => \$rootlimit,
't=s' => \$tmplimit,
'k=s' => \$kernelver,
'permission=s' => \$permission
'permission=s' => \$permission,
);
# if "Table.pm" can be found here, the attributes in linuximage and osimage will be updated
@ -247,7 +247,7 @@ unless ($osver and $profile) {
print ' genimage [ -i <nodebootif> ] [ -n <nodenetdrivers> ] [-r <otherifaces>] -k <KERNELVER> <imagename>'."\n";
print " --permission only works with statelite mode\n";
print "Examples:\n";
print " genimage -i eth0 -n tg3 -o centos5.1 -p compute\n";
print " genimage -i eth0 -n tg3 -o centos5.1 -p compute \n";
print " genimage -i eth0 -r eth1,eth2 -n tg3,bnx2 -o centos5.1 -p compute\n";
print " genimage -i eth0 -n igb,e1000e,e1000,bnx2,tg3 -o centos5.4 -p nfsroot\n";
print " genimage -i eth0 -n igb,e1000e,e1000,bnx2,tg3 -o centos5.4 -p nfsroot --permission 777\n";
@ -1354,9 +1354,16 @@ sub isnetdriver {
sub postscripts { # TODO: customized postscripts
sub postscripts {
generic_post();
# TODO: workaround for kdump on RHEL6
# add one fake command: fsck.nfs
unless ( -x "$rootimg_dir/sbin/fsck.nfs" ) {
system("echo true > $rootimg_dir/sbin/fsck.nfs; chmod a+x $rootimg_dir/sbin/fsck.nfs");
}
if( ! -d "$rootimg_dir/opt/xcat/") {
mkdir "$rootimg_dir/opt/xcat/";
}

50
xCAT/postscripts/enablekdump Executable file
View File

@ -0,0 +1,50 @@
#!/bin/bash
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
#(C)IBM Corp
#
for i in `cat /proc/cmdline`; do
KEY=`echo $i | awk -F= '{print $1}'`
if [ "$KEY" = "dump" ]; then
DUMP=`echo $i |awk -F= '{print $2}'`
if [ ! -z "$XCAT" ]; then
break
fi
elif [ "$KEY" = "XCAT" ]; then
XCAT=`echo $i |awk -F= '{print $2}'`
if [ ! -z "$DUMP" ]; then
break
fi
fi
done
if [ ! -z "$DUMP" ]; then
# parse "dump=<proto>://<nfsserver_IP>/<directory>"
KDPATH=${DUMP#*:}
KDPROTO=${DUMP%:$KDPATH*}
KDPATH=${KDPATH/\/\//}
KDIP=`echo $KDPATH | cut -d'/' -f1`
KDPATH=${KDPATH/$KDIP/}
# if "dump=<proto>:///<directory>", use $xcatmaster as the default NFS server
if [ -z $KDIP ]; then
KDIP=${XCAT%:*}
fi
if [ "$KDPROTO" = "nfs" ]; then
echo "net $KDIP:$KDPATH" > /etc/kdump.conf
fi
# workaround for RHEL6
KDTMPSERVER=${XCAT%:*}
/bin/mount $KDTMPSERVER:/install/kdump/tmp /var/tmp
/etc/init.d/kdump restart
/bin/umount /var/tmp
else
/bin/echo "The kdump server is not configured"
fi
exit 0

View File

@ -69,6 +69,7 @@ mkdir -p $RPM_BUILD_ROOT/etc/apache2/conf.d
mkdir -p $RPM_BUILD_ROOT/etc/httpd/conf.d
mkdir -p $RPM_BUILD_ROOT/install/postscripts
mkdir -p $RPM_BUILD_ROOT/install/prescripts
mkdir -p $RPM_BUILD_ROOT/install/kdump/tmp # workaround for RHEL6
mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/
cd $RPM_BUILD_ROOT/%{prefix}/share/xcat/