From 01be6f53fe17b820e39a3b161b90adf05330a2ca Mon Sep 17 00:00:00 2001 From: wanghuaz Date: Thu, 25 Apr 2013 12:59:42 +0000 Subject: [PATCH] Check if the deploy parameter is used by other kitcomponent that is not in the same kit git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.8@16065 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/kit.pm | 49 ++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index f70877819..a3ecdaa86 100644 --- a/xCAT-server/lib/xcat/plugins/kit.pm +++ b/xCAT-server/lib/xcat/plugins/kit.pm @@ -17,7 +17,7 @@ use xCAT::Table; use xCAT::Utils; use xCAT::MsgUtils; use Getopt::Long; -use Data::Dumper; +#use Data::Dumper; use File::Basename; use File::Path; @@ -2516,20 +2516,59 @@ sub rmkitcomp } } + # Check if each deploy parameter is used by other kitcomponent. + my @otherlines = (); + foreach my $osikitcomp ( @osikitcomps ) { + next if ( exists($kitcomps{$osikitcomp}{name}) ); + + (my $kitcomptable) = $tabs{kitcomponent}->getAttribs({kitcompname=> $osikitcomp}, 'kitname'); + if ( $kitcomptable and $kitcomptable->{kitname} ) { + (my $kittable) = $tabs{kit}->getAttribs({kitname=> $kitcomptable->{kitname}}, 'kitdir', 'kitdeployparams'); + if ( $kittable and $kittable->{kitdeployparams} and $kittable->{kitdir} ) { + my @otherdeployparams; + my $deployparam_file = $kittable->{kitdir}."/other_files/".$kittable->{kitdeployparams}; + if ( -e "$deployparam_file" ) { + if (open(OTHERDEPLOYPARAM, "<", "$deployparam_file" )) { + @otherdeployparams = ; + close(OTHERDEPLOYPARAM); + } + } + foreach ( @otherdeployparams ) { + push @otherlines, $_; + } + } + } + } + + my @newcontents = (); foreach my $line ( @lines ) { chomp $line; my $found = 0; - foreach my $content ( @contents ) { - chomp $content; - if ( $line =~ /$content/ ) { + + #check if the parameter is used by other kitcomponent + foreach my $otherline ( @otherlines ) { + chomp $otherline; + if ( $line =~ /$otherline/ ) { $found = 1; last; } } - unless ( $found ) { + if ( $found ) { push @newcontents, $line . "\n"; + } else { + foreach my $content ( @contents ) { + chomp $content; + if ( $line =~ /$content/ ) { + $found = 1; + last; + } + } + + unless ( $found ) { + push @newcontents, $line . "\n"; + } } }