From 1b5ff23093f70c50df9b67e66801bfcf835647c3 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Mon, 12 Aug 2013 11:18:49 -0400 Subject: [PATCH] Add usage message and manpage for geninitrd command; Add --noupdateinitrd flag for nodeset manpage; Make geninitrd to check the provmethod if no image name is specified --- xCAT-client/pods/man1/geninitrd.1.pod | 100 ++++++++++++++++++++++ xCAT-client/pods/man8/nodeset.8.pod | 7 ++ xCAT-server/lib/xcat/plugins/geninitrd.pm | 53 ++++++++++-- 3 files changed, 155 insertions(+), 5 deletions(-) create mode 100644 xCAT-client/pods/man1/geninitrd.1.pod diff --git a/xCAT-client/pods/man1/geninitrd.1.pod b/xCAT-client/pods/man1/geninitrd.1.pod new file mode 100644 index 000000000..65de247df --- /dev/null +++ b/xCAT-client/pods/man1/geninitrd.1.pod @@ -0,0 +1,100 @@ +=head1 NAME + +B - Generate an initrd (initial ramfs) which to be used for statefull install or stateless netboot. + +=head1 SYNOPSIS + +B + +B [B<-h> | B<--help>] + + +=head1 DESCRIPTION + +Generate the initrd for the osimage: B which is an xCAT object of I type. + +B + +=over 2 + +If the B is a statefull one (The provmethod attribute for the osimage is 'install'), +this command is used to rebuild the initrd to inject the new drivers from driver rpms or +'update distro' and copy the rebuilt initrd and new kernel (If there's new kernel in 'update +distro') to the directory I>. + +If the initrd has been rebuilt by geninitrd, when run nodeset, the I<--noupdateinitrd> option +should be used to skip the rebuilding of initrd to improve the performance. + +Three attributes of osimage object can be used to specify the Driver RPM location and Driver names +for injecting new drviers to initrd. + +B - comma separated driver names that need to be injected to the initrd. +The postfix '.ko' can be ignored. The netdrivers attribute must be set to specify the new driver list. +If you want to load all the drivers from the driver rpms, using the keyword allupdate. + +B - comma separated driver rpm packages (full path should be specified) + +B - comma separated 'osdistroupdate' object. Each 'osdistroupdate' object specifies a +Linux distro update. When run geninitrd, 'kernel-*.rpm' will be searched from osdistroupdate.dirpath +to get all the rpm packages and then search the drivers from the rpm packages. + +Refer to the doc: https://sourceforge.net/apps/mediawiki/xcat/index.php?title=Using_Linux_Driver_Update_Disk + +=back + +B + +=over 2 + +If the B is a stateless one (The provmethod attribute for the osimage is 'netboot'), +this command is used to generate the initrd from the rootimg which generated by 'genimage' command. +So the 'genimage' must be run once before running the geninitrd command. + +Two attributes of osimage object can be used to specify the Driver RPM location and Driver names +for injecting new drviers to initrd. + +B - comma separated driver names that need to be injected to the initrd. +The postfix '.ko' can be ignored. The netdrivers attribute must be set to specify the new driver list. +If you want to load all the drivers from the driver rpms, using the keyword allupdate. + +B - comma separated driver rpm packages (full path should be specified) + +=back + + +=head1 Parameters + +I specifies the name of an os image definition to be used. The specification for the image is storted in the I table and I table. + + +=head1 RETURN VALUE + +0 The command completed successfully. + +1 An error has occurred. + + +=head1 EXAMPLES + +=over 3 + +=item 1 +To generate initrd for the osimage B: + + geninitrd myimagename + +=back + + +=head1 FILES + +/opt/xcat/bin/geninitrd + +/opt/xcat/bin/genimage + +/opt/xcat/share/xcat/netboot//genimage + + +=head1 SEE ALSO + +L, L diff --git a/xCAT-client/pods/man8/nodeset.8.pod b/xCAT-client/pods/man8/nodeset.8.pod index 0c5584924..e0a2e6b74 100644 --- a/xCAT-client/pods/man8/nodeset.8.pod +++ b/xCAT-client/pods/man8/nodeset.8.pod @@ -6,6 +6,8 @@ B - set the boot state for a noderange B [I] [I|I|I|I|I|I|I|I|I>]] +B I [I> I<--noupdateinitrd>] + B [I<-h>|I<--help>|I<-v>|I<--version>] =head1 B @@ -67,6 +69,11 @@ Cleanup the current pxe/tftp boot configuration files for the nodes requested Prepare server for installing a node using the specified os image. The os image is defined in the I table and I table. If the is omitted, the os image name will be obtained from I for the node. +=item B<--noupdateinitrd> + +Skip the rebuilding of initrd when the 'netdrivers', 'drvierupdatesrc' or 'osupdatename' were set for injecting new drviers to initrd. But, the geninitrd command +should be run to rebuild the initrd for new drivers injecting. This is used to improve the performance of nodeset command. + =item B=> If you would like to run a task after deployment, you can define that task with this attribute. diff --git a/xCAT-server/lib/xcat/plugins/geninitrd.pm b/xCAT-server/lib/xcat/plugins/geninitrd.pm index a364a6210..9a9fe45f1 100644 --- a/xCAT-server/lib/xcat/plugins/geninitrd.pm +++ b/xCAT-server/lib/xcat/plugins/geninitrd.pm @@ -26,8 +26,28 @@ sub preprocess_request my $req = shift; my $callback = shift; - unless (defined ($req->{arg}) && $req->{arg}->[0]) { - xCAT::MsgUtils->message("E", {error=>["An osimage name needs to be specified."], errorcode=>["1"]}, $callback); + my $usage = sub { + my $callback = shift; + xCAT::MsgUtils->message("I", {data=>["Usage: geninitrd [-h | --help]"]}, $callback); + }; + + my $osimage; + if (defined ($req->{arg})) { + foreach (@{$req->{arg}}) { + if (/^-/) { + $usage->($callback); + return; + }else { + $osimage = $_; + } + } + } else { + $usage->($callback); + return; + } + + unless ($osimage) { + $usage->($callback); return; } @@ -46,10 +66,11 @@ sub process_request { my $req = shift; my $callback = shift; + my $doreq = shift; if ($req->{command}->[0] eq 'geninitrd') { - return geninitrd($req, $callback); + return geninitrd($req, $callback, $doreq); } } @@ -57,6 +78,7 @@ sub process_request sub geninitrd { my $req = shift; my $callback = shift; + my $doreq = shift; my $osimage = $req->{arg}->[0]; @@ -69,7 +91,7 @@ sub geninitrd { return; } - my $oient = $osimagetab->getAttribs({imagename => $osimage}, 'osvers', 'osarch', 'osupdatename'); + my $oient = $osimagetab->getAttribs({imagename => $osimage}, 'provmethod', 'osvers', 'osarch', 'osupdatename'); unless ($oient && $oient->{'osvers'} && $oient->{'osarch'} ) { xCAT::MsgUtils->message("E", {error=>["The osimage [$osimage] was not defined or [osvers, osarch] attributes were not set."], errorcode=>["1"]}, $callback); return; @@ -84,7 +106,7 @@ sub geninitrd { return; } - my $lient = $linuximagetab->getAttribs({imagename => $osimage}, 'pkgdir', 'driverupdatesrc', 'netdrivers'); + my $lient = $linuximagetab->getAttribs({imagename => $osimage}, 'rootimgdir', 'pkgdir', 'driverupdatesrc', 'netdrivers'); unless ($lient && $lient->{'pkgdir'}) { xCAT::MsgUtils->message("E", {error=>["The osimage [$osimage] was not defined or [pkgdir] attribute was not set."], errorcode=>["1"]}, $callback); return; @@ -93,6 +115,27 @@ sub geninitrd { $driverupdatesrc = $lient->{'driverupdatesrc'}; $netdrivers = $lient->{'netdrivers'}; + # if the provmethod equals 'netboot', call the genimage --onlyinitrd directly + if ($oient->{'provmethod'} && $oient->{'provmethod'} eq "netboot") { + if ($lient->{'rootimgdir'}) { + unless (-d $lient->{'rootimgdir'}."/rootimg/lib/modules") { + xCAT::MsgUtils->message("E", {error=>["The genimage should be run before running geninitrd."], errorcode=>["1"]}, $callback); + return; + } + } else { + xCAT::MsgUtils->message("E", {error=>["The rootimgdir attribute for the osimage should be set."], errorcode=>["1"]}, $callback); + return; + } + my @output = `genimage $osimage --onlyinitrd`; + xCAT::MsgUtils->message("I", {data=>\@output}, $callback); + #$doreq->({ command => ['genimage'], + # arg => [$osimage, '--onlyinitrd'] }, $callback); + return; + } elsif (!$oient->{'provmethod'} || $oient->{'provmethod'} ne "install") { + xCAT::MsgUtils->message("E", {error=>["The attribute [provmethod] for osimage [$osimage] must be set to install or netboot."], errorcode=>["1"]}, $callback); + return; + } + # get the path list of the osdistroupdate if ($oient->{'osupdatename'}) { my @osupdatenames = split (/,/, $oient->{'osupdatename'});