make kit work with old osimage which doesnt contains osdistro attributes

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@14473 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
wanghuaz 2012-11-29 07:17:15 +00:00
parent fb0ad21c3f
commit ef0d8c786a

View File

@ -1392,7 +1392,7 @@ sub addkitcomp
($osdistrotable) = $tabs{osdistro}->getAttribs({osdistroname=> $osimagetable->{'osdistroname'}}, 'basename', 'majorversion', 'minorversion', 'arch', 'type');
if ( !$osdistrotable or !$osdistrotable->{basename} ) {
my %rsp;
push@{ $rsp{data} }, "$osdistroname osdistro does not exist";
push @{ $rsp{data} }, "$osdistroname osdistro does not exist";
xCAT::MsgUtils->message( "E", \%rsp, $callback );
return 1;
}
@ -1407,13 +1407,34 @@ sub addkitcomp
# Read serverrole from osimage.
$os{$osimage}{serverrole} = lc($osimagetable->{'serverrole'});
} else {
} elsif ( !$osimagetable or !$osimagetable->{'osname'} ) {
my %rsp;
push@{ $rsp{data} }, "$osimage osimage does not exist or not saticified";
push@{ $rsp{data} }, "osimage $osimage does not contains a valid 'osname' attribute";
xCAT::MsgUtils->message( "E", \%rsp, $callback );
return 1;
} elsif ( !$osimagetable->{'osvers'} ) {
my %rsp;
push@{ $rsp{data} }, "osimage $osimage does not contains a valid 'osvers' attribute";
xCAT::MsgUtils->message( "E", \%rsp, $callback );
return 1;
} elsif ( !$osimagetable->{'osarch'} ) {
my %rsp;
push@{ $rsp{data} }, "osimage $osimage does not contains a valid 'osarch' attribute";
xCAT::MsgUtils->message( "E", \%rsp, $callback );
return 1;
} else {
$os{$osimage}{type} = lc($osimagetable->{'osname'});
$os{$osimage}{arch} = lc($osimagetable->{'osarch'});
$os{$osimage}{serverrole} = lc($osimagetable->{'serverrole'});
my ($basename, $majorversion, $minorversion) = $osimagetable->{'osvers'} =~ /^(\D+)(\d+)\W+(\d+)/;
$os{$osimage}{basename} = lc($basename);
$os{$osimage}{majorversion} = lc($majorversion);
$os{$osimage}{minorversion} = lc($minorversion);
}
foreach my $kitcomp ( keys %kitcomps ) {
(my $kitcomptable) = $tabs{kitcomponent}->getAttribs({kitcompname => $kitcomp}, 'kitname', 'kitreponame', 'serverroles', 'kitcompdeps');
if ( $kitcomptable and $kitcomptable->{'kitname'} and $kitcomptable->{'kitreponame'}) {