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
This commit is contained in:
wanghuaz 2012-11-29 06:24:17 +00:00
parent 6527f298bb
commit 9c9388f263

View File

@ -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;
}
}