fix defect #4307 [FVT]:chdef newimage -u give out wrong arch in ubuntu; fix defect #4345 Utils->osver routine does not support Redhat7 or SLES12;fix defect #4308 [FVT]: osarch default value of user defined osimage is ppc64le. needs to change to ppc64el

This commit is contained in:
immarvin 2014-11-21 00:19:37 -08:00
parent 72c058edc9
commit 3f59552d0c
2 changed files with 84 additions and 9 deletions

View File

@ -2162,7 +2162,72 @@ sub osver
my $line = '';
my @lines;
my $relfile;
if (-f "/etc/redhat-release")
if (-f "/etc/os-release"){
my $version;
my $version_id;
my $id;
my $id_like;
my $name;
my $prettyname;
my $verrel;
if (open($relfile,"<","/etc/os-release")) {
my @text = <$relfile>;
close($relfile);
chomp(@text);
#print Dumper(\@text);
foreach my $line (@text){
if($line =~ /^\s*VERSION=\"?([0-9\.]+).*/){
$version=$1;
}
if($line =~ /^\s*VERSION_ID=\"?([0-9\.]+).*/){
$version_id=$1;
}
if($line =~ /^\s*ID=\"?([0-9a-z\_\-\.]+).*/){
$id=$1;
}
if($line =~ /^\s*ID_LIKE=\"?([0-9a-z\_\-\.]+).*/){
$id_like=$1;
}
if($line =~ /^\s*NAME=\"?(.*)/){
$name=$1;
}
if($line =~ /^\s*PRETTY_NAME=\"?(.*)/){
$prettyname=$1;
}
}
}
$os=$id;
if (!$os and $id_like) {
$os=$id_like;
}
$verrel=$version;
if (!$verrel and $version_id) {
$verrel=$version_id;
}
if(!$name and $prettyname){
$name=$prettyname;
}
if($os =~ /rhel/ and $name =~ /Server/i){
$os="rhels";
}
if($verrel =~ /([0-9]+)\.?(.*)/) {
$ver=$1;
$rel=$2;
}
# print "$ver -- $rel";
}
elsif (-f "/etc/redhat-release")
{
open($relfile,"<","/etc/redhat-release");
$line = <$relfile>;
@ -2269,8 +2334,10 @@ sub osver
close($relfile);
}
}
#print "xxxx $type === $rel \n";
if ( $type and $type =~ /all/ ) {
if ( $rel ) {
if ( $rel ne "") {
# print "xxx $os-$ver-$rel \n";
return( "$os" . "," . "$ver" . ".$rel" );
} else {
return( "$os" . "," . "$ver" );

View File

@ -192,6 +192,14 @@ sub parse_attr_for_osimage{
return -1;
}
my ($tmp_imagetype, $tmp_arch, $tmp_osname,$tmp_ostype,$tmp_osvers);
if (!exists($attr_hash->{osvers})) {
$tmp_osvers = xCAT::Utils->osver("all");
$tmp_osvers =~ s/,//;
$attr_hash->{osvers} = $tmp_osvers;
} else {
$tmp_osvers =$attr_hash->{osvers};
}
if (!exists($attr_hash->{osarch})) {
$tmp_arch = `uname -m`;
chomp($tmp_arch);
@ -200,13 +208,13 @@ sub parse_attr_for_osimage{
} else {
$tmp_arch = $attr_hash->{osarch};
}
if (!exists($attr_hash->{osvers})) {
$tmp_osvers = xCAT::Utils->osver("all");
$tmp_osvers =~ s/,//;
$attr_hash->{osvers} = $tmp_osvers;
} else {
$tmp_osvers =$attr_hash->{osvers};
}
#for ubuntu,the the arch attribute "ppc64le" should be modified to "ppc64el"
if(($tmp_osvers =~ /^ubuntu/i) && ($tmp_arch =~ /^ppc64le/i)){
$tmp_arch="ppc64el";
$attr_hash->{osarch} = "ppc64el";
}
$tmp_osname = $tmp_osvers;
$tmp_ostype="Linux"; #like Linux, Windows
$tmp_imagetype="linux";