From 17d6cd35d04cf1a2e06eda0584998c625ec5dbb6 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Mon, 20 Jun 2016 15:31:39 -0400 Subject: [PATCH 1/2] Correct the count of removed objects --- xCAT-server/lib/xcat/plugins/DBobjectdefs.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm index 40285f360..5e0f04abb 100755 --- a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm +++ b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm @@ -3818,6 +3818,7 @@ sub defrm # the memberlist nodes must be updated. my $numobjects = 0; + my $numobjects_not_removed = 0; my %objTypeLists; foreach my $obj (keys %objhash) { @@ -3831,6 +3832,7 @@ sub defrm my $rsp; $rsp->{data}->[0] = "Could not find an object named \'$obj\' of type \'$objtype\'."; xCAT::MsgUtils->message("E", $rsp, $::callback); + $numobjects_not_removed++; next; } $numobjects++; @@ -3848,6 +3850,7 @@ sub defrm my $rsp; $rsp->{data}->[0] = "Could not get xCAT object definition for \'$obj\'."; xCAT::MsgUtils->message("I", $rsp, $::callback); + $numobjects_not_removed++; next; } @@ -3887,6 +3890,7 @@ sub defrm my $m = join ',', @nodes; $rsp->{data}->[0] = "Could not get xCAT object definition for \'$m\'."; xCAT::MsgUtils->message("I", $rsp, $::callback); + $numobjects_not_removed++; next; } @@ -3985,7 +3989,7 @@ sub defrm else { my $rsp; - my $nodenum = scalar(keys %objhash); + my $nodenum = scalar(keys %objhash) - $numobjects_not_removed; $rsp->{data}->[0] = "$nodenum object definitions have been removed."; xCAT::MsgUtils->message("I", $rsp, $::callback); } From 52798de7c4118239144aef8d52c5ee2e35ed3125 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 21 Jun 2016 14:57:32 -0400 Subject: [PATCH 2/2] Simplify solution and handle verbose option --- xCAT-server/lib/xcat/plugins/DBobjectdefs.pm | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm index 5e0f04abb..c6bab0dbe 100755 --- a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm +++ b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm @@ -3818,7 +3818,6 @@ sub defrm # the memberlist nodes must be updated. my $numobjects = 0; - my $numobjects_not_removed = 0; my %objTypeLists; foreach my $obj (keys %objhash) { @@ -3832,7 +3831,9 @@ sub defrm my $rsp; $rsp->{data}->[0] = "Could not find an object named \'$obj\' of type \'$objtype\'."; xCAT::MsgUtils->message("E", $rsp, $::callback); - $numobjects_not_removed++; + # Remove the object we could not find from the hash, this way the count of the objects + # and the content of the hash (for the verbose option), can be used for printing results at the end + delete($objhash{$obj}); next; } $numobjects++; @@ -3850,7 +3851,6 @@ sub defrm my $rsp; $rsp->{data}->[0] = "Could not get xCAT object definition for \'$obj\'."; xCAT::MsgUtils->message("I", $rsp, $::callback); - $numobjects_not_removed++; next; } @@ -3890,7 +3890,6 @@ sub defrm my $m = join ',', @nodes; $rsp->{data}->[0] = "Could not get xCAT object definition for \'$m\'."; xCAT::MsgUtils->message("I", $rsp, $::callback); - $numobjects_not_removed++; next; } @@ -3989,7 +3988,7 @@ sub defrm else { my $rsp; - my $nodenum = scalar(keys %objhash) - $numobjects_not_removed; + my $nodenum = scalar(keys %objhash); $rsp->{data}->[0] = "$nodenum object definitions have been removed."; xCAT::MsgUtils->message("I", $rsp, $::callback); }