From dcf192a350a19f73759376554d17b3005cbe9b57 Mon Sep 17 00:00:00 2001
From: wanghuaz <wanghuaz@8638fb3e-16cb-4fca-ae20-7b5d299a9bcd>
Date: Fri, 25 Sep 2009 08:30:11 +0000
Subject: [PATCH] fixed bug 2865553

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4224 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
---
 perl-xCAT/xCAT/DBobjUtils.pm | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/perl-xCAT/xCAT/DBobjUtils.pm b/perl-xCAT/xCAT/DBobjUtils.pm
index 77fc54277..fff6ac256 100644
--- a/perl-xCAT/xCAT/DBobjUtils.pm
+++ b/perl-xCAT/xCAT/DBobjUtils.pm
@@ -981,6 +981,7 @@ sub setobjdefs
 
 		my @setattrlist=();
 		my @checkedattrs;
+                my $invalidattr;
 
         foreach my $this_attr (@{$datatype->{'attrs'}})
         {
@@ -1042,18 +1043,26 @@ sub setobjdefs
                         }
 						xCAT::MsgUtils->message("I", $rsp, $::callback);
 						push(@checkedattrs, $attr_name);
+                        if ( $invalidattr->{$attr_name}->{valid} ne 1 ) {
+                            $invalidattr->{$attr_name}->{valid} = 0;
+                            $invalidattr->{$attr_name}->{condition} = "\'$check_attr=$check_value\'";
+                        }
+
                         next;
                     }
 
 					if ( !($objhash{$objname}{$check_attr} =~ /\b$check_value\b/) && !($DBattrvals{$objname}{$check_attr}  =~ /\b$check_value\b/) )
                     {
-                        my $rsp;
-                        push @{$rsp->{data}}, "Cannot set the \'$attr_name\' attribute unless \'$check_attr=$check_value\'.\n";
-                        xCAT::MsgUtils->message("E", $rsp, $::callback);
-                        next;
+                        if ( $invalidattr->{$attr_name}->{valid} ne 1 ) {
+                            $invalidattr->{$attr_name}->{valid} = 0;
+                            $invalidattr->{$attr_name}->{condition} = "\'$check_attr=$check_value\'";
 
+                        }
+
+                        next;
                     }
                 }
+                $invalidattr->{$attr_name}->{valid} = 1;
 
                 #  get the info needed to write to the DB table
                 #
@@ -1173,6 +1182,15 @@ sub setobjdefs
 
         }    # end - foreach attribute
 
+        my $rsp;
+        foreach my $att (keys %$invalidattr) {
+            if ( $invalidattr->{$att}->{valid} ne 1) {
+my $tt = $invalidattr->{$att}->{valid};
+                push @{$rsp->{data}}, "Cannot set the attr=\'$att\' attribute unless $invalidattr->{$att}->{condition}.\n";
+                xCAT::MsgUtils->message("E", $rsp, $::callback);
+            }
+        }
+
 
 # TODO - need to get back to this
 if (0) {