This is an automated email from the ASF dual-hosted git repository.

aonishuk pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 7301ffc  AMBARI-24456. Ambari server can not start on latest Amazon 
Linux 2 (aonishuk)
7301ffc is described below

commit 7301ffc6506025495b6d59b5190dede336cd8404
Author: Andrew Onishuk <aonis...@hortonworks.com>
AuthorDate: Fri Aug 10 11:19:49 2018 +0300

    AMBARI-24456. Ambari server can not start on latest Amazon Linux 2 
(aonishuk)
---
 ambari-common/src/main/python/ambari_commons/os_check.py | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/ambari-common/src/main/python/ambari_commons/os_check.py 
b/ambari-common/src/main/python/ambari_commons/os_check.py
index d9097a1..e242d7b 100644
--- a/ambari-common/src/main/python/ambari_commons/os_check.py
+++ b/ambari-common/src/main/python/ambari_commons/os_check.py
@@ -78,7 +78,7 @@ VER_NT_SERVER = 3
 _IS_ORACLE_LINUX = os.path.exists('/etc/oracle-release')
 _IS_REDHAT_LINUX = os.path.exists('/etc/redhat-release')
 
-SYSTEM_RELEASE_FILE = "/etc/system-release"
+OS_RELEASE_FILE = "/etc/os-release"
 
 def _is_oracle_linux():
   return _IS_ORACLE_LINUX
@@ -91,13 +91,16 @@ def _is_powerpc():
 
 def advanced_check(distribution):
   distribution = list(distribution)
-  if os.path.exists(SYSTEM_RELEASE_FILE):
-    with open(SYSTEM_RELEASE_FILE, "rb") as fp:
-      issue_content = fp.read()
+  if os.path.exists(OS_RELEASE_FILE):
+    with open(OS_RELEASE_FILE, "rb") as fp:
+      file_content = fp.read()
   
-    if "Amazon" in issue_content:
+    search_groups = re.search('NAME="(.+)"', file_content)
+    name = search_groups.group(1) if search_groups else ''
+
+    if "amazon" in name.lower():
       distribution[0] = "amazonlinux"
-      search_groups = re.search(' release (\d+)', issue_content)
+      search_groups = re.search('VERSION_ID="(\d+)"', file_content)
       
       if search_groups:
         distribution[1] = search_groups.group(1)

Reply via email to