You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by bi...@apache.org on 2016/07/12 19:41:04 UTC
[35/37] incubator-slider git commit: SLIDER-1150 Slider app fails to
start on AmazonLinux
SLIDER-1150 Slider app fails to start on AmazonLinux
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/f4ae985f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/f4ae985f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/f4ae985f
Branch: refs/heads/feature/SLIDER-1107_AM_config_generation
Commit: f4ae985f6df41f88c0da0631139e662d7adbd6ca
Parents: 833c744
Author: Gour Saha <go...@apache.org>
Authored: Tue Jul 5 18:14:51 2016 -0700
Committer: Gour Saha <go...@apache.org>
Committed: Tue Jul 5 18:14:51 2016 -0700
----------------------------------------------------------------------
.../libraries/functions/os_check.py | 30 +++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/f4ae985f/slider-agent/src/main/python/resource_management/libraries/functions/os_check.py
----------------------------------------------------------------------
diff --git a/slider-agent/src/main/python/resource_management/libraries/functions/os_check.py b/slider-agent/src/main/python/resource_management/libraries/functions/os_check.py
index 8c11d93..5d6cf07 100644
--- a/slider-agent/src/main/python/resource_management/libraries/functions/os_check.py
+++ b/slider-agent/src/main/python/resource_management/libraries/functions/os_check.py
@@ -18,6 +18,7 @@ See the License for the specific language governing permissions and
limitations under the License.
'''
+import re
import os
import sys
import platform
@@ -26,15 +27,42 @@ __all__ = [
'OSCheck',
]
+_IS_REDHAT_LINUX = os.path.exists('/etc/redhat-release')
+
+SYSTEM_RELEASE_FILE = "/etc/system-release"
+
+def _is_redhat_linux():
+ return _IS_REDHAT_LINUX
+
+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 "Amazon" in issue_content:
+ distribution[0] = "amazon"
+ search_groups = re.search('(\d+\.\d+)', issue_content)
+
+ if search_groups:
+ distribution[1] = search_groups.group(1)
+
+ return tuple(distribution)
def linux_distribution():
PYTHON_VER = sys.version_info[0] * 10 + sys.version_info[1]
if PYTHON_VER < 26:
- (distname, version, id) = platform.dist()
+ (distname, version, id) = platform.dist()
+ elif _is_redhat_linux():
+ (distname, version, id) = platform.dist()
else:
(distname, version, id) = platform.linux_distribution()
+ if distname == '':
+ (distname, version) = advanced_check((distname, version))
+ id = ' '
+
return (platform.system(), os.name, distname, version, id)
def windows_distribution():