From 0a87db910b62f4e74c7ca2b897f8b1c262712ea7 Mon Sep 17 00:00:00 2001 From: wanghuaz Date: Tue, 23 Oct 2012 04:07:56 +0000 Subject: [PATCH] Handling postbootscripts in osimage and kitcomponent tables git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@14092 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/kit.pm | 56 +++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index 9132e9595..16e69fa3c 100644 --- a/xCAT-server/lib/xcat/plugins/kit.pm +++ b/xCAT-server/lib/xcat/plugins/kit.pm @@ -292,21 +292,45 @@ sub assign_to_osimage # Adding postbootscrits to osimage.postbootscripts if ( $kitcomptable and $kitcomptable->{postbootscripts} ){ - if ( $osimagetable ){ - if ( $osimagetable->{postbootscripts} ) { - my $match = 0; - my @scripts = split ',', $osimagetable->{postbootscripts}; - foreach my $script ( @scripts ) { - if ( $kitcomptable->{postbootscripts} =~ /^$script$/ ) { - $match = 1; - last; + my @kitcompscripts = split ',', $kitcomptable->{postbootscripts}; + foreach my $kitcompscript ( @kitcompscripts ) { + + my $formatedkitcomp = "KIT_".$kitcompscript; + + if ( $osimagetable ) { + if ( $osimagetable->{postbootscripts} ){ + my $match = 0; + my $added = 0; + my @newscripts; + my @scripts = split ',', $osimagetable->{postbootscripts}; + foreach my $script ( @scripts ) { + if ( $script =~ /^$formatedkitcomp$/ ) { + $match = 1; + last; + } + + if ( $script !~ /^BASEXCAT_/ and $script !~ /^KIT_/ ) { + unless ( $added ) { + push @newscripts, $formatedkitcomp; + $added = 1; + } + } + + + push @newscripts, $script; + } + + if ( $match ) { + next; + } + + my $osimagescripts = join ',', @newscripts; + $osimagetable->{postbootscripts} = $osimagescripts; + } else { + $osimagetable->{postbootscripts} = $formatedkitcomp; } - unless ( $match ) { - $osimagetable->{postbootscripts} = $osimagetable->{postbootscripts} . ',' . $kitcomptable->{postbootscripts}; - } - } else { - $osimagetable->{postbootscripts} = $kitcomptable->{postbootscripts}; + } } @@ -1383,7 +1407,9 @@ sub addkitcomp @oskitcomps = split ',', $osimagetable->{'kitcomponents'}; } - foreach my $kitcomp ( keys %kitcomps ) { + my @newkitcomps = keys %kitcomps; + foreach ( keys %kitcomps ) { + my $kitcomp = shift @newkitcomps; $callback->({data=>["Assigning kit component $kitcomp to osimage $osimage"]}); # Check if this component is existing in osimage.kitcomponents @@ -1631,7 +1657,7 @@ sub rmkitcomp foreach my $kitcomponent (keys %kitcomps) { my @kitcompscripts = split( ',', $kitcomps{$kitcomponent}{postbootscripts} ); foreach my $kitcompscript ( @kitcompscripts ) { - if ( $osimagescript eq $kitcompscript ) { + if ( $osimagescript =~ /^KIT_$kitcompscript$/ ) { $match = 1; last; }