From ca77e78e8f005557e702002e98a4828336407fb5 Mon Sep 17 00:00:00 2001 From: ligc Date: Wed, 10 Jun 2009 06:31:37 +0000 Subject: [PATCH] xCAT_plugin::DBobjectdefs::defrm: check whether the object is in the table before try to delete it git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3545 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/DBobjectdefs.pm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm index e027b90f6..cbc281a11 100644 --- a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm +++ b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm @@ -2790,8 +2790,21 @@ sub defrm # the memberlist nodes must be updated. my $numobjects = 0; + my %objTypeLists; foreach my $obj (keys %objhash) { + my $objtype = $objhash{$obj}; + if (!defined($objTypeLists{$objtype})) # Do no call getObjectsOfType for the same objtype more than once. + { + @{$objTypeLists{$objtype}} = xCAT::DBobjUtils->getObjectsOfType($objtype); + } + if (!grep(/^$obj$/, @{$objTypeLists{$objtype}})) #Object is not in the db, do not need to delete + { + my $rsp; + $rsp->{data}->[0] = "Could not find an object named \'$obj\' of type \'$objtype\'.\n"; + xCAT::MsgUtils->message("E", $rsp, $::callback); + next; + } $numobjects++; if ($objhash{$obj} eq 'group')