From 58e27df4776a653042cef8aa2cd16769ee161f55 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Fri, 22 Apr 2011 15:28:02 +0000 Subject: [PATCH] Fix up cpNetBootImages changes, only copy if destination doesn't exist or is older than source git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@9381 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/esx.pm | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/esx.pm b/xCAT-server/lib/xcat/plugins/esx.pm index 37a7b9cc4..d9d26aca8 100644 --- a/xCAT-server/lib/xcat/plugins/esx.pm +++ b/xCAT-server/lib/xcat/plugins/esx.pm @@ -4129,17 +4129,27 @@ sub cpNetbootImages { foreach (@filestocopy) { my $mod = scalar fileparse($_); if (-r "$overridedir/$mod") { - copy("$overridedir/$mod","$destDir/$mod") or xCAT::SvrUtils::sendmsg([1,"Could not copy netboot contents from $_ to $destDir/$mod"], $output_handler); - } else { - copy($_,"$destDir/$mod") or xCAT::SvrUtils::sendmsg([1,"Could not copy netboot contents from $_ to $destDir/$mod"], $output_handler); + copyIfNewer("$overridedir/$mod","$destDir/$mod") or xCAT::SvrUtils::sendmsg([1,"Could not copy netboot contents from $overridedir/$mod to $destDir/$mod, $!"], $output_handler); + } elsif (-r "$_") { + copyIfNewer($srcDir."/".$mod,"$destDir/$mod") or xCAT::SvrUtils::sendmsg([1,"Could not copy netboot contents from $srcDir/$mod to $destDir/$mod, $!"], $output_handler); + } elsif ($mod ne "xcatmod.tgz") { + xCAT::SvrUtils::sendmsg([1,"Could not copy netboot contents from $srcDir/$mod to $destDir/$mod, $srcDir/$mod not found"], $output_handler); } } } else { - xCAT::SvrUtils::sendmsg([1,"VMware $osver is not supported for netboot"], $output_handler); + xCAT::SvrUtils::sendmsg([1,"VMware $osver is not supported for netboot"], $output_handler); } } +sub copyIfNewer { + my $source = shift; + my $dest = shift; + if (! -e $dest or -C $source > -C $dest) { + return copy($source,$dest); + } + return 1; +} # compares nfs target described by parameters to every share mounted by target hypervisor # returns 1 if matching datastore is present and 0 otherwise