From decc71ac21ef348a0d4d14b9fd50652607840f58 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Wed, 16 Jan 2008 21:14:50 +0000 Subject: [PATCH] Provide enhanced iSCSI support for the opportunity for more seamless operation git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@280 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT-2.0/xCAT/Postage.pm | 2 + xCAT-server-2.0/etc/xcat/postscripts.rules | 3 ++ xCAT-server-2.0/sbin/xcatd | 37 ++++++++++++++++++- .../xcat/install/fedora/iscsi.ppc64.tmpl | 1 - .../share/xcat/install/fedora/iscsi.tmpl | 1 - .../share/xcat/install/rh/iscsi.ppc64.tmpl | 1 - .../share/xcat/install/rh/iscsi.tmpl | 1 - xCAT/postscripts/locktftpdir.awk | 20 ++++++++++ xCAT/postscripts/setnetboot.awk | 21 +++++++++++ xCAT/postscripts/unlocktftpdir.awk | 20 ++++++++++ xCAT/postscripts/uploadboot | 28 ++++++++++++++ xCAT/xCAT.spec | 3 ++ 12 files changed, 133 insertions(+), 5 deletions(-) create mode 100755 xCAT/postscripts/locktftpdir.awk create mode 100755 xCAT/postscripts/setnetboot.awk create mode 100755 xCAT/postscripts/unlocktftpdir.awk create mode 100755 xCAT/postscripts/uploadboot diff --git a/perl-xCAT-2.0/xCAT/Postage.pm b/perl-xCAT-2.0/xCAT/Postage.pm index bff4a0594..a3575b9f6 100644 --- a/perl-xCAT-2.0/xCAT/Postage.pm +++ b/perl-xCAT-2.0/xCAT/Postage.pm @@ -45,6 +45,8 @@ sub writescript { } print $script "MASTER=".$master."\n"; print $script "export MASTER\n"; + print $script "NODE=$node\n"; + print $script "export NODE\n"; my $et = $typetab->getNodeAttribs($node,['os','arch']); unless ($et and $et->{'os'} and $et->{'arch'}) { die "No os/arch setting in nodetype table for $node"; diff --git a/xCAT-server-2.0/etc/xcat/postscripts.rules b/xCAT-server-2.0/etc/xcat/postscripts.rules index e00a60e9b..42b11bd8d 100644 --- a/xCAT-server-2.0/etc/xcat/postscripts.rules +++ b/xCAT-server-2.0/etc/xcat/postscripts.rules @@ -189,6 +189,9 @@ ALL { updateflag.awk $MASTER 3002 } +NODERANGE=iscsi { + uploadboot +} # hardcode networking #OSVER=sl[34].* or OSVER=centos.* or OSVER=rh.* or OSVER=sles.* or OSVER=suse.* { # hardnis diff --git a/xCAT-server-2.0/sbin/xcatd b/xCAT-server-2.0/sbin/xcatd index 152455af6..fcea466f1 100755 --- a/xCAT-server-2.0/sbin/xcatd +++ b/xCAT-server-2.0/sbin/xcatd @@ -6,6 +6,7 @@ BEGIN } use lib "$::XCATROOT/lib/perl"; use xCAT::Utils; +use File::Path; use IO::Socket::SSL; if (xCAT::Utils->isLinux()) { @@ -135,6 +136,7 @@ if (xCAT::Utils->isLinux()) { close($conn); next; } + my $tftpdir = "/tftpboot/"; eval { alarm(2); print $conn "ready\n"; @@ -154,7 +156,40 @@ if (xCAT::Utils->isLinux()) { plugin_command(\%request,undef,\&convey_response); exit(0); } - } + } elsif ($text =~ /^unlocktftpdir/) { #TODO: only nodes in install state should be allowed + close($conn); + mkpath("$tftpdir/xcat/$node"); + chmod 01777,"$tftpdir/xcat/$node"; + chmod 0666,glob("$tftpdir/xcat/$node/*"); + } elsif ($text =~ /locktftpdir/) { + chmod 0755,"$tftpdir/xcat/$node"; + chmod 0644,glob("$tftpdir/xcat/$node/*"); + } elsif ($text =~ /^setnetboot/) { + $text =~ s/^setnetboot\s+//; + my $kname; + my $iname; + my $kcmdline; + ($kname,$iname,$kcmdline) = split(/\s+/,$text,3); + chomp($kcmdline); + my $noderestab = xCAT::Table->new('noderes',-create=>1); + $noderestab->setNodeAttribs($node,{kernel=>"xcat/$node/$kname",initrd=>"xcat/$node/$iname",kcmdline=>$kcmdline}); + my $chaintab = xCAT::Table->new('chain',-create=>1); + $chaintab->setNodeAttribs($node,{currstate=>'netboot',currchain=>'netboot'}); + $noderestab->close; + $chaintab->close; + undef $noderestab; + undef $chaintab; + my %request = ( + command => [ 'nodeset' ], + node => [ $node ], + arg => [ 'enact' ], + ); + my $pid=fork(); + unless ($pid) { #fork off the nodeset and potential slowness + plugin_command(\%request,undef,\&convey_response); + exit(0); + } + } alarm(2); } alarm(0); diff --git a/xCAT-server-2.0/share/xcat/install/fedora/iscsi.ppc64.tmpl b/xCAT-server-2.0/share/xcat/install/fedora/iscsi.ppc64.tmpl index 54db75656..07a03c2dd 100644 --- a/xCAT-server-2.0/share/xcat/install/fedora/iscsi.ppc64.tmpl +++ b/xCAT-server-2.0/share/xcat/install/fedora/iscsi.ppc64.tmpl @@ -39,7 +39,6 @@ iscsi --ipaddr #TABLE:iscsi:$NODE:server# --user "#TABLE:iscsi:$NODE:userid#" -- #/boot really significant for this sort of setup nowadays? part None --fstype "PPC PReP Boot" --size 8 part /boot --size 50 --fstype ext3 -part swap --size 1024 part / --size 1 --grow --fstype ext3 #RAID 0 /scr for performance diff --git a/xCAT-server-2.0/share/xcat/install/fedora/iscsi.tmpl b/xCAT-server-2.0/share/xcat/install/fedora/iscsi.tmpl index 153fec914..4de2baf64 100644 --- a/xCAT-server-2.0/share/xcat/install/fedora/iscsi.tmpl +++ b/xCAT-server-2.0/share/xcat/install/fedora/iscsi.tmpl @@ -38,7 +38,6 @@ iscsi --ipaddr #TABLE:iscsi:$NODE:server# --user "#TABLE:iscsi:$NODE:userid#" -- #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -part swap --size 1024 part / --size 1 --grow --fstype ext3 #RAID 0 /scr for performance diff --git a/xCAT-server-2.0/share/xcat/install/rh/iscsi.ppc64.tmpl b/xCAT-server-2.0/share/xcat/install/rh/iscsi.ppc64.tmpl index 575d4cf88..f24eca66d 100644 --- a/xCAT-server-2.0/share/xcat/install/rh/iscsi.ppc64.tmpl +++ b/xCAT-server-2.0/share/xcat/install/rh/iscsi.ppc64.tmpl @@ -39,7 +39,6 @@ iscsi --ipaddr #TABLE:iscsi:$NODE:server# --user "#TABLE:iscsi:$NODE:userid#" -- #/boot really significant for this sort of setup nowadays? part None --fstype "PPC PReP Boot" --size 8 part /boot --size 50 --fstype ext3 -part swap --size 1024 part / --size 1 --grow --fstype ext3 #RAID 0 /scr for performance diff --git a/xCAT-server-2.0/share/xcat/install/rh/iscsi.tmpl b/xCAT-server-2.0/share/xcat/install/rh/iscsi.tmpl index 6e17514f0..73beb37ed 100644 --- a/xCAT-server-2.0/share/xcat/install/rh/iscsi.tmpl +++ b/xCAT-server-2.0/share/xcat/install/rh/iscsi.tmpl @@ -38,7 +38,6 @@ iscsi --ipaddr #TABLE:iscsi:$NODE:server# --user "#TABLE:iscsi:$NODE:userid#" -- #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -part swap --size 1024 part / --size 1 --grow --fstype ext3 #RAID 0 /scr for performance diff --git a/xCAT/postscripts/locktftpdir.awk b/xCAT/postscripts/locktftpdir.awk new file mode 100755 index 000000000..7d22b6e56 --- /dev/null +++ b/xCAT/postscripts/locktftpdir.awk @@ -0,0 +1,20 @@ +#!/usr/bin/awk -f +BEGIN { + xcatdhost = ARGV[1] + xcatdport = ARGV[2] + + ns = "/inet/tcp/0/" ARGV[1] "/" xcatdport + + while(1) { + if((ns |& getline) > 0) + print $0 | "logger -t xcat" + + if($0 == "ready") + print "locktftpdir" |& ns + if($0 == "done") + break + } + close(ns) + + exit 0 +} diff --git a/xCAT/postscripts/setnetboot.awk b/xCAT/postscripts/setnetboot.awk new file mode 100755 index 000000000..89deea9ee --- /dev/null +++ b/xCAT/postscripts/setnetboot.awk @@ -0,0 +1,21 @@ +#!/usr/bin/awk -f +BEGIN { + xcatdhost = ARGV[1] + xcatdport = ARGV[2] + kernel = ARGV[3] + initrd = ARGV[4] + kcmd = ARGV[5] + ns = "/inet/tcp/0/" ARGV[1] "/" xcatdport + + while(1) { + if((ns |& getline) > 0) + print $0 | "logger -t xcat" + + if($0 == "ready") + print "setnetboot "kernel" "initrd" "kcmd |& ns + if($0 == "done") + break + } + close(ns) + exit 0 +} diff --git a/xCAT/postscripts/unlocktftpdir.awk b/xCAT/postscripts/unlocktftpdir.awk new file mode 100755 index 000000000..dfe7ae0b9 --- /dev/null +++ b/xCAT/postscripts/unlocktftpdir.awk @@ -0,0 +1,20 @@ +#!/usr/bin/awk -f +BEGIN { + xcatdhost = ARGV[1] + xcatdport = ARGV[2] + + ns = "/inet/tcp/0/" ARGV[1] "/" xcatdport + + while(1) { + if((ns |& getline) > 0) + print $0 | "logger -t xcat" + + if($0 == "ready") + print "unlocktftpdir" |& ns + if($0 == "done") + break + } + close(ns) + + exit 0 +} diff --git a/xCAT/postscripts/uploadboot b/xCAT/postscripts/uploadboot new file mode 100755 index 000000000..46aed58a8 --- /dev/null +++ b/xCAT/postscripts/uploadboot @@ -0,0 +1,28 @@ +#!/bin/sh +if [ -r /boot/etc/yaboot.conf ]; then + KNAME=`grep ^image /boot/etc/yaboot.conf|head -n 1|cut -d= -f 2|sed -e 's!^/!!'` + KERNEL=/boot/$KNAME + KERNEL=`echo $KERNEL|sed -e 's!//!/!g'` + INAME=`grep initrd /boot/etc/yaboot.conf|head -n 1|cut -d= -f 2|sed -e 's!^/!!'` + INITRD=/boot/$INAME + INITRD=`echo $INITRD|sed -e 's!//!/!g'` + KCMDLINE=`grep append= /boot/etc/yaboot.conf|head -n 1|cut -d= -f 2-` + KCMDLINE=`echo $KCMDLINE|sed -e 's! rhgb!!'|sed -e 's!"!!g'` +elif [ -r /boot/grub/menu.lst ]; then + KNAME=`grep -v ^# /boot/grub/menu.lst|grep -v title|grep kernel|cut -d' ' -f 2|sed -e 's!/boot/!!'` + KERNEL=/boot/$KNAME + KCMDLINE=`grep -v ^# /boot/grub/menu.lst|grep -v title|grep kernel|cut -d' ' -f 3-|sed -e 's! rhgb!!'` + INAME=`grep -v ^# /boot/grub/menu.lst|grep -v title|grep initrd|cut -d' ' -f 2|sed -e 's!/boot/!!'` + INITRD=/boot/$INAME + INITRD=`echo $INITRD|sed -e 's!//!/!g'` + +fi +mkdir /servboot +`dirname $0`/unlocktftpdir.awk $MASTER 3002 +mount -o nolock $MASTER:/tftpboot/xcat/$NODE /servboot +cp $KERNEL /servboot/$KNAME +cp $INITRD /servboot/$INAME +umount /servboot +`dirname $0`/locktftpdir.awk $MASTER 3002 +rmdir /servboot +`dirname $0`/setnetboot.awk $MASTER 3002 $KNAME $INAME "$KCMDLINE" diff --git a/xCAT/xCAT.spec b/xCAT/xCAT.spec index a87fc7bb2..1dd1deafd 100644 --- a/xCAT/xCAT.spec +++ b/xCAT/xCAT.spec @@ -66,6 +66,9 @@ if [ "$1" = "1" ]; then #Only if installing for the fist time.. cp /root/.ssh/id_rsa.pub /install/postscripts/.ssh/authorized_keys mkdir -p /var/log/consoles + if ! grep /tftpboot /etc/exports; then + echo '/tftpboot *(rw,root_squash,sync)' >> /etc/exports #SECURITY: this has potential for sharing private host/user keys + fi if ! grep /install /etc/exports; then echo '/install *(ro,no_root_squash,sync)' >> /etc/exports #SECURITY: this has potential for sharing private host/user keys service nfs restart