Explorar el Código

AMBARI-492. make support for os check a bit more robust (Contributed by Hitesh)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/branches/ambari-186@1347328 13f79535-47bb-0310-9956-ffa450edef68
Vikram Dixit K hace 13 años
padre
commit
85075f943f

+ 2 - 0
CHANGES.txt

@@ -6,6 +6,8 @@ characters wide.
 
 Release 0.1.x - unreleased
 
+  AMBARI-492. make support for os check a bit more robust (Hitesh via Vikram)
+
   AMBARI-491. Service Reconfiguration screens should respect the "reconfigurable" attributes set in ConfigProperties table (Yusaku via Vikram)
 
   AMBARI-490. Highlight the required parameters in Step 6 "Custom Config" of the Cluster Init Wizard (Yusaku via Vikram)

+ 2 - 2
hmc/php/frontend/addNodes/obtainNodesInfo.php

@@ -21,8 +21,8 @@ function getCommandLine() {
   $cpuCmd = "grep -c processor /proc/cpuinfo ;";
   $archCmd = "uname -m ;";
   $mntPointCmd = "df -lkh | sed \\\"1 d\\\" | grep -vw \\\"/boot\\\" | grep -vw \\\"/dev\/shm\\\" | grep -vw \\\"/home\\\" | grep -vw \/ | awk '{ print \\\$(NF)}' ; ";
-  $osTypeCmd = "if [ -f /usr/bin/lsb_release ] ; then lsb_release -si | tr '[:upper:]' '[:lower:]' | cut -d ' ' -f 1; lsb_release -sr | cut -d . -f 1; "
-      . "else cat \\`ls /etc/*release | grep \\\"redhat\|SuSE\\\"\\` | head -1 | awk '{ first=\\\"\\\"; ver=\\\"\\\"; for(i=1; i<=NF; i++) { if ( i == 1 ) print \\\$i; if ( \\\$i ~ /[0-9]+/ ) { print \\\$i; break; } } }' | tr '[:upper:]' '[:lower:]' ; "
+  $osTypeCmd = "if [ -f /usr/bin/lsb_release ] ; then lsb_release -sd | tr '[:upper:]' '[:lower:]' | tr '\\\"' ' ' | awk '{ for(i=1; i<=NF; i++) { print \\\$i; print '\\n'; if ( \\\$i ~ /[0-9]+/ ) { break; } } }' ; "
+      . "else cat \\`ls /etc/*release | grep \\\"redhat\|SuSE\\\"\\` | head -1 | awk '{ for(i=1; i<=NF; i++) { print \\\$i; print '\\n'; if ( \\\$i ~ /[0-9]+/ ) { break; } } }' | tr '[:upper:]' '[:lower:]' ; "
       . "fi ; ";
   $osInfoCmd = "if [ -f /usr/bin/lsb_release ] ; then lsb_release -sd | tr '\\\"' ' '; "
       . " else cat \\`ls /etc/*release | grep \\\"redhat\|SuSE\\\"\\` | head -1 ; "

+ 10 - 2
hmc/php/frontend/addNodes/verifyAndUpdateNodesInfo.php

@@ -160,7 +160,15 @@ function populateVal ($line, $count, $arr)
     if (!isset($arr["osType"])) {
       $arr["osType"] = "";
     }
-    $arr["osType"] .= trim($line);
+    $lline = strtolower(trim($line));
+    if ($lline == "release") {
+      continue;
+    }
+    $matches = array();
+    if (preg_match("/([0-9]+)(\.[0-9]+)?/", $lline, $matches) > 0) {
+      $lline = $matches[1];
+    }
+    $arr["osType"] .= $lline;
     break;
   case 5:
     if (!isset($arr["os"])) {
@@ -279,7 +287,7 @@ if ($dirHandle = opendir($prevOutputDir)) {
       }
 
       if ($nodeStatus == "SUCCESS") {
-        if ($thisHostArray["osType"] != "redhatenterpriseserver5"
+        if ($thisHostArray["osType"] != "redhatenterpriselinuxserver5"
             && $thisHostArray["osType"] != "centos5") {
           $thisHostArray["badHealthReason"] = "Unsupported OS";
           $finalOpStatus = "FAILED";