From 21e51b18ad5f1040d80026f22eeb758641932057 Mon Sep 17 00:00:00 2001 From: hzx <245352261@qq.com> Date: Wed, 4 Sep 2024 15:02:34 +0800 Subject: [PATCH] add support for H3Linux && NingOS platform --- build.sh | 8 ++++-- build/get_PlatForm_str.sh | 8 ++++++ script/base_diff/comm_constants.py | 2 +- script/domain_utils/cluster_os/os_file.py | 2 +- script/gs_postuninstall | 2 +- script/gspylib/common/Common.py | 10 +++---- .../gspylib/inspection/common/SharedFuncs.py | 2 +- .../inspection/items/network/CheckBond.py | 2 +- .../gspylib/inspection/items/os/CheckOSVer.py | 13 ++++++++- script/gspylib/os/gsplatform.py | 28 ++++++++++++++++--- script/local/LocalCheckOS.py | 8 +++--- script/os_platform/common.py | 10 +++++-- script/os_platform/linux_platform.py | 14 +++++++++- script/os_platform/rhel_platform.py | 6 +++- 14 files changed, 90 insertions(+), 25 deletions(-) diff --git a/build.sh b/build.sh index 046a220..97b8931 100644 --- a/build.sh +++ b/build.sh @@ -54,7 +54,7 @@ done PLAT_FORM_STR=$(sh "${ROOT_DIR}/build/get_PlatForm_str.sh") if [ "${PLAT_FORM_STR}"x == "Failed"x ]; then - echo "We only support openEuler(aarch64), EulerOS(aarch64), FusionOS, CentOS, UOS platform." + echo "We only support openEuler(aarch64), EulerOS(aarch64), FusionOS, CentOS, UOS, H3Linux, NingOS platform." exit 1; fi @@ -80,8 +80,12 @@ elif [ X$(echo $PLAT_FORM_STR | grep "kylin") != X"" ]; then dist_version="Kylin" elif [ X$(echo $PLAT_FORM_STR | grep "uos") != X"" ]; then dist_version="UOS" +elif [ X$(echo $PLAT_FORM_STR | grep "h3linux") != X"" ]; then + dist_version="H3Linux" +elif [ X$(echo $PLAT_FORM_STR | grep "ningos") != X"" ]; then + dist_version="NingOS" else - echo "We only support openEuler(aarch64), EulerOS(aarch64), FusionOS, CentOS, Ubuntu(x86), UOS platform." + echo "We only support openEuler(aarch64), EulerOS(aarch64), FusionOS, CentOS, Ubuntu(x86), UOS, H3Linux, NingOS platform." echo "Kernel is $kernel" exit 1 fi diff --git a/build/get_PlatForm_str.sh b/build/get_PlatForm_str.sh index 5f21779..f25a33e 100644 --- a/build/get_PlatForm_str.sh +++ b/build/get_PlatForm_str.sh @@ -41,6 +41,14 @@ function get_os_str() { os_str=uos_x86_64 elif [ "$os_name"x = "uos"x ] && [ "$cpu_arc"x = "aarch64"x ]; then os_str=uos_aarch64 + elif [ "$os_name"x = "h3linux"x ] && [ "$cpu_arc"x = "x86_64"x ]; then + os_str=uos_x86_64 + elif [ "$os_name"x = "h3linux"x ] && [ "$cpu_arc"x = "aarch64"x ]; then + os_str=uos_aarch64 + elif [ "$os_name"x = "ningos"x ] && [ "$cpu_arc"x = "x86_64"x ]; then + os_str=uos_x86_64 + elif [ "$os_name"x = "ningos"x ] && [ "$cpu_arc"x = "aarch64"x ]; then + os_str=uos_aarch64 else os_str="Failed" fi diff --git a/script/base_diff/comm_constants.py b/script/base_diff/comm_constants.py index a664e4a..e79f05d 100644 --- a/script/base_diff/comm_constants.py +++ b/script/base_diff/comm_constants.py @@ -33,4 +33,4 @@ class CommConstants: UPGRADE_SQL_FILE = "upgrade_sql.tar.gz" # not support grep upgrade FIRST_GREY_UPGRADE_NUM = -1 - DIST_NAME_TUPLE = ("redhat", "euleros", "centos", "openEuler", "FusionOS") + DIST_NAME_TUPLE = ("redhat", "euleros", "centos", "openEuler", "FusionOS", "H3Linux", "NingOS") diff --git a/script/domain_utils/cluster_os/os_file.py b/script/domain_utils/cluster_os/os_file.py index b086c68..97e2618 100644 --- a/script/domain_utils/cluster_os/os_file.py +++ b/script/domain_utils/cluster_os/os_file.py @@ -83,7 +83,7 @@ class OsFile: return init_system_file if distname == "SuSE" and os.path.isfile(init_file_suse): init_file = init_file_suse - elif distname in ("redhat", "centos", "euleros", "oracle", "openEuler", "FusionOS") \ + elif distname in ("redhat", "centos", "euleros", "oracle", "openEuler", "FusionOS", "H3Linux", "NingOS") \ and os.path.isfile(init_file_redhat): init_file = init_file_redhat elif distname == "kylin" and os.path.isfile(init_file_kylin): diff --git a/script/gs_postuninstall b/script/gs_postuninstall index f924ecc..319bba0 100644 --- a/script/gs_postuninstall +++ b/script/gs_postuninstall @@ -317,7 +317,7 @@ General options: group = grp.getgrgid(pwd.getpwnam(self.user).pw_gid).gr_name distname, version, idnum = LinuxDistro.linux_distribution() # check if OS version is redhat or Euler - if (distname in ("redhat", "euleros", "centos", "openEuler", "FusionOS")): + if (distname in ("redhat", "euleros", "centos", "openEuler", "FusionOS", "H3Linux", "NingOS")): if (self.deleteGroup != True and self.deleteUser == True and self.user == group): GaussLog.exitWithError(ErrorCode.GAUSS_500["GAUSS_50001"] % diff --git a/script/gspylib/common/Common.py b/script/gspylib/common/Common.py index ee772f1..1f4f54a 100644 --- a/script/gspylib/common/Common.py +++ b/script/gspylib/common/Common.py @@ -620,7 +620,7 @@ class DefaultValue(): NetWorkConfFile = "" distname, version, idnum = LinuxDistro.linux_distribution() distname = distname.lower() - if (distname in ("redhat", "centos", "euleros", "openeuler", "fusionos")): + if (distname in ("redhat", "centos", "euleros", "openeuler", "fusionos", "h3linux", "ningos")): NetWorkConfFile = "%s/ifcfg-%s" % (RedHatNetWorkConfPath, networkCardNum) else: @@ -629,7 +629,7 @@ class DefaultValue(): if (not os.path.exists(NetWorkConfFile)): if (distname in ( - "redhat", "centos", "euleros", "openeuler", "fusionos")): + "redhat", "centos", "euleros", "openeuler", "fusionos", "h3linux", "ningos")): cmd = "find %s -iname 'ifcfg-*-%s' -print" % ( RedHatNetWorkConfPath, networkCardNum) elif (distname == "debian" and version == "buster/sid"): @@ -815,7 +815,7 @@ class DefaultValue(): """ distname, version, _ = LinuxDistro.linux_distribution() if (distname.lower() in ("suse", "redhat", "centos", "euleros", - "openeuler", "fusionos")): + "openeuler", "fusionos", "h3linux", "ningos")): cmd = g_file.SHELL_CMD_DICT["checkPassword"] % (checkUser, "'^Last.*Change'") else: @@ -836,7 +836,7 @@ class DefaultValue(): if ("password must be changed" in result): raise Exception(ErrorCode.GAUSS_503["GAUSS_50307"]) if (distname.lower() in ("redhat", "centos", "euleros", - "openeuler", "fusionos")): + "openeuler", "fusionos", "h3linux", "ningos")): if ("password must be changed" in result): raise Exception(ErrorCode.GAUSS_503["GAUSS_50307"]) @@ -911,7 +911,7 @@ class DefaultValue(): return initSystemFile if (distname == "SuSE" and os.path.isfile(initFileSuse)): initFile = initFileSuse - elif (distname in ("redhat", "centos", "euleros", "openEuler", "FusionOS", "kylin") and + elif (distname in ("redhat", "centos", "euleros", "openEuler", "FusionOS", "kylin", "h3linux", "ningos") and os.path.isfile(initFileRedhat)): initFile = initFileRedhat elif (distname == "debian" and version == "buster/sid" and diff --git a/script/gspylib/inspection/common/SharedFuncs.py b/script/gspylib/inspection/common/SharedFuncs.py index c5e3768..396c940 100644 --- a/script/gspylib/inspection/common/SharedFuncs.py +++ b/script/gspylib/inspection/common/SharedFuncs.py @@ -634,7 +634,7 @@ def isSupportSystemOs(): output : NA """ osName = LinuxDistro.linux_distribution()[0] - if osName in ["redhat", "centos", "euleros", "openEuler", "FusionOS"]: + if osName in ["redhat", "centos", "euleros", "openEuler", "FusionOS", "H3Linux", "NingOS"]: return True else: return False diff --git a/script/gspylib/inspection/items/network/CheckBond.py b/script/gspylib/inspection/items/network/CheckBond.py index 1776411..4598094 100644 --- a/script/gspylib/inspection/items/network/CheckBond.py +++ b/script/gspylib/inspection/items/network/CheckBond.py @@ -68,7 +68,7 @@ class CheckBond(BaseItem): ifcfgFileRedhat = "/etc/sysconfig/network-scripts/ifcfg-%s" \ % networkCards distname, version, idnum = LinuxDistro.linux_distribution() - if (distname in ["redhat", "centos", "euleros", "openEuler", "FusionOS"]): + if (distname in ["redhat", "centos", "euleros", "openEuler", "FusionOS", "H3Linux", "NingOS"]): cmd = "echo BONDING_MODULE_OPTS='mode=%d " \ "miimon=100 use_carrier=0' >> %s " % (1, ifcfgFileRedhat) else: diff --git a/script/gspylib/inspection/items/os/CheckOSVer.py b/script/gspylib/inspection/items/os/CheckOSVer.py index 6e05135..aad4b79 100644 --- a/script/gspylib/inspection/items/os/CheckOSVer.py +++ b/script/gspylib/inspection/items/os/CheckOSVer.py @@ -54,6 +54,12 @@ class CheckOSVer(BaseItem): elif distName == "fusionos": self.result.rst = ResultStatus.OK self.result.val = "The current OS is FusionOS %s." % version + elif distName == "h3linux": + self.result.rst = ResultStatus.OK + self.result.val = "The current OS is H3Linux %s." % version + elif distName == "ningos": + self.result.rst = ResultStatus.OK + self.result.val = "The current OS is NingOS %s." % version else: self.result.rst = ResultStatus.NG self.result.val = "The current OS[%s %s] " \ @@ -73,7 +79,8 @@ class CheckOSVer(BaseItem): analysis = "" VerGroupDisk = {'RedHat6': [], 'RedHat7': [], 'Euler': [], 'SuSE11SP1': [], 'SuSE11SP234': [], 'SuSE12': [], - 'openEuler': [], 'FusionOS': []} + 'openEuler': [], 'FusionOS': [], 'H3Linux': [], + 'NingOS': []} for v in itemResult.getLocalItems(): analysis += "%s: %s\n" % (v.host, v.val) verInfo = v.val.strip().split(' ')[4:] @@ -89,6 +96,10 @@ class CheckOSVer(BaseItem): VerGroupDisk['openEuler'].append(verInfo) elif verInfo[0] == "FusionOS": VerGroupDisk['FusionOS'].append(verInfo) + elif verInfo[0] == "H3Linux": + VerGroupDisk['H3Linux'].append(verInfo) + elif verInfo[0] == "NingOS": + VerGroupDisk['NingOS'].append(verInfo) elif verInfo[0] == "SuSE": if verInfo[1] == "11.1": VerGroupDisk['SuSE11SP1'].append(verInfo) diff --git a/script/gspylib/os/gsplatform.py b/script/gspylib/os/gsplatform.py index b1a24f4..d1d9198 100644 --- a/script/gspylib/os/gsplatform.py +++ b/script/gspylib/os/gsplatform.py @@ -54,7 +54,7 @@ NET_IPV4 = "ipv4" _supported_dists = ( 'SuSE', 'debian', 'fedora', 'redhat', 'centos', 'euleros', "openEuler", 'mandrake', 'mandriva', 'rocks', 'slackware', 'yellowdog', 'gentoo', - 'FusionOS', 'UnitedLinux', 'turbolinux') + 'FusionOS', 'UnitedLinux', 'turbolinux', 'H3Linux', 'NingOS') _release_filename = re.compile(r'(\w+)[-_](release|version)') _lsb_release_version = re.compile(r'(.+)' ' release ' @@ -76,8 +76,10 @@ DEBIAN = "debian" UBUNTU = "ubuntu" UNIONTECH = "uniontech" UOS = "uos" +H3LINUX = "h3linux" +NINGOS = "ningos" SUPPORT_WHOLE_PLATFORM_LIST = [SUSE, REDHAT, CENTOS, EULEROS, FUSIONOS, - OPENEULER, KYLIN, ASIANUX, DEBIAN, UBUNTU, UOS, UNIONTECH] + OPENEULER, KYLIN, ASIANUX, DEBIAN, UBUNTU, UOS, UNIONTECH, H3LINUX, NINGOS] # 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"] @@ -115,11 +117,14 @@ PAK_SUSE = "SUSE" PAK_UNIONTECH = "UnionTech" PAK_KYLIN = "Kylin" PAK_UOS = "UOS" +PAK_H3LINUX = "H3Linux" +PAK_NINGOS = "NingOS" ####################################################### _supported_dists = ( 'SuSE', 'debian', 'fedora', 'redhat', 'centos', 'euleros', 'openEuler', 'mandrake', 'mandriva', 'rocks', 'slackware', 'yellowdog', 'gentoo', - 'FusionOS', 'UnitedLinux', 'turbolinux', 'kylin', 'asianux', 'ubuntu', 'uos', 'UnionTech') + 'FusionOS', 'UnitedLinux', 'turbolinux', 'kylin', 'asianux', 'ubuntu', 'uos', 'UnionTech', + 'H3Linux', 'NingOS') _release_filename = re.compile(r'(\w+)[-_](release|version)') _lsb_release_version = re.compile(r'(.+)' ' release ' @@ -1727,6 +1732,18 @@ class LinuxPlatform(GenericPlatform): prefixStr, packageVersion, PAK_FUSIONOS, BIT_VERSION, postfixStr)) + elif distname in H3LINUX: + fileName = os.path.join(dirName, "./../../../", + "%s-%s-%s-%s.%s" % ( + prefixStr, packageVersion, + PAK_H3LINUX, + BIT_VERSION, postfixStr)) + elif distname in NINGOS: + fileName = os.path.join(dirName, "./../../../", + "%s-%s-%s-%s.%s" % ( + prefixStr, packageVersion, + PAK_NINGOS, + BIT_VERSION, postfixStr)) elif distname in DEBIAN and (version == "buster/sid"): fileName = os.path.join(dirName, "./../../../", "%s-%s-%s-%s.%s" % ( @@ -2028,7 +2045,8 @@ class RHELPlatform(LinuxPlatform): (distName.lower() == CENTOS and version[0:3] == SUPPORT_EULEROS_VERSION_LIST and os.path.isfile(os.path.join("/etc", "euleros-release"))) or - (distName.lower() == OPENEULER) or (distName.lower() == FUSIONOS)): + (distName.lower() == OPENEULER) or (distName.lower() == FUSIONOS) or + (distName.lower() == H3LINUX) or (distName.lower() == NINGOS)): return True else: return False @@ -2158,6 +2176,8 @@ class RHELPlatform(LinuxPlatform): version[0:3] in SUPPORT_RHEL_SERIES_VERSION_LIST)) or (distName.lower() == OPENEULER) or (distName.lower() == FUSIONOS) or + (distName.lower() == H3LINUX) or + (distName.lower() == NINGOS) or (distName.lower() == DEBIAN and version == "buster/sid") )): return distName.lower(), version[0:3] diff --git a/script/local/LocalCheckOS.py b/script/local/LocalCheckOS.py index 7be9628..03041e3 100644 --- a/script/local/LocalCheckOS.py +++ b/script/local/LocalCheckOS.py @@ -664,7 +664,7 @@ def disRemoveIPC(): """ g_logger.debug("disbale RemoveIPC.") distName = g_Platform.getCurrentPlatForm()[0] - if distName.upper() in ("OPENEULER", "FUSIONOS", "KYLIN"): + if distName.upper() in ("OPENEULER", "FUSIONOS", "KYLIN", "H3LINUX", "NINGOS"): cmd = "setenforce 0" subprocess.getstatusoutput(cmd) initFile = "/usr/lib/systemd/system/systemd-logind.service" @@ -1436,7 +1436,7 @@ def collectfirewall(): """ data = firewall() distname = LinuxDistro.linux_distribution()[0] - if distname in ("redhat", "centos", "euleros", "openEuler", "FusionOS", "kylin"): + if distname in ("redhat", "centos", "euleros", "openEuler", "FusionOS", "kylin", "H3Linux", "NingOS"): data.distname = distname.upper() if g_Platform.isPlatFormEulerOSOrRHEL7X(): cmd = "systemctl status firewalld.service" @@ -1451,7 +1451,7 @@ def collectfirewall(): data.errormsg = output return data - if distname in ("redhat", "centos", "euleros", "openEuler", "FusionOS", "kylin"): + if distname in ("redhat", "centos", "euleros", "openEuler", "FusionOS", "kylin", "H3Linux", "NingOS"): if g_Platform.isPlatFormEulerOSOrRHEL7X(): if (output.strip()).find("Active: " "active (running)") > 0: @@ -1908,7 +1908,7 @@ def CheckPlatformInfo(): data.bits) g_logger.log("False %s %s" % (data.distname, platform_str)) return - elif (data.distname == "euleros" or data.distname == "openEuler" or data.distname == "FusionOS" or data.distname == "kylin" or data.distname == "uos"): + elif (data.distname == "euleros" or data.distname == "openEuler" or data.distname == "FusionOS" or data.distname == "kylin" or data.distname == "uos" or data.distname == "H3Linux" or data.distname == "NingOS"): mixed_type = "%s" % data.distname platform_str = "%s_%s_%s" % (data.distname, data.version, data.bits) elif (data.distname == "debian" or data.version == "buster/sid"): diff --git a/script/os_platform/common.py b/script/os_platform/common.py index c3b2c63..eb17b0d 100644 --- a/script/os_platform/common.py +++ b/script/os_platform/common.py @@ -33,8 +33,11 @@ DEBIAN = "debian" UBUNTU = "ubuntu" UNIONTECH = "uniontech" UOS = "uos" +H3LINUX = "h3linux" +NINGOS = "ningos" SUPPORT_WHOLE_PLATFORM_LIST = [SUSE, REDHAT, CENTOS, EULEROS, OPENEULER, KYLIN, - FUSIONOS, ASIANUX, DEBIAN, UBUNTU, UOS, UNIONTECH] + FUSIONOS, ASIANUX, DEBIAN, UBUNTU, UOS, UNIONTECH, + H3LINUX, NINGOS] # 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"] @@ -74,8 +77,11 @@ PAK_KYLIN = "Kylin" PAK_SUSE = "SUSE" PAK_DEBIAN = "Debian" PAK_UOS = "UOS" +PAK_H3LINUX = "H3Linux" +PAK_NINGOS = "NingOS" ####################################################### _supported_dists = ( 'SuSE', 'debian', 'fedora', 'redhat', 'centos', 'euleros', 'openEuler', 'mandrake', 'mandriva', 'rocks', 'slackware', 'yellowdog', 'gentoo', - 'FusionOS', 'UnitedLinux', 'turbolinux', 'ubuntu', 'kylin', 'asianux', 'uos', 'UnionTech') + 'FusionOS', 'UnitedLinux', 'turbolinux', 'ubuntu', 'kylin', 'asianux', 'uos', 'UnionTech', + 'H3Linux', 'NingOS') diff --git a/script/os_platform/linux_platform.py b/script/os_platform/linux_platform.py index 3608d48..7ee617b 100644 --- a/script/os_platform/linux_platform.py +++ b/script/os_platform/linux_platform.py @@ -28,7 +28,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, H3LINUX, PAK_H3LINUX, NINGOS, PAK_NINGOS from os_platform.linux_distro import LinuxDistro @@ -233,6 +233,18 @@ class LinuxPlatform(object): self.package_file_path(prefix_str, packageVersion, PAK_KYLIN, postfix_str), self.package_file_path(prefix_str, packageVersion, PAK_UOS, postfix_str) ] + + elif distname == H3LINUX: + file_name_list = [ + self.package_file_path(prefix_str, packageVersion, PAK_OPENEULER, postfix_str), + self.package_file_path(prefix_str, packageVersion, PAK_H3LINUX, postfix_str) + ] + + elif distname == NINGOS: + file_name_list = [ + self.package_file_path(prefix_str, packageVersion, PAK_OPENEULER, postfix_str), + self.package_file_path(prefix_str, packageVersion, PAK_NINGOS, postfix_str) + ] elif distname == DEBIAN: file_name_list = [ diff --git a/script/os_platform/rhel_platform.py b/script/os_platform/rhel_platform.py index 88ccbe4..3b7ca46 100644 --- a/script/os_platform/rhel_platform.py +++ b/script/os_platform/rhel_platform.py @@ -25,7 +25,7 @@ import platform from gspylib.common.ErrorCode import ErrorCode from os_platform.common import BIT_VERSION, EULEROS, SUPPORT_EULEROS_VERSION_LIST, \ FUSIONOS, SUPPORT_RHEL_SERIES_PLATFORM_LIST, \ - SUPPORT_RHEL_SERIES_VERSION_LIST, OPENEULER, CENTOS, \ + SUPPORT_RHEL_SERIES_VERSION_LIST, OPENEULER, CENTOS, H3LINUX, NINGOS, \ UOS, UNIONTECH, SUPPORT_UOS_VERSION_LIST, \ SUPPORT_RHEL7X_VERSION_LIST, DEBIAN, BLANK_SPACE from os_platform.linux_distro import LinuxDistro @@ -60,6 +60,8 @@ class RHELPlatform(LinuxPlatform): SUPPORT_EULEROS_VERSION_LIST and os.path.isfile(os.path.join("/etc", "euleros-release"))) or (dist_name.lower() == OPENEULER) or + (dist_name.lower() == H3LINUX) or + (dist_name.lower() == NINGOS) or (dist_name.lower() == FUSIONOS) ): return True @@ -171,6 +173,8 @@ class RHELPlatform(LinuxPlatform): (dist_name.lower() in SUPPORT_RHEL_SERIES_PLATFORM_LIST and version[0:3] in SUPPORT_RHEL_SERIES_VERSION_LIST)) or (dist_name.lower() == OPENEULER) or + (dist_name.lower() == H3LINUX) or + (dist_name.lower() == NINGOS) or (dist_name.lower() == FUSIONOS) or (dist_name.lower() == DEBIAN and version == "buster/sid") )):