From 3f59552d0c5d7cb73de7b576beca574998227728 Mon Sep 17 00:00:00 2001 From: immarvin Date: Fri, 21 Nov 2014 00:19:37 -0800 Subject: [PATCH] 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 --- perl-xCAT/xCAT/Utils.pm | 71 +++++++++++++++++++- xCAT-server/lib/xcat/plugins/DBobjectdefs.pm | 22 ++++-- 2 files changed, 84 insertions(+), 9 deletions(-) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index 5f37479b4..8eb1e0050 100755 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -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" ); diff --git a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm index e61152906..2323d469d 100755 --- a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm +++ b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm @@ -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";