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
This commit is contained in:
jbjohnso 2007-11-06 21:28:02 +00:00
parent eeca5a7634
commit 89a13f0618
2 changed files with 67 additions and 14 deletions

View File

@ -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;

View File

@ -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');