From 526e1fb67db8ba70bab06147d9edf9163ac654f7 Mon Sep 17 00:00:00 2001 From: wanghuaz Date: Thu, 24 Jan 2013 10:00:25 +0000 Subject: [PATCH] Now kitcomponent and osimage could specify multiple serverroles, addkitcomp and chkkitcomp will match their every serverrole git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@14978 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/kit.pm | 54 +++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index 02dbacf0f..ab73ac66c 100644 --- a/xCAT-server/lib/xcat/plugins/kit.pm +++ b/xCAT-server/lib/xcat/plugins/kit.pm @@ -1640,11 +1640,28 @@ sub addkitcomp return 1; } - if ( $os{$osimage}{serverrole} and ($os{$osimage}{serverrole} ne $kitcomps{$kitcomp}{serverroles}) ) { - my %rsp; - push@{ $rsp{data} }, "osimage $osimage doesn't fit to kit component $kitcomp with attribute serverrole"; - xCAT::MsgUtils->message( "E", \%rsp, $callback ); - return 1; + if ( $os{$osimage}{serverrole} ) { + my $match = 0; + my @os_serverroles = split /,/, $os{$osimage}{serverrole}; + my @kitcomp_serverroles = split /,/, $kitcomps{$kitcomp}{serverroles}; + foreach my $os_serverrole (@os_serverroles) { + foreach my $kitcomp_serverrole (@kitcomp_serverroles) { + if ( $os_serverrole eq $kitcomp_serverrole ) { + $match = 1; + last; + } + } + + if ( $match ) { + last; + } + } + if ( !$match ) { + my %rsp; + push@{ $rsp{data} }, "osimage $osimage doesn't fit to kit component $kitcomp with attribute serverrole"; + xCAT::MsgUtils->message( "E", \%rsp, $callback ); + return 1; + } } if ( $kitcomptable and $kitcomptable->{'kitcompdeps'} ) { @@ -2681,11 +2698,28 @@ sub chkkitcomp return 1; } - if ( $os{$osimage}{serverrole} and ($os{$osimage}{serverrole} ne $kitcomps{$kitcomp}{serverroles}) ) { - my %rsp; - push@{ $rsp{data} }, "kit component $kitcomp doesn't fit to osimage $osimage with attribute serverrole"; - xCAT::MsgUtils->message( "E", \%rsp, $callback ); - return 1; + if ( $os{$osimage}{serverrole} ) { + my $match = 0; + my @os_serverroles = split /,/, $os{$osimage}{serverrole}; + my @kitcomp_serverroles = split /,/, $kitcomps{$kitcomp}{serverroles}; + foreach my $os_serverrole (@os_serverroles) { + foreach my $kitcomp_serverrole (@kitcomp_serverroles) { + if ( $os_serverrole eq $kitcomp_serverrole ) { + $match = 1; + last; + } + } + + if ( $match ) { + last; + } + } + if ( !$match ) { + my %rsp; + push@{ $rsp{data} }, "osimage $osimage doesn't fit to kit component $kitcomp with attribute serverrole"; + xCAT::MsgUtils->message( "E", \%rsp, $callback ); + return 1; + } } # Check if this kit component's dependencies are in the kitcomponent list.