diff --git a/xCAT-server/lib/xcat/plugins/aixinstall.pm b/xCAT-server/lib/xcat/plugins/aixinstall.pm index 3a83a2e66..0c5cdf2fe 100644 --- a/xCAT-server/lib/xcat/plugins/aixinstall.pm +++ b/xCAT-server/lib/xcat/plugins/aixinstall.pm @@ -10791,23 +10791,53 @@ sub mkdsklsnode my $snbk = $Sname . "_" . $i; my $bkloc = "$loc/$snbk/.client_data"; - my $fcmd; - if (-d $bkloc) + my $mkcmd; + if (! -d $bkloc) { - # if backup exist then rm contents - $fcmd = qq~/usr/bin/rm $bkloc/* ; ~; - } else { # else create dir - $fcmd=qq~/usr/bin/mkdir -m 644 -p $bkloc ; ~; + $mkcmd=qq~/usr/bin/mkdir -m 644 -p $bkloc ~; + my $output = xCAT::Utils->runcmd("$mkcmd", -1); + if ($::RUNCMD_RC != 0) + { + my $rsp; + push @{$rsp->{data}}, "Could not create $bkloc\n"; + xCAT::MsgUtils->message("E", $rsp, $callback); + } } - my $ccmd=qq~$fcmd /usr/bin/cp -p -r $cdloc/* $bkloc~; - my $output = xCAT::Utils->runcmd("$ccmd", -1); + # should only backup files for the specific nodes + + # get list of files from $cdloc dir + my $rcmd = qq~/usr/bin/ls $cdloc 2>/dev/null~; + my @rlist = xCAT::Utils->runcmd("$rcmd", -1); if ($::RUNCMD_RC != 0) { my $rsp; - push @{$rsp->{data}}, "Could not back up $cdloc on $Sname \n"; + push @{$rsp->{data}}, "Could not list contents of $cdloc.\n"; xCAT::MsgUtils->message("E", $rsp, $callback); + $error++; + } + + foreach my $nd (@nodelist) { + $nd =~ s/\..*$//; + + # for each file in $cdloc + my $filestring = ""; + foreach my $f (@rlist) { + # if file contains node name then copy it + if ($f =~ /$nd/) { + $filestring .="$cdloc/$f "; + } + } + my $ccmd=qq~/usr/bin/cp -p -r $filestring $bkloc 2>/dev/null~; + my $output = xCAT::Utils->runcmd("$ccmd", -1); + if ($::RUNCMD_RC != 0) + { + my $rsp; + push @{$rsp->{data}}, "Could not copy files to $bkloc. \n"; + xCAT::MsgUtils->message("E", $rsp, $callback); + $error++; + } } } } diff --git a/xCAT-server/lib/xcat/plugins/snmove.pm b/xCAT-server/lib/xcat/plugins/snmove.pm index 2fd398a51..ce6c434d7 100644 --- a/xCAT-server/lib/xcat/plugins/snmove.pm +++ b/xCAT-server/lib/xcat/plugins/snmove.pm @@ -562,16 +562,6 @@ sub process_request $sharedinstall="no"; } - # - # handle the statelite update for the sharedinstall=sns case - # - using a shared file system across all service nodes - # - if ( ($::isaix) && ($sharedinstall eq "sns") ){ - my $s = &sfsSLconfig(\@nodes, \%nhash, \%sn_hash, $old_node_hash, $nimprime, $callback, $sub_req); - } - - # TBD - handle sharedinstall =all case ???? - # handle the statelite update for sharedinstall=no # - not using a shared files system my %SLmodhash; @@ -836,6 +826,19 @@ sub process_request } } + # + # handle the statelite update for the sharedinstall=sns case + # - using a shared file system across all service nodes + # - must be done AFTER node def is updated! + # + if ( ($::isaix) && ($sharedinstall eq "sns") ){ + my $s = &sfsSLconfig(\@nodes, \%nhash, \%sn_hash, $old_node_hash, $nimprime, $callback, $sub_req); + } + + # TBD - handle sharedinstall =all case ???? + + + # run makeconservercf my @nodes_con = keys(%sn_hash1); if (@nodes_con > 0) @@ -884,6 +887,7 @@ sub process_request $nimtab->close(); # now try to restore any backup client data + # for each service node foreach my $s (keys %SRloc) { @@ -898,15 +902,50 @@ sub process_request my $snbk = "$s" . "_" . "$osi"; my $bkloc = "$sloc/$snbk/.client_data"; - my $ccmd=qq~/usr/bin/cp -r -p $bkloc/* $cdloc 2>/dev/null~; + # get a list of files from the backup dir + my $rcmd = qq~/usr/bin/ls $bkloc 2>/dev/null~; + + my $rlist = xCAT::InstUtils->xcmd($callback, $sub_req, "xdsh", $s, $rcmd, 0); - my $output = xCAT::InstUtils->xcmd($callback, $sub_req, "xdsh", $s, $ccmd, 0); if ($::RUNCMD_RC != 0) { - if ($::VERBOSE) { + my $rsp; + push @{$rsp->{data}}, "Could not list contents of $bkloc.\n"; + xCAT::MsgUtils->message("E", $rsp, $callback); + $error++; + } + + # restore file on node by node basis + # we don't want all the files! + # - just the ones we are moving + foreach my $nd (@nodes) { + + $nd =~ s/\..*$//; + + # for each file in $bkloc + my $filestring = ""; + foreach my $f ( split(/\n/, $rlist) ){ + my $junk; + my $file; + if ($f =~ /:/) { + ($junk, $file) = split(/:/, $f); + } + $file =~ s/\s*//g; # remove blanks + + # if file contains node name then copy it + if ($file =~ /$nd/) { + $filestring .= "$bkloc/$file "; + } + } + my $ccmd=qq~/usr/bin/cp -p -r $filestring $cdloc 2>/dev/null~; + + my $output = xCAT::InstUtils->xcmd($callback, $sub_req, "xdsh", $s, $rcmd, 0); + if ($::RUNCMD_RC != 0) + { my $rsp; - push @{$rsp->{data}}, "Could not copy $bkloc on $s.\n"; + push @{$rsp->{data}}, "Could not copy files to $cdloc.\n"; xCAT::MsgUtils->message("E", $rsp, $callback); + $error++; } } } @@ -2047,7 +2086,6 @@ sub sfsSLconfig } } - # get hash of statelite table entries my $statetab = xCAT::Table->new('statelite', -create => 1); my $recs = $statetab->getAllEntries; @@ -2081,7 +2119,6 @@ sub sfsSLconfig # if the $server value was the old SN hostname # then we need to # update the statelite table with the new SN name - if ( $server eq $old_node_hash->{$n}->{'oldmaster'} ) { my $stmnt = "$sn_hash{$n}{'xcatmaster'}:$dir"; $SLmodhash{$item}{'statemnt'} = $stmnt;