From f23d37e4105bbfff829b304f3164e2bceb036929 Mon Sep 17 00:00:00 2001 From: wanghuaz Date: Fri, 1 Feb 2013 09:43:17 +0000 Subject: [PATCH] Fixing bug 3339: check if the kitomponent is existing before adidng it. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@15033 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/kit.pm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index 744d7604d..526532ed3 100644 --- a/xCAT-server/lib/xcat/plugins/kit.pm +++ b/xCAT-server/lib/xcat/plugins/kit.pm @@ -1014,6 +1014,21 @@ sub addkit return 1; } + # Check if the kitcomponent is existing + my @kitcomps = $tabs{kitcomponent}->getAllAttribs( 'kitcompname' ); + foreach my $kitcomp (@kitcomps) { + if ( $kitcomp->{kitcompname} ) { + foreach my $kitcompid (keys %kitcomphash) { + if ( $kitcomphash{$kitcompid}{kitcompname} and $kitcomphash{$kitcompid}{kitcompname} =~ /$kitcomp->{kitcompname}/ ) { + my %rsp; + push@{ $rsp{data} }, "Failed to add kitcomponent $kitcomp->{kitcompname} because it is already existing"; + xCAT::MsgUtils->message( "E", \%rsp, $callback ); + return 1; + } + } + } + } + my %rsp; push@{ $rsp{data} }, "Adding Kit $kithash{kitname}"; xCAT::MsgUtils->message( "I", \%rsp, $callback );