diff --git a/perl-xCAT/xCAT/PPCdb.pm b/perl-xCAT/xCAT/PPCdb.pm index 1b7868525..d1573a02e 100644 --- a/perl-xCAT/xCAT/PPCdb.pm +++ b/perl-xCAT/xCAT/PPCdb.pm @@ -44,6 +44,7 @@ sub add_ppc { my $hwtype = shift; my $values = shift; + my $not_overwrite = shift; my @tabs = qw(ppc vpd nodehm nodelist nodetype); my %db = (); my %nodetype = ( @@ -84,6 +85,41 @@ sub add_ppc { $db{nodetype}->setNodeAttribs( $name,{nodetype=>$nodetype{$type}} ); $db{nodetype}{commit} = 1; } + ############################### + # If cannot be overwroten, get + # old data firstly + ############################### + my $mgt; + my $cons; + if ( $not_overwrite) + { + my $enthash = $db{ppc}->getNodeAttribs( $name, [qw(hcp id pprofile parent)]); + if ( $enthash ) + { + $server = $enthash->{hcp} if ($enthash->{hcp}); + $id = $enthash->{id} if ( $enthash->{id}); + $pprofile = $enthash->{pprofile} if ( $enthash->{pprofile}); + $parent = $enthash->{parent} if ( $enthash->{parent}); + } + $enthash = $db{nodehm}->getNodeAttribs( $name, [qw(mgt)]); + if ( $enthash ) + { + $mgt= $enthash->{mgt} if ( $enthash->{mgt}); + $cons= $enthash->{cons} if ( $enthash->{cons}); + } + $enthash = $db{vpd}->getNodeAttribs( $name, [qw(mtm serial)]); + if ( $enthash ) + { + $model = $enthash->{mtm} if ( $enthash->{mtm}); + $serial= $enthash->{serial} if ( $enthash->{serial}); + } + } + else + { + $mgt = $hwtype; + $cons = $hwtype; + } + ############################### # Update ppc table ############################### @@ -106,9 +142,9 @@ sub add_ppc { # Update nodehm table ########################### if($type =~ /^lpar$/){ - $db{nodehm}->setNodeAttribs( $name, {mgt=>$hwtype,cons=>$hwtype} ); + $db{nodehm}->setNodeAttribs( $name, {mgt=>$mgt,cons=>$cons} ); } else { - $db{nodehm}->setNodeAttribs( $name, {mgt=>$hwtype} ); + $db{nodehm}->setNodeAttribs( $name, {mgt=>$mgt} ); } $db{nodehm}{commit} = 1; } diff --git a/xCAT-server/lib/xcat/plugins/lsslp.pm b/xCAT-server/lib/xcat/plugins/lsslp.pm index 6eae58aed..6ce1727d7 100644 --- a/xCAT-server/lib/xcat/plugins/lsslp.pm +++ b/xCAT-server/lib/xcat/plugins/lsslp.pm @@ -1584,10 +1584,10 @@ sub xCATdB { my $values = join( ",", lc($type),$name,$id,$model,$serial,$name,$prof,$frame,$ips ); - xCAT::PPCdb::add_ppc( lc($type), [$values] ); + xCAT::PPCdb::add_ppc( lc($type), [$values],1 ); } elsif ( $type =~ /^(HMC|IVM)$/ ) { - xCAT::PPCdb::add_ppchcp( lc($type), $name ); + xCAT::PPCdb::add_ppchcp( lc($type), $name,1 ); } elsif ( $type =~ /^FSP$/ ) { ######################################## @@ -1666,7 +1666,7 @@ sub xCATdB { my $values = join( ",", lc($type),$name,$cageid,$model,$serial,$name,$prof,$frame,$ips ); - xCAT::PPCdb::add_ppc( "fsp", [$values] ); + xCAT::PPCdb::add_ppc( "fsp", [$values],1 ); } elsif ( $type =~ /^(RSA|MM)$/ ) { xCAT::PPCdb::add_systemX( $type, $data );