diff --git a/script/gspylib/os/gsplatform.py b/script/gspylib/os/gsplatform.py index 746cd56708ab0e85e40839a98745a7905bde6cac..2aac3ba2ee557214f819036f91ff873b84de193f 100644 --- a/script/gspylib/os/gsplatform.py +++ b/script/gspylib/os/gsplatform.py @@ -76,6 +76,7 @@ UNIONTECH = "uniontech" UOS = "uos" SUPPORT_WHOLE_PLATFORM_LIST = [SUSE, REDHAT, CENTOS, EULEROS, FUSIONOS, OPENEULER, KYLIN, ASIANUX, DEBIAN, UBUNTU, UOS, UNIONTECH] +SUPPORT_USER_DEFINED_OS_LIST = [] # RedhatX platform SUPPORT_RHEL_SERIES_PLATFORM_LIST = [REDHAT, CENTOS, "kylin", "asianux"] SUPPORT_RHEL6X_VERSION_LIST = ["6.4", "6.5", "6.6", "6.7", "6.8", "6.9", "10"] @@ -320,7 +321,7 @@ def linux_distribution(distname='', version='', idNum='', """ is_flag_osid = False - is_flag_oscorrect = True + is_flag_oscorrect = False try: etc = os.listdir('/etc') except os.error: @@ -341,24 +342,24 @@ def linux_distribution(distname='', version='', idNum='', if distname == "UnionTech": distname = "uos" # Read the first line - if gFile is None: - return distname, version, idNum - with open('/etc/' + gFile, 'r') as f: - firstline = f.readline() - _distname, _version, _id = _parse_release_file(firstline) - - if _distname and full_distribution_name: - distname = _distname - for dist in SUPPORT_WHOLE_PLATFORM_LIST: - if dist.lower == _distname.lower: - is_flag_oscorrect = True - if _version: - version = _version - if _id: - idNum = _id - if is_flag_oscorrect == True: - return distname, version, idNum - elif is_flag_oscorrect == False: + if gFile is not None: + with open('/etc/' + gFile, 'r') as f: + firstline = f.readline() + _distname, _version, _id = _parse_release_file(firstline) + + if _distname and full_distribution_name: + distname = _distname + for dist in SUPPORT_WHOLE_PLATFORM_LIST: + if dist.lower == _distname.lower: + is_flag_oscorrect = True + if _version: + version = _version + if _id: + idNum = _id + if is_flag_oscorrect == True: + return distname, version, idNum + + if is_flag_oscorrect == False: # Read system information from configuration file # Call the function and pass in the filename osid_path = os.path.realpath( @@ -379,11 +380,11 @@ def linux_distribution(distname='', version='', idNum='', if is_flag_osid: if selected_data['os']: distname = selected_data['os'] + SUPPORT_USER_DEFINED_OS_LIST.append(distname) + SUPPORT_USER_DEFINED_OS_LIST.append(distname.lower()) if selected_data['version']: version = selected_data['version'] - if selected_data['bit']: - idNum = selected_data['bit'] - return distname, version, idNum + return distname, version, idNum def dist(supported_dists=_supported_dists): """ Tries to determine the name of the Linux OS distribution name. @@ -1737,6 +1738,12 @@ class LinuxPlatform(GenericPlatform): prefixStr, packageVersion, PAK_UOS, BIT_VERSION, postfixStr)) + elif distname in SUPPORT_USER_DEFINED_OS_LIST: + fileName = os.path.join(dirName, "./../../../", + "%s-%s-%s-%s.%s" % ( + prefixStr, packageVersion, + SUPPORT_USER_DEFINED_OS_LIST[0], + BIT_VERSION, postfixStr)) else: raise Exception(ErrorCode.GAUSS_519["GAUSS_51900"] + "Supported platforms are: %s." % str( @@ -2156,7 +2163,8 @@ class RHELPlatform(LinuxPlatform): version[0:3] in SUPPORT_RHEL_SERIES_VERSION_LIST)) or (distName.lower() == OPENEULER) or (distName.lower() == FUSIONOS) or - (distName.lower() == DEBIAN and version == "buster/sid") + (distName.lower() == DEBIAN and version == "buster/sid") or + (distName.lower() in SUPPORT_USER_DEFINED_OS_LIST) )): return distName.lower(), version[0:3] else: @@ -2214,7 +2222,8 @@ class UserPlatform(): # Kylin "10" 64bit # Ubuntu "18.04" 64bit distName, version, idNum = dist() - if distName.lower() not in SUPPORT_WHOLE_PLATFORM_LIST: + if dist_name.lower() not in SUPPORT_WHOLE_PLATFORM_LIST \ + and dist_name.lower() not in SUPPORT_USER_DEFINED_OS_LIST: raise Exception(ErrorCode.GAUSS_519["GAUSS_51900"] + "Supported platforms are: %s." % str( SUPPORT_WHOLE_PLATFORM_LIST)) diff --git a/script/local/LocalCheckOS.py b/script/local/LocalCheckOS.py index 7be9628fbec777248ce279e3d6253d64b84d5f2f..ba902275a88ad91e80238120ef0b53be8e6aced4 100644 --- a/script/local/LocalCheckOS.py +++ b/script/local/LocalCheckOS.py @@ -48,7 +48,7 @@ from os_platform.linux_distro import LinuxDistro from os_platform.common import SUPPORT_RHEL6X_VERSION_LIST, \ SUPPORT_RHEL7X_VERSION_LIST, SUPPORT_SUSE12X_VERSION_LIST, \ SUPPORT_SUSE11X_VERSION_LIST, SUPPORT_RHEL8X_VERSION_LIST, \ - SUPPORT_RHEL_LEAST_VERSION + SUPPORT_RHEL_LEAST_VERSION, SUPPORT_USER_DEFINED_OS_LIST sys.path.insert(0, localDirPath + "/../../lib") import psutil @@ -1914,6 +1914,9 @@ def CheckPlatformInfo(): elif (data.distname == "debian" or data.version == "buster/sid"): mixed_type = "%s" % data.distname platform_str = "%s_%s_%s" % (data.distname, data.version, data.bits) + elif (data.distname in SUPPORT_USER_DEFINED_OS_LIST): + mixed_type = "%s" % data.distname + platform_str = "%s_%s_%s" % (data.distname, data.version, data.bits) else: g_logger.log("Warning reason: %s version is not the official version" "supported by OM, but you can still deploy and install it" % diff --git a/script/os_platform/UserPlatform.py b/script/os_platform/UserPlatform.py index 816a88db85a94e7d73d50edd7e961d45d70895b9..6fd27698bdabb703a4ebf2d35004cc778509cc3b 100644 --- a/script/os_platform/UserPlatform.py +++ b/script/os_platform/UserPlatform.py @@ -21,7 +21,7 @@ from gspylib.common.ErrorCode import ErrorCode from os_platform.common import SUPPORT_WHOLE_PLATFORM_LIST, SUSE, \ - SUPPORT_RHEL_SERIES_PLATFORM_LIST + SUPPORT_RHEL_SERIES_PLATFORM_LIST, SUPPORT_USER_DEFINED_OS_LIST from os_platform.linux_distro import LinuxDistro from os_platform.rhel_platform import RHELPlatform from os_platform.sles_platform import SLESPlatform @@ -44,7 +44,8 @@ class UserPlatform(object): # Kylin "10" 64bit # Ubuntu "18.04" 64bit dist_name = LinuxDistro.linux_distribution()[0] - if dist_name.lower() not in SUPPORT_WHOLE_PLATFORM_LIST: + if dist_name.lower() not in SUPPORT_WHOLE_PLATFORM_LIST \ + and dist_name.lower() not in SUPPORT_USER_DEFINED_OS_LIST: raise Exception(ErrorCode.GAUSS_519["GAUSS_51900"] + "Supported platforms are: %s." % str( SUPPORT_WHOLE_PLATFORM_LIST)) diff --git a/script/os_platform/common.py b/script/os_platform/common.py index c3b2c63f446d859324e179a038fb153bba1e8b8d..fab0dbc3f975e776e36c85055f7b69b4961df7bc 100644 --- a/script/os_platform/common.py +++ b/script/os_platform/common.py @@ -35,6 +35,7 @@ UNIONTECH = "uniontech" UOS = "uos" SUPPORT_WHOLE_PLATFORM_LIST = [SUSE, REDHAT, CENTOS, EULEROS, OPENEULER, KYLIN, FUSIONOS, ASIANUX, DEBIAN, UBUNTU, UOS, UNIONTECH] +SUPPORT_USER_DEFINED_OS_LIST = [] # RedhatX platform SUPPORT_RHEL_SERIES_PLATFORM_LIST = [REDHAT, CENTOS, "kylin", "asianux"] SUPPORT_RHEL6X_VERSION_LIST = ["6.4", "6.5", "6.6", "6.7", "6.8", "6.9", "10"] diff --git a/script/os_platform/linux_distro.py b/script/os_platform/linux_distro.py index 95a82927a799b5b38c4ded08019f876b73436207..91ef054b2579d2ff8e420b5cbb93f4f9276ed05e 100644 --- a/script/os_platform/linux_distro.py +++ b/script/os_platform/linux_distro.py @@ -24,7 +24,8 @@ import re import select import sys -from os_platform.common import _supported_dists,SUPPORT_WHOLE_PLATFORM_LIST +from os_platform.common import _supported_dists,SUPPORT_WHOLE_PLATFORM_LIST,\ +SUPPORT_USER_DEFINED_OS_LIST ISCONFIGURETRUE = "# isConfigure = TRUE" ISCONFIGUREFALSE = "# isConfigure = FALSE" @@ -237,7 +238,7 @@ class LinuxDistro(object): """ is_flag_osid = False - is_flag_oscorrect = True + is_flag_oscorrect = False try: etc_dir = os.listdir('/etc') except os.error: @@ -259,24 +260,24 @@ class LinuxDistro(object): if distname == "UnionTech": distname = "uos" # Read the first line - if gFile is None: - return distname, version, idNum - with open('/etc/' + gFile, 'r') as f: - firstline = f.readline() - _distname, _version, _id = LinuxDistro._parse_release_file(firstline) - - if _distname and full_distribution_name: - distname = _distname - for dist in SUPPORT_WHOLE_PLATFORM_LIST: - if dist.lower == _distname.lower: - is_flag_oscorrect = True - if _version: - version = _version - if _id: - idNum = _id - if is_flag_oscorrect == True: - return distname, version, idNum - elif is_flag_oscorrect == False: + if gFile is not None: + with open('/etc/' + gFile, 'r') as f: + firstline = f.readline() + _distname, _version, _id = LinuxDistro._parse_release_file(firstline) + + if _distname and full_distribution_name: + distname = _distname + for dist in SUPPORT_WHOLE_PLATFORM_LIST: + if dist.lower == _distname.lower: + is_flag_oscorrect = True + if _version: + version = _version + if _id: + idNum = _id + if is_flag_oscorrect == True: + return distname, version, idNum + + if is_flag_oscorrect == False: # Read system information from configuration file # Call the function and pass in the filename osid_path = os.path.realpath( @@ -297,8 +298,8 @@ class LinuxDistro(object): if is_flag_osid: if selected_data['os']: distname = selected_data['os'] + SUPPORT_USER_DEFINED_OS_LIST.append(distname) + SUPPORT_USER_DEFINED_OS_LIST.append(distname.lower()) if selected_data['version']: version = selected_data['version'] - if selected_data['bit']: - idNum = selected_data['bit'] - return distname, version, idNum + return distname, version, idNum diff --git a/script/os_platform/linux_platform.py b/script/os_platform/linux_platform.py index b4ac31d15f9c3ed028fa8549d2f33f0381e6ddc1..554f3cbae4b7dd13b86face33351629c741b7518 100644 --- a/script/os_platform/linux_platform.py +++ b/script/os_platform/linux_platform.py @@ -26,7 +26,7 @@ from os_platform.common import REDHAT, PAK_REDHAT, BIT_VERSION, \ CENTOS, UOS, PAK_EULER, PAK_CENTOS, ASIANUX, SUSE, PAK_ASIANUX, \ EULEROS, OPENEULER, KYLIN, PAK_OPENEULER, SUPPORT_WHOLE_PLATFORM_LIST,\ BLANK_SPACE, PAK_UBUNTU, DEBIAN, PAK_KYLIN, PAK_UOS, PAK_SUSE, PAK_DEBIAN, \ - FUSIONOS, PAK_FUSIONOS + FUSIONOS, PAK_FUSIONOS, SUPPORT_USER_DEFINED_OS_LIST from os_platform.linux_distro import LinuxDistro @@ -231,6 +231,11 @@ class LinuxPlatform(object): self.package_file_path(prefix_str, packageVersion, PAK_FUSIONOS, postfix_str) ] + elif distname in SUPPORT_USER_DEFINED_OS_LIST: + file_name_list = [ + self.package_file_path(prefix_str, packageVersion, SUPPORT_USER_DEFINED_OS_LIST[0], postfix_str) + ] + else: raise Exception(ErrorCode.GAUSS_519["GAUSS_51900"] + "Supported platforms are: %s." % str( diff --git a/script/os_platform/rhel_platform.py b/script/os_platform/rhel_platform.py index 88ccbe43d83decffe1e8db8ebe6e6623654eb873..9ff0fca4efd56d8de2a1b02cfd6c123e51c0c297 100644 --- a/script/os_platform/rhel_platform.py +++ b/script/os_platform/rhel_platform.py @@ -27,7 +27,7 @@ from os_platform.common import BIT_VERSION, EULEROS, SUPPORT_EULEROS_VERSION_LIS FUSIONOS, SUPPORT_RHEL_SERIES_PLATFORM_LIST, \ SUPPORT_RHEL_SERIES_VERSION_LIST, OPENEULER, CENTOS, \ UOS, UNIONTECH, SUPPORT_UOS_VERSION_LIST, \ - SUPPORT_RHEL7X_VERSION_LIST, DEBIAN, BLANK_SPACE + SUPPORT_RHEL7X_VERSION_LIST, DEBIAN, BLANK_SPACE, SUPPORT_USER_DEFINED_OS_LIST from os_platform.linux_distro import LinuxDistro from os_platform.linux_platform import LinuxPlatform @@ -172,7 +172,8 @@ class RHELPlatform(LinuxPlatform): version[0:3] in SUPPORT_RHEL_SERIES_VERSION_LIST)) or (dist_name.lower() == OPENEULER) or (dist_name.lower() == FUSIONOS) or - (dist_name.lower() == DEBIAN and version == "buster/sid") + (dist_name.lower() == DEBIAN and version == "buster/sid") or + (dist_name.lower() in SUPPORT_USER_DEFINED_OS_LIST) )): return dist_name.lower(), version[0:3] elif((bits == BIT_VERSION and