Browse Source

AMBARI-8656 Confirm hosts doesn't passing on CentOS5 (dsen)

Dmytro Sen 10 years ago
parent
commit
2cfc2f843d
1 changed files with 21 additions and 18 deletions
  1. 21 18
      ambari-common/src/main/python/ambari_commons/os_check.py

+ 21 - 18
ambari-common/src/main/python/ambari_commons/os_check.py

@@ -21,30 +21,27 @@ limitations under the License.
 import os
 import sys
 import platform
-import ctypes
-
-class _OSVERSIONINFOEXW(ctypes.Structure):
-  _fields_ = [('dwOSVersionInfoSize', ctypes.c_ulong),
-              ('dwMajorVersion', ctypes.c_ulong),
-              ('dwMinorVersion', ctypes.c_ulong),
-              ('dwBuildNumber', ctypes.c_ulong),
-              ('dwPlatformId', ctypes.c_ulong),
-              ('szCSDVersion', ctypes.c_wchar*128),
-              ('wServicePackMajor', ctypes.c_ushort),
-              ('wServicePackMinor', ctypes.c_ushort),
-              ('wSuiteMask', ctypes.c_ushort),
-              ('wProductType', ctypes.c_byte),
-              ('wReserved', ctypes.c_byte)]
-
-VER_NT_WORKSTATION = 1
-VER_NT_DOMAIN_CONTROLLER = 2
-VER_NT_SERVER = 3
 
 def _get_windows_version():
   """
   Get's the OS major and minor versions.  Returns a tuple of
   (OS_MAJOR, OS_MINOR).
   """
+  import ctypes
+
+  class _OSVERSIONINFOEXW(ctypes.Structure):
+    _fields_ = [('dwOSVersionInfoSize', ctypes.c_ulong),
+                ('dwMajorVersion', ctypes.c_ulong),
+                ('dwMinorVersion', ctypes.c_ulong),
+                ('dwBuildNumber', ctypes.c_ulong),
+                ('dwPlatformId', ctypes.c_ulong),
+                ('szCSDVersion', ctypes.c_wchar*128),
+                ('wServicePackMajor', ctypes.c_ushort),
+                ('wServicePackMinor', ctypes.c_ushort),
+                ('wSuiteMask', ctypes.c_ushort),
+                ('wProductType', ctypes.c_byte),
+                ('wReserved', ctypes.c_byte)]
+
   os_version = _OSVERSIONINFOEXW()
   os_version.dwOSVersionInfoSize = ctypes.sizeof(os_version)
   retcode = ctypes.windll.Ntdll.RtlGetVersion(ctypes.byref(os_version))
@@ -68,6 +65,12 @@ REL_2008R2 = "win2008serverr2"
 REL_2012 = "win2012server"
 REL_2012R2 = "win2012serverr2"
 
+# windows machine types
+VER_NT_WORKSTATION = 1
+VER_NT_DOMAIN_CONTROLLER = 2
+VER_NT_SERVER = 3
+
+
 def os_distribution():
   if platform.system() == SYSTEM_WINDOWS:
     # windows distribution