From 89a13f06181aad0bd97e8be7edb086c61df110f9 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Tue, 6 Nov 2007 21:28:02 +0000 Subject: [PATCH] More changes to nodeset netboot, a trial run at nodeset netboot, not being intelligent yet about using tftp for only the smaller image git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@38 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- .../usr/lib/xcat/plugins/centos.pm | 68 ++++++++++++++++--- .../usr/lib/xcat/plugins/destiny.pm | 13 ++-- 2 files changed, 67 insertions(+), 14 deletions(-) diff --git a/xCAT-server-2.0/usr/lib/xcat/plugins/centos.pm b/xCAT-server-2.0/usr/lib/xcat/plugins/centos.pm index 82146e890..6f9a002bc 100644 --- a/xCAT-server-2.0/usr/lib/xcat/plugins/centos.pm +++ b/xCAT-server-2.0/usr/lib/xcat/plugins/centos.pm @@ -27,8 +27,8 @@ my %numdiscs = ( sub handled_commands { return { copycd => "centos", + mknetboot => "nodetype:os=centos.*", mkinstall => "nodetype:os=centos.*", - mknetboot => "centos" } } @@ -44,21 +44,21 @@ sub process_request { } elsif ($request->{command}->[0] eq 'mkinstall') { return mkinstall($request,$callback,$doreq); } elsif ($request->{command}->[0] eq 'mknetboot') { - return makenetboot($request,$callback,$doreq); + return mknetboot($request,$callback,$doreq); } } -sub makenetboot { +sub mknetboot { my $req = shift; my $callback = shift; my $doreq = shift; + my $tftpdir = "/tftpboot"; + my $nodes = @{$request->{node}}; my @args=@{$req->{arg}}; - unless (grep /^centos/,@args) { - return; - } - (my $osver,my $arch, my $profile)=split(/-/,$args[0],3); - my $installroot; + my @nodes = @{$req->{node}}; + my $ostab = xCAT::Table->new('nodetype'); my $sitetab = xCAT::Table->new('site'); + my $installroot; if ($sitetab) { (my $ref) = $sitetab->getAttribs({key=>installdir},value); print Dumper($ref); @@ -66,6 +66,58 @@ sub makenetboot { $installroot = $ref->{value}; } } + foreach $node (@nodes) { + my $ent = $ostab->getNodeAttribs($node,['os','arch','profile']); + unless ($ent->{os} and $ent->{arch} and $ent->{profile}) { + $callback->({error=>["Insufficient nodetype entry for $node"],errorcode=>[1]}); + next; + } + 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/"); + } + 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 "/$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; + } + my $restab = xCAT::Table->new('noderes'); + my $hmtab = xCAT::Table->new('nodehm'); + my $ent = $restab->getNodeAttribs($node,['serialport','primarynic']); + my $kcmdline; + 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"; + } + } + $restab->setNodeAttribs($node,{ + kernel=>"xcat/netboot/$osver/$arch/kernel", + initrd=>"xcat/netboot/$osver/$arch/rootimg.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; diff --git a/xCAT-server-2.0/usr/lib/xcat/plugins/destiny.pm b/xCAT-server-2.0/usr/lib/xcat/plugins/destiny.pm index d16d54401..0a8c1da24 100644 --- a/xCAT-server-2.0/usr/lib/xcat/plugins/destiny.pm +++ b/xCAT-server-2.0/usr/lib/xcat/plugins/destiny.pm @@ -47,12 +47,16 @@ sub setdestiny { my $state = $req->{arg}->[0]; if ($state eq "next") { return nextdestiny(); - } elsif ($state =~ /^install$/ or $state eq "install") { + } elsif ($state =~ /^install$/ or $state eq "install" or $state eq "netboot") { + chomp($state); + $subreq->({command=>["mk$state"], + node=>$req->{node}}, \&relay_response); + if ($errored) { return; } my $nodetype = xCAT::Table->new('nodetype'); foreach (@{$req->{node}}) { my $ntent = $nodetype->getNodeAttribs($_,[qw(os arch profile)]); if ($ntent and $ntent->{os}) { - $state = "install ".$ntent->{os}; + $state .= " ".$ntent->{os}; } if ($ntent and $ntent->{arch}) { $state .= "-".$ntent->{arch}; @@ -60,11 +64,8 @@ sub setdestiny { if ($ntent and $ntent->{profile}) { $state .= "-".$ntent->{profile}; } - $chaintab->setNodeAttribs($_,{currchain=>"boot"}); + unless ($state =~ /^netboot/) { $chaintab->setNodeAttribs($_,{currchain=>"boot"}); }; } - $subreq->({command=>["mkinstall"], - node=>$req->{node}}, \&relay_response); - if ($errored) { return; } } elsif ($state eq "shell" or $state eq "standby" or $state =~ /^runcmd/) { my $noderes=xCAT::Table->new('noderes'); my $nodetype = xCAT::Table->new('nodetype');