From 590425a581bcb386096f2364a759490822d4b4bb Mon Sep 17 00:00:00 2001 From: ligc Date: Fri, 6 Nov 2009 03:25:48 +0000 Subject: [PATCH] fix for bug 2887320: check postscripts whether in xcatdefaults before setting to the database. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4494 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/DBobjUtils.pm | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/perl-xCAT/xCAT/DBobjUtils.pm b/perl-xCAT/xCAT/DBobjUtils.pm index 3e9fdafee..9821b1e3e 100644 --- a/perl-xCAT/xCAT/DBobjUtils.pm +++ b/perl-xCAT/xCAT/DBobjUtils.pm @@ -1269,6 +1269,43 @@ if (0) { return 1; } + # Special case for the postscripts table + # Does not set the postscripts to the postscripts table + # if the postscripts already in xcatdefaults + # for code logic, it will be clearer to put the special case into defch, + # but putting it into defch will introduce additional table access for postscripts table. + # accessing table is time consuming. + if ($table eq "postscripts") { + my $xcatdefaultsps; + my @TableRowArray = xCAT::DBobjUtils->getDBtable('postscripts'); + if (defined(@TableRowArray)) + { + foreach my $tablerow (@TableRowArray) + { + if(($tablerow->{node} eq 'xcatdefaults') && !($tablerow->{disable})) + { + $xcatdefaultsps = $tablerow->{postscripts}; + last; + } + } + } + my @xcatdefps = split(/,/, $xcatdefaultsps); + foreach my $obj(keys %{$allupdates{$table}}) { + my @newps; + if (defined($allupdates{$table}{$obj}{'postscripts'}{'tabattrs'}{'postscripts'})) { + foreach my $tempps (split(/,/, $allupdates{$table}{$obj}{'postscripts'}{'tabattrs'}{'postscripts'})) { + if (grep(/^$tempps$/, @xcatdefps)) { + my $rsp; + $rsp->{data}->[0] = "$obj: postscripts \'$tempps\' is already included in the \'xcatdefaults\'."; + xCAT::MsgUtils->message("E", $rsp, $::callback); + } else { + push @newps, $tempps; + } + } + $allupdates{$table}{$obj}{'postscripts'}{'tabattrs'}{'postscripts'} = join(',', @newps); + } + } + } OBJ: foreach my $obj (keys %{$allupdates{$table}}) { ROW: foreach my $row (keys %{$allupdates{$table}{$obj}}) { my %keyhash;