From 9c9388f2635aac94f8d58e3b4b8d99d73ce97cc6 Mon Sep 17 00:00:00 2001 From: wanghuaz Date: Thu, 29 Nov 2012 06:24:17 +0000 Subject: [PATCH] Add an enhancement of rmkit that prevent removing a kit if its isinternal attribute is set to 1 git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@14471 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/kit.pm | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index 06948d809..8fc9801f6 100644 --- a/xCAT-server/lib/xcat/plugins/kit.pm +++ b/xCAT-server/lib/xcat/plugins/kit.pm @@ -1093,11 +1093,17 @@ sub rmkit # Check if it is a kitname or basename - (my $ref1) = $tabs{kit}->getAttribs({kitname => $kit}, 'basename'); + (my $ref1) = $tabs{kit}->getAttribs({kitname => $kit}, 'basename', 'isinternal'); if ( $ref1 and $ref1->{'basename'}){ + if ( $ref1->{'isinternal'} and !$force ) { + my %rsp; + push@{ $rsp{data} }, "Kit $kit with isinterval attribute cannot be remoed"; + xCAT::MsgUtils->message( "E", \%rsp, $callback ); + return 1; + } $kitnames{$kit} = 1; } else { - my @entries = $tabs{kit}->getAllAttribsWhere( "basename = '$kit'", 'kitname' ); + my @entries = $tabs{kit}->getAllAttribsWhere( "basename = '$kit'", 'kitname', 'isinternal'); unless (@entries) { my %rsp; push@{ $rsp{data} }, "Kit $kit could not be found in DB $t"; @@ -1105,6 +1111,12 @@ sub rmkit return 1; } foreach my $entry (@entries) { + if ( $entry->{'isinternal'} and !$force ) { + my %rsp; + push@{ $rsp{data} }, "Kit $entry->{kitname} with isinterval attribute cannot be remoed"; + xCAT::MsgUtils->message( "E", \%rsp, $callback ); + return 1; + } $kitnames{$entry->{kitname}} = 1; } }