From 7a69c9b7790f5ee982cc3fb99b09759964a9a2a4 Mon Sep 17 00:00:00 2001 From: Bin Xu Date: Tue, 22 May 2018 12:47:37 +0800 Subject: [PATCH] using --nosyncfiles to bypass syncing files to root image directory (#5229) --- .../references/man1/packimage.1.rst | 12 ++++++++++- xCAT-client/pods/man1/packimage.1.pod | 8 ++++++- xCAT-server/lib/xcat/plugins/packimage.pm | 21 ++++++++++++------- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man1/packimage.1.rst b/docs/source/guides/admin-guides/references/man1/packimage.1.rst index f7f1ff332..7105513fd 100644 --- a/docs/source/guides/admin-guides/references/man1/packimage.1.rst +++ b/docs/source/guides/admin-guides/references/man1/packimage.1.rst @@ -23,7 +23,7 @@ SYNOPSIS \ **packimage [-v| -**\ **-version]**\ -\ **packimage**\ [\ **-m | -**\ **-method**\ \ *cpio|tar*\ ] [\ **-c | -**\ **-compress**\ \ *gzip|pigz|xz*\ ] \ *imagename*\ +\ **packimage**\ [\ **-m | -**\ **-method**\ \ *cpio|tar*\ ] [\ **-c | -**\ **-compress**\ \ *gzip|pigz|xz*\ ] [\ **--nosyncfiles**\ ] \ *imagename*\ *********** @@ -57,6 +57,8 @@ OPTIONS \ **-c| -**\ **-compress**\ Compress Method (pigz,gzip,xz, default is pigz/gzip) +\ **--nosyncfiles**\ Bypass of syncfiles requested, will not sync files to root image directory + ************ RETURN VALUE @@ -89,6 +91,14 @@ EXAMPLES packimage -m tar -c pigz rhels7.1-x86_64-netboot-compute +3. To pack the osimage 'rhels7.1-x86_64-netboot-compute' without syncing files: + + +.. code-block:: perl + + packimage --nosyncfiles rhels7.1-x86_64-netboot-compute + + ***** FILES diff --git a/xCAT-client/pods/man1/packimage.1.pod b/xCAT-client/pods/man1/packimage.1.pod index 5b2b2a837..05f2cdeff 100644 --- a/xCAT-client/pods/man1/packimage.1.pod +++ b/xCAT-client/pods/man1/packimage.1.pod @@ -8,7 +8,7 @@ B B -B [B<-m>|B<--method> I] [B<-c>|B<--compress> I] I +B [B<-m>|B<--method> I] [B<-c>|B<--compress> I] [B<--nosyncfiles>] I =head1 DESCRIPTION @@ -31,6 +31,8 @@ B<-m| --method> Archive Method (cpio,tar,squashfs, default is cpio) B<-c| --compress> Compress Method (pigz,gzip,xz, default is pigz/gzip) +B<--nosyncfiles> Bypass of syncfiles requested, will not sync files to root image directory + =head1 RETURN VALUE @@ -48,6 +50,10 @@ B<-c| --compress> Compress Method (pigz,gzip,xz, default is pigz/gzip) packimage -m tar -c pigz rhels7.1-x86_64-netboot-compute +3. To pack the osimage 'rhels7.1-x86_64-netboot-compute' without syncing files: + + packimage --nosyncfiles rhels7.1-x86_64-netboot-compute + =head1 FILES /opt/xcat/sbin/packimage diff --git a/xCAT-server/lib/xcat/plugins/packimage.pm b/xCAT-server/lib/xcat/plugins/packimage.pm index 9d326c0b0..709a04b31 100755 --- a/xCAT-server/lib/xcat/plugins/packimage.pm +++ b/xCAT-server/lib/xcat/plugins/packimage.pm @@ -82,7 +82,7 @@ sub process_request { @ARGV = @{$args}; } if (scalar(@ARGV) == 0) { - $callback->({ info => ["Usage:\n packimage [-m| --method=cpio|tar] [-c| --compress=gzip|pigz|xz] \n packimage [-h| --help]\n packimage [-v| --version]"] }); + $callback->({ info => ["Usage:\n packimage [-m| --method=cpio|tar] [-c| --compress=gzip|pigz|xz] [--nosyncfiles] \n packimage [-h| --help]\n packimage [-v| --version]"] }); return 0; } @@ -95,6 +95,7 @@ sub process_request { my $syncfile; my $rootimg_dir; my $destdir; + my $nosyncfiles; my $imagename; my $dotorrent; my $provmethod; @@ -109,6 +110,7 @@ sub process_request { "method|m=s" => \$method, "compress|c=s" => \$compress, "tracker=s" => \$dotorrent, + 'nosyncfiles' => \$nosyncfiles, "help|h" => \$help, "version|v" => \$version ); @@ -122,7 +124,7 @@ sub process_request { return 0; } if ($help) { - $callback->({ info => ["Usage:\n packimage [-m| --method=cpio|tar] [-c| --compress=gzip|pigz|xz] \n packimage [-h| --help]\n packimage [-v| --version]"] }); + $callback->({ info => ["Usage:\n packimage [-m| --method=cpio|tar] [-c| --compress=gzip|pigz|xz] [--nosyncfiles] \n packimage [-h| --help]\n packimage [-v| --version]"] }); return 0; } @@ -412,12 +414,15 @@ sub process_request { close($shadow); umask($oldmask); - # sync fils configured in the synclist to the rootimage - $syncfile = xCAT::SvrUtils->getsynclistfile(undef, $osver, $arch, $profile, "netboot", $imagename); - if (defined($syncfile) && -f $syncfile - && -d $rootimg_dir) { - print "sync files from $syncfile to the $rootimg_dir\n"; - system("$::XCATROOT/bin/xdcp -i $rootimg_dir -F $syncfile"); + if (not $nosyncfiles) { + # sync fils configured in the synclist to the rootimage + $syncfile = xCAT::SvrUtils->getsynclistfile(undef, $osver, $arch, $profile, "netboot", $imagename); + if ( defined($syncfile) && -f $syncfile && -d $rootimg_dir) { + print "Syncing files from $syncfile to root image dir: $rootimg_dir\n"; + system("$::XCATROOT/bin/xdcp -i $rootimg_dir -F $syncfile"); + } + } else { + print "Bypass of syncfiles requested, will not sync files to root image directory.\n"; } my $temppath;