From 3c6a24a3048b55f9cd422b0307b8f098f5e85d36 Mon Sep 17 00:00:00 2001 From: junhangis Date: Sat, 27 Aug 2022 10:55:55 +0800 Subject: [PATCH] add support for FusionOS platform --- build.sh | 6 ++++-- build/get_PlatForm_str.sh | 4 ++++ 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 +++++----- script/gspylib/inspection/common/SharedFuncs.py | 4 ++-- .../inspection/items/network/CheckBond.py | 2 +- .../gspylib/inspection/items/os/CheckOSVer.py | 7 ++++++- script/gspylib/os/gsplatform.py | 17 +++++++++++++---- script/local/LocalCheckOS.py | 8 ++++---- script/os_platform/common.py | 6 ++++-- script/os_platform/linux_platform.py | 8 +++++++- script/os_platform/rhel_platform.py | 7 +++++-- 14 files changed, 58 insertions(+), 27 deletions(-) diff --git a/build.sh b/build.sh index 70a760a..bf746d0 100644 --- a/build.sh +++ b/build.sh @@ -48,7 +48,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), CentOS platform." + echo "We only support openEuler(aarch64), EulerOS(aarch64), FusionOS, CentOS platform." exit 1; fi @@ -62,6 +62,8 @@ if [ X$(echo $PLAT_FORM_STR | grep "centos") != X"" ]; then dist_version="CentOS" elif [ X$(echo $PLAT_FORM_STR | grep "openeuler") != X"" ]; then dist_version="openEuler" +elif [ X$(echo $PLAT_FORM_STR | grep "fusionos") != X"" ]; then + dist_version="FusionOS" elif [ X$(echo $PLAT_FORM_STR | grep "euleros") != X"" ]; then dist_version="EulerOS" elif [ X$(echo $PLAT_FORM_STR | grep "ubuntu") != X"" ]; then @@ -69,7 +71,7 @@ elif [ X$(echo $PLAT_FORM_STR | grep "ubuntu") != X"" ]; then elif [ X$(echo $PLAT_FORM_STR | grep "asianux") != X"" ]; then dist_version="Asianux" else - echo "We only support openEuler(aarch64), EulerOS(aarch64), CentOS, Ubuntu(x86) platform." + echo "We only support openEuler(aarch64), EulerOS(aarch64), FusionOS, CentOS, Ubuntu(x86) platform." echo "Kernel is $kernel" exit 1 fi diff --git a/build/get_PlatForm_str.sh b/build/get_PlatForm_str.sh index addb16d..cf8c84f 100644 --- a/build/get_PlatForm_str.sh +++ b/build/get_PlatForm_str.sh @@ -27,6 +27,10 @@ function get_os_str() { os_str=openeuler_aarch64 elif [ "$os_name"x = "openEuler"x ] && [ "$cpu_arc"x = "x86_64"x ]; then os_str=openeuler_x86_64 + elif [ "$os_name"x = "fusionos"x ] && [ "$cpu_arc"x = "aarch64"x ]; then + os_str=fusionos_aarch64 + elif [ "$os_name"x = "fusionos"x ] && [ "$cpu_arc"x = "x86_64"x ]; then + os_str=fusionos_x86_64 elif [ "$os_name"x = "ubuntu"x ] && [ "$cpu_arc"x = "x86_64"x ]; then os_str=ubuntu18.04_x86_64 elif [ "$os_name"x = "asianux"x ] && [ "$cpu_arc"x = "x86_64"x ]; then diff --git a/script/base_diff/comm_constants.py b/script/base_diff/comm_constants.py index 30fc71b..7d442c0 100644 --- a/script/base_diff/comm_constants.py +++ b/script/base_diff/comm_constants.py @@ -28,4 +28,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") + DIST_NAME_TUPLE = ("redhat", "euleros", "centos", "openEuler", "FusionOS") diff --git a/script/domain_utils/cluster_os/os_file.py b/script/domain_utils/cluster_os/os_file.py index e67c595..b086c68 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") \ + elif distname in ("redhat", "centos", "euleros", "oracle", "openEuler", "FusionOS") \ 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 720cf87..0f1b6db 100644 --- a/script/gs_postuninstall +++ b/script/gs_postuninstall @@ -316,7 +316,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")): + if (distname in ("redhat", "euleros", "centos", "openEuler", "FusionOS")): 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 0e9da07..bfa4509 100644 --- a/script/gspylib/common/Common.py +++ b/script/gspylib/common/Common.py @@ -592,7 +592,7 @@ class DefaultValue(): NetWorkConfFile = "" distname, version, idnum = LinuxDistro.linux_distribution() distname = distname.lower() - if (distname in ("redhat", "centos", "euleros", "openEuler")): + if (distname in ("redhat", "centos", "euleros", "openEuler", "fusionos")): NetWorkConfFile = "%s/ifcfg-%s" % (RedHatNetWorkConfPath, networkCardNum) else: @@ -601,7 +601,7 @@ class DefaultValue(): if (not os.path.exists(NetWorkConfFile)): if (distname in ( - "redhat", "centos", "euleros", "openeuler")): + "redhat", "centos", "euleros", "openeuler", "fusionos")): cmd = "find %s -iname 'ifcfg-*-%s' -print" % ( RedHatNetWorkConfPath, networkCardNum) elif (distname == "debian" and version == "buster/sid"): @@ -784,7 +784,7 @@ class DefaultValue(): """ distname, version, _ = LinuxDistro.linux_distribution() if (distname.lower() in ("suse", "redhat", "centos", "euleros", - "openeuler")): + "openeuler", "fusionos")): cmd = g_file.SHELL_CMD_DICT["checkPassword"] % (checkUser, "'^Last.*Change'") else: @@ -805,7 +805,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")): + "openeuler", "fusionos")): if ("password must be changed" in result): raise Exception(ErrorCode.GAUSS_503["GAUSS_50307"]) @@ -881,7 +881,7 @@ class DefaultValue(): return initSystemFile if (distname == "SuSE" and os.path.isfile(initFileSuse)): initFile = initFileSuse - elif (distname in ("redhat", "centos", "euleros", "openEuler") and + elif (distname in ("redhat", "centos", "euleros", "openEuler", "FusionOS") 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 18d7a7a..971300e 100644 --- a/script/gspylib/inspection/common/SharedFuncs.py +++ b/script/gspylib/inspection/common/SharedFuncs.py @@ -631,7 +631,7 @@ def isSupportSystemOs(): output : NA """ osName = LinuxDistro.linux_distribution()[0] - if osName in ["redhat", "centos", "euleros", "openEuler"]: + if osName in ["redhat", "centos", "euleros", "openEuler", "FusionOS"]: return True else: return False @@ -809,7 +809,7 @@ def getOSInitFile(): if (distname == "SuSE" and os.path.isfile(initFileSuse)): initFile = initFileSuse elif (distname in ( - "redhat", "centos", "euleros", "openEuler") and os.path.isfile( + "redhat", "centos", "euleros", "openEuler", "FusionOS") and os.path.isfile( initFileRedhat)): initFile = initFileRedhat else: diff --git a/script/gspylib/inspection/items/network/CheckBond.py b/script/gspylib/inspection/items/network/CheckBond.py index 4a5f537..b9ec7b2 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"]): + if (distname in ["redhat", "centos", "euleros", "openEuler", "FusionOS"]): 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 58e9f4a..6e05135 100644 --- a/script/gspylib/inspection/items/os/CheckOSVer.py +++ b/script/gspylib/inspection/items/os/CheckOSVer.py @@ -51,6 +51,9 @@ class CheckOSVer(BaseItem): elif distName == "openeuler": self.result.rst = ResultStatus.OK self.result.val = "The current OS is openEuler %s." % version + elif distName == "fusionos": + self.result.rst = ResultStatus.OK + self.result.val = "The current OS is FusionOS %s." % version else: self.result.rst = ResultStatus.NG self.result.val = "The current OS[%s %s] " \ @@ -70,7 +73,7 @@ class CheckOSVer(BaseItem): analysis = "" VerGroupDisk = {'RedHat6': [], 'RedHat7': [], 'Euler': [], 'SuSE11SP1': [], 'SuSE11SP234': [], 'SuSE12': [], - 'openEuler': []} + 'openEuler': [], 'FusionOS': []} for v in itemResult.getLocalItems(): analysis += "%s: %s\n" % (v.host, v.val) verInfo = v.val.strip().split(' ')[4:] @@ -84,6 +87,8 @@ class CheckOSVer(BaseItem): VerGroupDisk['Euler'].append(verInfo) elif verInfo[0] == "openEuler": VerGroupDisk['openEuler'].append(verInfo) + elif verInfo[0] == "FusionOS": + VerGroupDisk['FusionOS'].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 78ea384..d379af0 100644 --- a/script/gspylib/os/gsplatform.py +++ b/script/gspylib/os/gsplatform.py @@ -47,7 +47,7 @@ from netifaces import interfaces, ifaddresses, AF_INET, AF_INET6 _supported_dists = ( 'SuSE', 'debian', 'fedora', 'redhat', 'centos', 'euleros', "openEuler", 'mandrake', 'mandriva', 'rocks', 'slackware', 'yellowdog', 'gentoo', - 'UnitedLinux', 'turbolinux') + 'FusionOS', 'UnitedLinux', 'turbolinux') _release_filename = re.compile(r'(\w+)[-_](release|version)') _lsb_release_version = re.compile(r'(.+)' ' release ' @@ -61,12 +61,13 @@ SUSE = "suse" REDHAT = "redhat" CENTOS = "centos" EULEROS = "euleros" +FUSIONOS = "fusionos" KYLIN = "kylin" OPENEULER = "openeuler" ASIANUX = "asianux" DEBIAN = "debian" UBUNTU = "ubuntu" -SUPPORT_WHOLE_PLATFORM_LIST = [SUSE, REDHAT, CENTOS, EULEROS, +SUPPORT_WHOLE_PLATFORM_LIST = [SUSE, REDHAT, CENTOS, EULEROS, FUSIONOS, OPENEULER, KYLIN, ASIANUX, DEBIAN, UBUNTU] # RedhatX platform SUPPORT_RHEL_SERIES_PLATFORM_LIST = [REDHAT, CENTOS, "kylin", "asianux"] @@ -96,6 +97,7 @@ COLON = ":" PAK_CENTOS = "CentOS" PAK_EULER = "Euler" PAK_OPENEULER = "openEuler" +PAK_FUSIONOS = "FusionOS" PAK_REDHAT = "RedHat" PAK_ASIANUX = "Asianux" PAK_UBUNTU = "Ubuntu" @@ -105,7 +107,7 @@ PAK_SUSE = "SUSE" _supported_dists = ( 'SuSE', 'debian', 'fedora', 'redhat', 'centos', 'euleros', "openEuler", 'mandrake', 'mandriva', 'rocks', 'slackware', 'yellowdog', 'gentoo', - 'UnitedLinux', 'turbolinux', 'kylin', 'asianux', 'ubuntu') + 'FusionOS', 'UnitedLinux', 'turbolinux', 'kylin', 'asianux', 'ubuntu') _release_filename = re.compile(r'(\w+)[-_](release|version)') _lsb_release_version = re.compile(r'(.+)' ' release ' @@ -1537,6 +1539,12 @@ class LinuxPlatform(GenericPlatform): prefixStr, packageVersion, PAK_OPENEULER, BIT_VERSION, postfixStr)) + elif distname in FUSIONOS: + fileName = os.path.join(dirName, "./../../../", + "%s-%s-%s-%s.%s" % ( + prefixStr, packageVersion, + PAK_FUSIONOS, + BIT_VERSION, postfixStr)) elif distname in DEBIAN and (version == "buster/sid"): fileName = os.path.join(dirName, "./../../../", "%s-%s-%s-%s.%s" % ( @@ -1782,7 +1790,7 @@ 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): + (distName.lower() == OPENEULER) or (distName.lower() == FUSIONOS)): return True else: return False @@ -1911,6 +1919,7 @@ class RHELPlatform(LinuxPlatform): (distName.lower() in SUPPORT_RHEL_SERIES_PLATFORM_LIST and 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") )): return distName.lower(), version[0:3] diff --git a/script/local/LocalCheckOS.py b/script/local/LocalCheckOS.py index 210e784..f66375b 100644 --- a/script/local/LocalCheckOS.py +++ b/script/local/LocalCheckOS.py @@ -661,7 +661,7 @@ def disRemoveIPC(): """ g_logger.debug("disbale RemoveIPC.") distName = g_Platform.getCurrentPlatForm()[0] - if distName.upper() in ("OPENEULER", "KYLIN"): + if distName.upper() in ("OPENEULER", "FUSIONOS", "KYLIN"): cmd = "setenforce 0" subprocess.getstatusoutput(cmd) initFile = "/usr/lib/systemd/system/systemd-logind.service" @@ -1391,7 +1391,7 @@ def collectfirewall(): """ data = firewall() distname = LinuxDistro.linux_distribution()[0] - if distname in ("redhat", "centos", "euleros", "openEuler"): + if distname in ("redhat", "centos", "euleros", "openEuler", "FusionOS"): data.distname = distname.upper() if g_Platform.isPlatFormEulerOSOrRHEL7X(): cmd = "systemctl status firewalld.service" @@ -1406,7 +1406,7 @@ def collectfirewall(): data.errormsg = output return data - if distname in ("redhat", "centos", "euleros", "openEuler"): + if distname in ("redhat", "centos", "euleros", "openEuler", "FusionOS"): if g_Platform.isPlatFormEulerOSOrRHEL7X(): if (output.strip()).find("Active: " "active (running)") > 0: @@ -1791,7 +1791,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 == "kylin"): + elif (data.distname == "euleros" or data.distname == "openEuler" or data.distname == "FusionOS" or data.distname == "kylin"): 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 ec7850e..143c82c 100644 --- a/script/os_platform/common.py +++ b/script/os_platform/common.py @@ -27,11 +27,12 @@ CENTOS = "centos" EULEROS = "euleros" KYLIN = "kylin" OPENEULER = "openeuler" +FUSIONOS = "fusionos" ASIANUX = "asianux" DEBIAN = "debian" UBUNTU = "ubuntu" SUPPORT_WHOLE_PLATFORM_LIST = [SUSE, REDHAT, CENTOS, EULEROS, OPENEULER, KYLIN, - ASIANUX, DEBIAN, UBUNTU] + FUSIONOS, ASIANUX, DEBIAN, UBUNTU] # 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"] @@ -60,6 +61,7 @@ COLON = ":" PAK_CENTOS = "CentOS" PAK_EULER = "Euler" PAK_OPENEULER = "openEuler" +PAK_FUSIONOS = "FusionOS" PAK_REDHAT = "RedHat" PAK_ASIANUX = "Asianux" PAK_UBUNTU = "Ubuntu" @@ -71,4 +73,4 @@ PAK_DEBIAN = "Debian" _supported_dists = ( 'SuSE', 'debian', 'fedora', 'redhat', 'centos', 'euleros', "openEuler", 'mandrake', 'mandriva', 'rocks', 'slackware', 'yellowdog', 'gentoo', - 'UnitedLinux', 'turbolinux', 'ubuntu', 'kylin', 'asianux') + "FusionOS", 'UnitedLinux', 'turbolinux', 'ubuntu', 'kylin', 'asianux') diff --git a/script/os_platform/linux_platform.py b/script/os_platform/linux_platform.py index 60696c2..1f21d23 100644 --- a/script/os_platform/linux_platform.py +++ b/script/os_platform/linux_platform.py @@ -25,7 +25,8 @@ from gspylib.common.ErrorCode import ErrorCode from os_platform.common import REDHAT, PAK_REDHAT, BIT_VERSION, \ CENTOS, 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_SUSE, PAK_DEBIAN + BLANK_SPACE, PAK_UBUNTU, DEBIAN, PAK_KYLIN, PAK_SUSE, PAK_DEBIAN, \ + FUSIONOS, PAK_FUSIONOS from os_platform.linux_distro import LinuxDistro @@ -224,6 +225,11 @@ class LinuxPlatform(object): self.package_file_path(prefix_str, packageVersion, PAK_OPENEULER, postfix_str) ] + elif distname == FUSIONOS: + file_name_list = [ + self.package_file_path(prefix_str, packageVersion, PAK_FUSIONOS, 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 483ae93..d21ffbd 100644 --- a/script/os_platform/rhel_platform.py +++ b/script/os_platform/rhel_platform.py @@ -24,7 +24,7 @@ import os import platform from gspylib.common.ErrorCode import ErrorCode from os_platform.common import BIT_VERSION, EULEROS, SUPPORT_EULEROS_VERSION_LIST, \ - SUPPORT_RHEL_SERIES_PLATFORM_LIST, \ + FUSIONOS, SUPPORT_RHEL_SERIES_PLATFORM_LIST, \ SUPPORT_RHEL_SERIES_VERSION_LIST, OPENEULER, CENTOS, \ SUPPORT_RHEL7X_VERSION_LIST, DEBIAN, BLANK_SPACE from os_platform.linux_distro import LinuxDistro @@ -58,7 +58,9 @@ class RHELPlatform(LinuxPlatform): (dist_name.lower() == CENTOS and version[0:3] == SUPPORT_EULEROS_VERSION_LIST and os.path.isfile(os.path.join("/etc", "euleros-release"))) or - dist_name.lower() == OPENEULER): + (dist_name.lower() == OPENEULER) or + (dist_name.lower() == FUSIONOS) + ): return True return False @@ -168,6 +170,7 @@ 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() == FUSIONOS) or (dist_name.lower() == DEBIAN and version == "buster/sid") )): return dist_name.lower(), version[0:3]