Menu

#4345 Utils->osver routine does not support Redhat7 or SLES12.

2.9.1
pending
yangsong
Rehat7 (1)
SLES12
5
2014-11-21
2014-10-30
No

The Utils->osver routine only checks files like /etc/redhat-release, /etc/SuSE-release, the new file on Redhat7 and SLES-12 is /etc/os-release.

It is working for now because the old file is still there, but it is going away eventually.
slesmn:~ # cat /etc/SuSE-release
SUSE Linux Enterprise Server 12 (x86_64)
VERSION = 12
PATCHLEVEL = 0
This file is deprecated and will be removed in a future service pack or release.
Please check /etc/os-release for details about this release.

Discussion

  • Guang Cheng Li

    Guang Cheng Li - 2014-10-31
    • assigned_to: Guang Cheng Li --> yangsong
     
  • yangsong

    yangsong - 2014-11-21
    • status: open --> pending
     
  • yangsong

    yangsong - 2014-11-21

    commit 3f59552d0c5d7cb73de7b576beca574998227728
    Author: immarvin yangsbj@cn.ibm.com
    Date: Fri Nov 21 00:19:37 2014 -0800

    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
    

    diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm
    index 5f37479..8eb1e00 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 =~ /^\sVERSION=\"?([0-9.]+)./){
    + $version=$1;
    + }
    + if($line =~ /^\sVERSION_ID=\"?([0-9.]+)./){
    + $version_id=$1;
    + }
    +
    +
    + if($line =~ /^\sID=\"?([0-9a-z_-.]+)./){
    + $id=$1;
    + }
    + if($line =~ /^\sID_LIKE=\"?([0-9a-z_-.]+)./){
    + $id_like=$1;
    + }
    +
    +
    + if($line =~ /^\sNAME=\"?(.)/){
    + $name=$1;
    + }
    + if($line =~ /^\sPRETTY_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 e611529..2323d46 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";

     
MongoDB Logo MongoDB