From 775941db70be9cc83b9ca1954205e88d83cdeb1c Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 25 Apr 2013 12:07:48 +0000 Subject: [PATCH] support for addkcmdline of osimage. According to the design, the linuximage:addkcmdline should be appended to kernel arguments of the nodes after "nodeset osimage=". git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@16062 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/pxe.pm | 20 ++++++++++++++++---- xCAT-server/lib/xcat/plugins/xnba.pm | 19 +++++++++++++++---- xCAT-server/lib/xcat/plugins/yaboot.pm | 25 +++++++++++++++++++++++-- 3 files changed, 54 insertions(+), 10 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/pxe.pm b/xCAT-server/lib/xcat/plugins/pxe.pm index 67a251513..e44c667de 100644 --- a/xCAT-server/lib/xcat/plugins/pxe.pm +++ b/xCAT-server/lib/xcat/plugins/pxe.pm @@ -86,8 +86,11 @@ sub setstate { my %machash = %{shift()}; my %nthash = %{shift()}; my $tftpdir = shift; + my %linuximghash = %{shift()}; + my $imgaddkcmdline=($linuximghash{'boottarget'})? undef:$linuximghash{'addkcmdline'}; + my $kern = $bphash{$node}->[0]; #$bptab->getNodeAttribs($node,['kernel','initrd','kcmdline']); - if (not $addkcmdlinehandled->{$node} and $kern->{addkcmdline}) { + if (not $addkcmdlinehandled->{$node} and ($kern->{addkcmdline} or ($imgaddkcmdline))) { #Implement the kcmdline append here for #most generic, least code duplication @@ -103,7 +106,8 @@ sub setstate { #I dislike spaces, tabs are cleaner, I'm too tired to change all the xCAT code. #I give in. - my $kcmdlinehack = $kern->{addkcmdline}; + my $kcmdlinehack = ($imgaddkcmdline)?$kern->{addkcmdline}." ".$imgaddkcmdline : $kern->{addkcmdline}; + while ($kcmdlinehack =~ /#NODEATTRIB:([^:#]+):([^:#]+)#/) { my $natab = xCAT::Table->new($1); @@ -130,6 +134,7 @@ sub setstate { } #$kern->{kcmdline} .= " ".$kern->{addkcmdline}; + $kern->{kcmdline} .= " ".$kcmdlinehack; ###hack end @@ -484,11 +489,12 @@ sub process_request { my $mactab = xCAT::Table->new('mac'); #to get all the hostnames my $typetab = xCAT::Table->new('nodetype'); my $restab = xCAT::Table->new('noderes'); + my $linuximgtab=xCAT::Table->new('linuximage',-create=>1); my %nrhash = %{$restab->getNodesAttribs(\@nodes,[qw(tftpdir)])}; my %bphash = %{$bptab->getNodesAttribs(\@nodes,[qw(kernel initrd kcmdline addkcmdline)])}; my %chainhash = %{$chaintab->getNodesAttribs(\@nodes,[qw(currstate)])}; my %machash = %{$mactab->getNodesAttribs(\@nodes,[qw(mac)])}; - my %nthash = %{$typetab->getNodesAttribs(\@nodes,[qw(os)])}; + my %nthash = %{$typetab->getNodesAttribs(\@nodes,[qw(os provmethod)])}; foreach (@nodes) { my %response; my $tftpdir; @@ -502,7 +508,13 @@ sub process_request { $response{node}->[0]->{data}->[0]= getstate($_,$tftpdir); $callback->(\%response); } elsif ($args[0]) { #If anything else, send it on to the destiny plugin, then setstate - ($rc,$errstr) = setstate($_,\%bphash,\%chainhash,\%machash,\%nthash,$tftpdir); + my $ent = $nthash{$_}->[0]; + my $osimgname = $ent->{'provmethod'}; + my $linuximghash=undef; + unless($osimgname =~ /^(install|netboot|statelite)$/){ + $linuximghash = $linuximgtab->getAttribs({imagename => $osimgname}, 'boottarget', 'addkcmdline'); + } + ($rc,$errstr) = setstate($_,\%bphash,\%chainhash,\%machash,\%nthash,$tftpdir,$linuximghash); if ($rc) { $response{node}->[0]->{errorcode}->[0]= $rc; $response{node}->[0]->{errorc}->[0]= $errstr; diff --git a/xCAT-server/lib/xcat/plugins/xnba.pm b/xCAT-server/lib/xcat/plugins/xnba.pm index 1aa239a56..f06208883 100644 --- a/xCAT-server/lib/xcat/plugins/xnba.pm +++ b/xCAT-server/lib/xcat/plugins/xnba.pm @@ -97,9 +97,11 @@ sub setstate { my %machash = %{shift()}; my %iscsihash = %{shift()}; my $tftpdir = shift; + my %linuximghash = %{shift()}; + my $imgaddkcmdline=($linuximghash{'boottarget'})? undef:$linuximghash{'addkcmdline'}; my $kern = $bphash{$node}->[0]; #$bptab->getNodeAttribs($node,['kernel','initrd','kcmdline']); unless ($addkcmdlinehandled->{$node}) { #Tag to let us know the plugin had a special syntax implemented for addkcmdline - if ($kern->{addkcmdline}) { + if ($kern->{addkcmdline} or ($imgaddkcmdline)) { #Implement the kcmdline append here for #most generic, least code duplication @@ -115,7 +117,7 @@ sub setstate { #I dislike spaces, tabs are cleaner, I'm too tired to change all the xCAT code. #I give in. - my $kcmdlinehack = $kern->{addkcmdline}; + my $kcmdlinehack = ($imgaddkcmdline)?$kern->{addkcmdline}." ".$imgaddkcmdline : $kern->{addkcmdline}; while ($kcmdlinehack =~ /#NODEATTRIB:([^:#]+):([^:#]+)#/) { my $natab = xCAT::Table->new($1); @@ -143,7 +145,6 @@ sub setstate { #$kern->{kcmdline} .= " ".$kern->{addkcmdline}; $kern->{kcmdline} .= " ".$kcmdlinehack; - ###hack end } @@ -516,6 +517,10 @@ sub process_request { if ($iscsitab) { %iscsihash = %{$iscsitab->getNodesAttribs(\@nodes,[qw(server target)])}; } + my $typetab=xCAT::Table->new('nodetype',-create=>1); + my $typehash=$typetab->getNodesAttribs(\@nodes,['provmethod']); + my $linuximgtab=xCAT::Table->new('linuximage',-create=>1); + my %machash = %{$mactab->getNodesAttribs(\@nodes,[qw(mac)])}; foreach (@nodes) { my $tftpdir; @@ -533,7 +538,13 @@ sub process_request { } elsif ($args[0]) { #If anything else, send it on to the destiny plugin, then setstate my $rc; my $errstr; - ($rc,$errstr) = setstate($_,\%bphash,\%chainhash,\%machash,\%iscsihash,$tftpdir); + my $ent = $typehash->{$_}->[0]; + my $osimgname = $ent->{'provmethod'}; + my $linuximghash=undef; + unless($osimgname =~ /^(install|netboot|statelite)$/){ + $linuximghash = $linuximgtab->getAttribs({imagename => $osimgname}, 'boottarget', 'addkcmdline'); + } + ($rc,$errstr) = setstate($_,\%bphash,\%chainhash,\%machash,\%iscsihash,$tftpdir,$linuximghash); #currently, it seems setstate doesn't return error codes... #if ($rc) { # $response{node}->[0]->{errorcode}->[0]= $rc; diff --git a/xCAT-server/lib/xcat/plugins/yaboot.pm b/xCAT-server/lib/xcat/plugins/yaboot.pm index 9154d3b9e..e79f8aaf9 100644 --- a/xCAT-server/lib/xcat/plugins/yaboot.pm +++ b/xCAT-server/lib/xcat/plugins/yaboot.pm @@ -10,6 +10,7 @@ use xCAT::MsgUtils; use File::Path; use Socket; use Getopt::Long; +use xCAT::Table; my $request; my %breaknetbootnodes; @@ -89,6 +90,7 @@ sub setstate { my %machash = %{shift()}; my $tftpdir = shift; my %nrhash = %{shift()}; + my $linuximghash = shift(); my $kern = $bphash{$node}->[0]; #$bptab->getNodeAttribs($node,['kernel','initrd','kcmdline']); if ($kern->{kcmdline} =~ /!myipfn!/) { my $ipfn = xCAT::NetworkUtils->my_ip_facing($node); @@ -130,6 +132,16 @@ sub setstate { if ($kern->{addkcmdline}) { $kern->{kcmdline} .= " ".$kern->{addkcmdline}; } + + if($linuximghash and $linuximghash->{'addkcmdline'}) + { + unless($linuximghash->{'boottarget'}) + { + $kern->{kcmdline} .= " ".$linuximghash->{'addkcmdline'}; + } + } + + my $pcfg; unless (-d "$tftpdir/etc") { mkpath("$tftpdir/etc"); @@ -507,7 +519,9 @@ sub process_request { my $nrtab=xCAT::Table->new('noderes',-create=>1); my $nrhash=$nrtab->getNodesAttribs(\@nodes,['servicenode']); my $typetab=xCAT::Table->new('nodetype',-create=>1); - my $typehash=$typetab->getNodesAttribs(\@nodes,['os']); + my $typehash=$typetab->getNodesAttribs(\@nodes,['os','provmethod']); + my $linuximgtab=xCAT::Table->new('linuximage',-create=>1); + my $rc; my $errstr; @@ -524,7 +538,14 @@ sub process_request { $response{node}->[0]->{data}->[0]= getstate($_,$tftpdir); $callback->(\%response); } elsif ($args[0]) { #If anything else, send it on to the destiny plugin, then setstate - ($rc,$errstr) = setstate($_,$bphash,$chainhash,$machash,$tftpdir,$nrhash); + my $ent = $typehash->{$_}->[0]; + my $osimgname = $ent->{'provmethod'}; + my $linuximghash=undef; + unless($osimgname =~ /^(install|netboot|statelite)$/){ + $linuximghash = $linuximgtab->getAttribs({imagename => $osimgname}, 'boottarget', 'addkcmdline'); + } + + ($rc,$errstr) = setstate($_,$bphash,$chainhash,$machash,$tftpdir,$nrhash,$linuximghash); if ($rc) { $response{node}->[0]->{errorcode}->[0]= $rc; $response{node}->[0]->{errorc}->[0]= $errstr;