-Fix packimage to strip dots and numbers to derive base os lists
-Modify centos plugin to use the built in stateless support git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@441 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
64bef2058a
commit
bf7f93e286
@ -59,6 +59,11 @@ sub mknetboot {
|
||||
my @nodes = @{$req->{node}};
|
||||
my $ostab = xCAT::Table->new('nodetype');
|
||||
my $sitetab = xCAT::Table->new('site');
|
||||
(my $sent) = $sitetab->getAttribs({key=>master},value);
|
||||
my $imgsrv;
|
||||
if ($sent and $sent->{value}) {
|
||||
$imgsrv = $sent->{value};
|
||||
}
|
||||
my $installroot;
|
||||
if ($sitetab) {
|
||||
(my $ref) = $sitetab->getAttribs({key=>installdir},value);
|
||||
@ -76,100 +81,58 @@ sub mknetboot {
|
||||
my $osver = $ent->{os};
|
||||
my $arch = $ent->{arch};
|
||||
my $profile = $ent->{profile};
|
||||
unless (-r "/$installroot/netboot/$osver/$arch/$profile/kernel" and -r "$installroot/netboot/$osver/$arch/$profile/rootimg.gz") {
|
||||
makenetboot($osver,$arch,$profile,$installroot,$callback);
|
||||
mkpath("/$tftpdir/xcat/netboot/$osver/$arch/$profile/");
|
||||
copy("/$installroot/netboot/$osver/$arch/$profile/kernel","/$tftpdir/xcat/netboot/$osver/$arch/$profile/");
|
||||
copy("/$installroot/netboot/$osver/$arch/$profile/rootimg.gz","/$tftpdir/xcat/netboot/$osver/$arch/$profile/");
|
||||
my $suffix = 'gz';
|
||||
if (-r "/$installroot/netboot/$osver/$arch/$profile/rootimg.sfs") {
|
||||
$suffix = 'sfs';
|
||||
}
|
||||
unless (-r "/$tftpdir/xcat/netboot/$osver/$arch/$profile/kernel" and -r "/$tftpdir/xcat/netboot/$osver/$arch/$profile/rootimg.gz") {
|
||||
mkpath("/$tftpdir/xcat/netboot/$osver/$arch/$profile/");
|
||||
copy("/$installroot/netboot/$osver/$arch/$profile/kernel","/$tftpdir/xcat/netboot/$osver/$arch/$profile/");
|
||||
copy("/$installroot/netboot/$osver/$arch/$profile/rootimg.gz","/$tftpdir/xcat/netboot/$osver/$arch/$profile/");
|
||||
unless ((-r "/$installroot/netboot/$osver/$arch/$profile/rootimg.gz" or
|
||||
-r "/$installroot/netboot/$osver/$arch/$profile/rootimg.sfs") and
|
||||
-r "/$installroot/netboot/$osver/$arch/$profile/kernel" and
|
||||
-r "/$installroot/netboot/$osver/$arch/$profile/initrd.gz") {
|
||||
$callback->({error=>["No packed image for platform $osver, architecture $arch, and profile $profile, please run packimage (i.e. packimage -o $osver -p $profile -a $arch"],errorcode=>[1]});
|
||||
next;
|
||||
}
|
||||
unless (-r "/$tftpdir/xcat/netboot/$osver/$arch/$profile/kernel" and -r "/$tftpdir/xcat/netboot/$osver/$arch/$profile/rootimg.gz") {
|
||||
$callback->({error=>["Netboot image creation failed for $node"],errorcode=>[1]});
|
||||
next;
|
||||
mkpath("/$tftpdir/xcat/netboot/$osver/$arch/$profile/");
|
||||
#TODO: only copy if newer...
|
||||
copy("/$installroot/netboot/$osver/$arch/$profile/kernel","/$tftpdir/xcat/netboot/$osver/$arch/$profile/");
|
||||
copy("/$installroot/netboot/$osver/$arch/$profile/initrd.gz","/$tftpdir/xcat/netboot/$osver/$arch/$profile/");
|
||||
unless (-r "/$tftpdir/xcat/netboot/$osver/$arch/$profile/kernel" and -r "/$tftpdir/xcat/netboot/$osver/$arch/$profile/initrd.gz") {
|
||||
$callback->({error=>["Copying to /$tftpdir/xcat/netboot/$osver/$arch/$profile failed"],errorcode=>[1]});
|
||||
next;
|
||||
}
|
||||
my $restab = xCAT::Table->new('noderes');
|
||||
my $hmtab = xCAT::Table->new('nodehm');
|
||||
my $ent = $restab->getNodeAttribs($node,['serialport','primarynic']);
|
||||
my $kcmdline;
|
||||
my $ient = $restab->getNodeAttribs($node,['servicenode']);
|
||||
my $ipfn = my_ip_facing($node);
|
||||
if ($ient and $ient->{servicenode}) { #Servicenode attribute overrides
|
||||
$imgsrv = $ient=>{servicenode};
|
||||
} elsif ($ipfn) {
|
||||
$imgsrv = $ipfn; #guessing self is second best
|
||||
} # resort to master value in site table only if not local to node...
|
||||
unless ($imgsrv) {
|
||||
$callback->({error=>["Unable to determine or reasonably guess the image server for $node"],errorcode=>[1]});
|
||||
next;
|
||||
}
|
||||
my $kcmdline = "imgurl=http://$imgsrv/install/netboot/$osver/$arch/$profile/rootimg.$suffix ";
|
||||
if (defined $ent->{serialport}) {
|
||||
my $sent = $hmtab->getNodeAttribs($node,['serialspeed','serialflow']);
|
||||
unless ($sent->{serialspeed}) {
|
||||
$callback->({error=>["serialport defined, but no serialspeed for $node in nodehm table"],errorcode=>[1]});
|
||||
next;
|
||||
}
|
||||
$kcmdline .= "console=ttyS".$ent->{serialport}.",".$sent->{serialspeed};
|
||||
if ($sent->{serialflow} =~ /(hard|tcs|ctsrts)/) {
|
||||
$kcmdline .= "n8r";
|
||||
}
|
||||
my $sent = $hmtab->getNodeAttribs($node,['serialspeed','serialflow']);
|
||||
unless ($sent->{serialspeed}) {
|
||||
$callback->({error=>["serialport defined, but no serialspeed for $node in nodehm table"],errorcode=>[1]});
|
||||
next;
|
||||
}
|
||||
$kcmdline .= "console=ttyS".$ent->{serialport}.",".$sent->{serialspeed};
|
||||
if ($sent->{serialflow} =~ /(hard|tcs|ctsrts)/) {
|
||||
$kcmdline .= "n8r";
|
||||
}
|
||||
}
|
||||
$restab->setNodeAttribs($node,{
|
||||
kernel=>"xcat/netboot/$osver/$arch/$profile/kernel",
|
||||
initrd=>"xcat/netboot/$osver/$arch/$profile/rootimg.gz",
|
||||
initrd=>"xcat/netboot/$osver/$arch/$profile/initrd.gz",
|
||||
kcmdline=>$kcmdline
|
||||
});
|
||||
}
|
||||
}
|
||||
sub makenetboot {
|
||||
my $osver = shift;
|
||||
my $arch = shift;
|
||||
my $profile = shift;
|
||||
my $installroot = shift;
|
||||
my $callback = shift;
|
||||
unless ($installroot) {
|
||||
$callback->({error=>["No installdir defined in site table"],errorcode=>[1]});
|
||||
return;
|
||||
}
|
||||
my $srcdir = "/$installroot/$osver/$arch";
|
||||
unless ( -d $srcdir."/repodata" ) {
|
||||
$callback->({error=>["copycds has not been run for $osver/$arch"],errorcode=>[1]});
|
||||
return;
|
||||
}
|
||||
my $yumconf;
|
||||
open($yumconf,">","/tmp/mknetboot.$$.yum.conf");
|
||||
print $yumconf "[$osver-$arch]\nname=$osver-$arch\nbaseurl=file:///$srcdir\ngpgcheck=0\n";
|
||||
close($yumconf);
|
||||
system("yum -y -c /tmp/mknetboot.$$.yum.conf --installroot=$installroot/netboot/$osver/$arch/$profile/rootimg/ --disablerepo=* --enablerepo=$osver-$arch install bash dhclient kernel openssh-server openssh-clients dhcpv6_client vim-minimal");
|
||||
my $cfgfile;
|
||||
open($cfgfile,">","$installroot/netboot/$osver/$arch/$profile/rootimg/etc/fstab");
|
||||
print $cfgfile "devpts /dev/pts devpts gid=5,mode=620 0 0\n";
|
||||
print $cfgfile "tmpfs /dev/shm tmpfs defaults 0 0\n";
|
||||
print $cfgfile "proc /proc proc defaults 0 0\n";
|
||||
print $cfgfile "sysfs /sys sysfs defaults 0 0\n";
|
||||
close($cfgfile);
|
||||
open ($cfgfile,">","$installroot/netboot/$osver/$arch/$profile/rootimg/etc/sysconfig/network");
|
||||
print $cfgfile "NETWORKING=yes\n";
|
||||
close($cfgfile);
|
||||
open ($cfgfile,">","$installroot/netboot/$osver/$arch/$profile/rootimg/etc/sysconfig/network-scripts/ifcfg-eth0");
|
||||
print $cfgfile "ONBOOT=yes\nBOOTPROTO=dhcp\nDEVICE=eth0\n";
|
||||
close($cfgfile);
|
||||
open ($cfgfile,">","$installroot/netboot/$osver/$arch/$profile/rootimg/etc/sysconfig/network-scripts/ifcfg-eth1");
|
||||
print $cfgfile "ONBOOT=yes\nBOOTPROTO=dhcp\nDEVICE=eth1\n";
|
||||
close($cfgfile);
|
||||
link("$installroot/netboot/$osver/$arch/$profile/rootimg/sbin/init","$installroot/netboot/$osver/$arch/$profile/rootimg/init");
|
||||
rename(<$installroot/netboot/$osver/$arch/$profile/rootimg/boot/vmlinuz*>,"$installroot/netboot/$osver/$arch/$profile/kernel");
|
||||
if (-d "$installroot/postscripts/hostkeys") {
|
||||
for my $key (<$installroot/postscripts/hostkeys/*key>) {
|
||||
copy ($key,"$installroot/netboot/$osver/$arch/$profile/rootimg/etc/ssh/");
|
||||
}
|
||||
chmod 0600,</$installroot/netboot/$osver/$arch/$profile/rootimg/etc/ssh/*key>;
|
||||
}
|
||||
if (-d "/$installroot/postscripts/.ssh") {
|
||||
mkpath("/$installroot/netboot/$osver/$arch/$profile/rootimg/root/.ssh");
|
||||
chmod(0700,"/$installroot/netboot/$osver/$arch/$profile/rootimg/root/.ssh/");
|
||||
for my $file (</$installroot/postscripts/.ssh/*>) {
|
||||
copy ($file,"/$installroot/netboot/$osver/$arch/$profile/rootimg/root/.ssh/");
|
||||
}
|
||||
chmod(0600,</$installroot/netboot/$osver/$arch/$profile/rootimg/root/.ssh/*>);
|
||||
}
|
||||
my $oldpath=cwd;
|
||||
chdir("$installroot/netboot/$osver/$arch/$profile/rootimg");
|
||||
system("find . '!' -wholename './usr/share/man*' -a '!' -wholename './usr/share/locale*' -a '!' -wholename './usr/share/i18n*' -a '!' -wholename './var/cache/yum*' -a '!' -wholename './usr/share/doc*' -a '!' -wholename './usr/lib/locale*' -a '!' -wholename './boot*' |cpio -H newc -o | gzip -c - > ../rootimg.gz");
|
||||
chdir($oldpath);
|
||||
}
|
||||
|
||||
sub mkinstall {
|
||||
my $request = shift;
|
||||
|
@ -36,7 +36,7 @@ sub process_request {
|
||||
"method|m=s" => \$method
|
||||
);
|
||||
my $distname = $osver;
|
||||
$distname =~ s/\d+$//;
|
||||
$distname =~ s/[0-9\.]+$//;
|
||||
unless ($installroot) {
|
||||
$callback->({error=>["No installdir defined in site table"],errorcode=>[1]});
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user