diff -crN script/gspylib/common/Common.py script_adapt/gspylib/common/Common.py *** script/gspylib/common/Common.py 2024-09-29 18:57:52.000000000 +0800 --- script_adapt/gspylib/common/Common.py 2024-12-21 09:33:24.000000000 +0800 *************** *** 39,44 **** --- 39,45 ---- from subprocess import PIPE from subprocess import Popen from base_utils.os.password_util import PasswordUtil + from os_platform.common import DEBIAN, UBUNTU # The installation starts, but the package is not decompressed completely. # The lib64/libz.so.1 file is incomplete, and the hashlib depends on the *************** *** 632,638 **** "redhat", "centos", "euleros", "openeuler", "fusionos", "h3linux", "ningos")): cmd = "find %s -iname 'ifcfg-*-%s' -print" % ( RedHatNetWorkConfPath, networkCardNum) ! elif (distname == "debian" and version == "buster/sid"): cmd = "find %s -iname 'ifcfg-*-%s' -print" % ( UbuntuNetWorkConfPath, networkCardNum) else: --- 633,639 ---- "redhat", "centos", "euleros", "openeuler", "fusionos", "h3linux", "ningos")): cmd = "find %s -iname 'ifcfg-*-%s' -print" % ( RedHatNetWorkConfPath, networkCardNum) ! elif (distname == "debian"): cmd = "find %s -iname 'ifcfg-*-%s' -print" % ( UbuntuNetWorkConfPath, networkCardNum) else: *************** *** 731,738 **** hostIp = info[NetUtil.ADDRESS_FAMILY_INDEX][NetUtil.IP_ADDRESS_INDEX] # due to two loopback address in ubuntu, 127.0.1.1 are choosed by hostname. # there is need to choose 127.0.0.1 version = LinuxDistro.linux_distribution()[1].split('/')[0] ! if version == "buster" and hostIp == "127.0.1.1": hostIp = "127.0.0.1" return hostIp --- 732,740 ---- hostIp = info[NetUtil.ADDRESS_FAMILY_INDEX][NetUtil.IP_ADDRESS_INDEX] # due to two loopback address in ubuntu, 127.0.1.1 are choosed by hostname. # there is need to choose 127.0.0.1 + distname, version, idnum = LinuxDistro.linux_distribution() version = LinuxDistro.linux_distribution()[1].split('/')[0] ! if distname in (UBUNTU, DEBIAN) and hostIp == "127.0.1.1": hostIp = "127.0.0.1" return hostIp *************** *** 914,920 **** 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 os.path.isfile(initFileUbuntu)): initFile = initFileUbuntu else: --- 916,922 ---- elif (distname in ("redhat", "centos", "euleros", "openEuler", "FusionOS", "kylin", "h3linux", "ningos") and os.path.isfile(initFileRedhat)): initFile = initFileRedhat ! elif (distname == "debian" and os.path.isfile(initFileUbuntu)): initFile = initFileUbuntu else: *************** *** 1885,1890 **** --- 1887,1928 ---- hostname) except Exception as e: raise Exception(str(e)) + + @staticmethod + def distribute_hosts_file(g_sshTool, hosts_file, hostname=None, + mpprc_file="", local_mode=False): + ''' + function: distribute the hosts file to remote nodes + input: g_sshTool, hostname, hosts file, mpprcFile + output:NA + ''' + if hostname is None: + hostname = [] + try: + # distribute xml file + # check and create xml file path + hosts_dir = os.path.dirname(hosts_file) + hosts_dir = os.path.normpath(hosts_dir) + LocalRemoteCmd.checkRemoteDir(g_sshTool, hosts_dir, hostname, mpprc_file, + local_mode) + local_node = NetUtil.GetHostIpOrName() + # Skip local file overwriting + if not hostname: + hostname = g_sshTool.hostNames[:] + if local_node in hostname: + hostname.remove(local_node) + if (not local_mode): + # Send xml file to every host + g_sshTool.scpFiles(hosts_file, hosts_dir, hostname, mpprc_file) + # change owner and mode of xml file + cmd = CmdUtil.getChmodCmd(str(DefaultValue.FILE_MODE), hosts_file) + CmdExecutor.execCommandWithMode(cmd, + g_sshTool, + local_mode, + mpprc_file, + hostname) + except Exception as e: + raise Exception(str(e)) @staticmethod def getSecurityMode(): diff -crN script/gspylib/os/gsplatform.py script_adapt/gspylib/os/gsplatform.py *** script/gspylib/os/gsplatform.py 2024-09-29 18:57:52.000000000 +0800 --- script_adapt/gspylib/os/gsplatform.py 2024-12-20 20:30:57.000000000 +0800 *************** *** 2104,2110 **** if self.isSupportSystemctl(): return self.getSystemctlCmd("crond.service", action) ! elif distname == "debian" and version == "buster/sid": return self.getServiceCmd("cron", action) else: return self.getServiceCmd("crond", action) --- 2104,2110 ---- if self.isSupportSystemctl(): return self.getSystemctlCmd("crond.service", action) ! elif distname == "debian": return self.getServiceCmd("cron", action) else: return self.getServiceCmd("crond", action) *************** *** 2178,2184 **** (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] else: --- 2178,2184 ---- (distName.lower() == FUSIONOS) or (distName.lower() == H3LINUX) or (distName.lower() == NINGOS) or ! (distName.lower() == DEBIAN) )): return distName.lower(), version[0:3] else: diff -crN script/gs_uninstall script_adapt/gs_uninstall *** script/gs_uninstall 2024-09-29 18:57:52.000000000 +0800 --- script_adapt/gs_uninstall 2024-12-21 09:53:02.000000000 +0800 *************** *** 57,62 **** --- 57,63 ---- ParallelBaseOM.__init__(self) self.cleanInstance = False self.clearDisk = False + self.isSingle = False def usage(self): """ *************** *** 138,143 **** --- 139,146 ---- # Initialize the self.sshTool variable self.initSshTool(self.clusterInfo.getClusterNodeNames(), DefaultValue.TIMEOUT_PSSH_UNINSTALL) + if len(self.clusterInfo.getClusterNodeNames()) == 1: + self.isSingle = True except Exception as e: self.logger.logExit(str(e)) diff -crN script/impl/preinstall/PreinstallImpl.py script_adapt/impl/preinstall/PreinstallImpl.py *** script/impl/preinstall/PreinstallImpl.py 2024-09-29 18:57:52.000000000 +0800 --- script_adapt/impl/preinstall/PreinstallImpl.py 2024-12-20 20:27:47.000000000 +0800 *************** *** 430,436 **** "Successfully distribute package to package path.") break # 3.distribute xml file ! DefaultValue.distributeXmlConfFile(self.context.sshTool, self.context.xmlFile, hosts, self.context.mpprcFile) cmd = "%s -t %s -u %s -X %s" % (OMCommand.getLocalScript("Local_PreInstall"), --- 430,436 ---- "Successfully distribute package to package path.") break # 3.distribute xml file ! DefaultValue.distribute_hosts_file(self.context.sshTool, self.context.xmlFile, hosts, self.context.mpprcFile) cmd = "%s -t %s -u %s -X %s" % (OMCommand.getLocalScript("Local_PreInstall"), *************** *** 445,451 **** # 4.distribute hosts file hosts_file = os.path.normpath(os.path.join(self.context.clusterToolPath, "hosts")) ! DefaultValue.distributeXmlConfFile(self.context.sshTool, hosts_file, hosts, self.context.mpprcFile) except Exception as e: --- 445,451 ---- # 4.distribute hosts file hosts_file = os.path.normpath(os.path.join(self.context.clusterToolPath, "hosts")) ! DefaultValue.distribute_hosts_file(self.context.sshTool, hosts_file, hosts, self.context.mpprcFile) except Exception as e: *************** *** 660,666 **** os.path.isfile(self.context.mpprcFile) and self.context.clusterInfo.enable_dss == 'on'): CmdExecutor.execCommandWithMode(cmd, self.context.sshTool, ! self.context.localMode) self.context.logger.debug("Command for change env: %s" % cmd) except Exception as e: raise Exception(str(e)) --- 660,666 ---- os.path.isfile(self.context.mpprcFile) and self.context.clusterInfo.enable_dss == 'on'): CmdExecutor.execCommandWithMode(cmd, self.context.sshTool, ! self.context.localMode or self.context.isSingle) self.context.logger.debug("Command for change env: %s" % cmd) except Exception as e: raise Exception(str(e)) diff -crN script/impl/uninstall/UninstallImpl.py script_adapt/impl/uninstall/UninstallImpl.py *** script/impl/uninstall/UninstallImpl.py 2024-09-29 18:57:52.000000000 +0800 --- script_adapt/impl/uninstall/UninstallImpl.py 2024-12-21 15:02:26.000000000 +0800 *************** *** 56,61 **** --- 56,62 ---- self.localMode = unstallation.localMode self.logger = unstallation.logger self.sshTool = unstallation.sshTool + self.isSingle = unstallation.isSingle self.tmpDir = EnvUtil.getTmpDirFromEnv(self.user) try: # Initialize the unstallation.clusterInfo variable *************** *** 112,118 **** cmd += " -d" self.logger.debug("Command for checking uninstallation: " + cmd) CmdExecutor.execCommandWithMode(cmd, ! self.sshTool, self.localMode, self.mpprcFile) self.logger.log("Successfully checked uninstallation.", "constant") --- 113,119 ---- cmd += " -d" self.logger.debug("Command for checking uninstallation: " + cmd) CmdExecutor.execCommandWithMode(cmd, ! self.sshTool, self.localMode or self.isSingle, self.mpprcFile) self.logger.log("Successfully checked uninstallation.", "constant") *************** *** 192,198 **** self.user, self.clusterInfo.appPath, self.localLog) self.logger.debug("Command for stop cluster: %s" % cmd) CmdExecutor.execCommandWithMode(cmd, self.sshTool, ! self.localMode, self.mpprcFile) self.logger.log("Successfully stopped the cluster.") else: self.cm_stop_cluster() --- 193,199 ---- self.user, self.clusterInfo.appPath, self.localLog) self.logger.debug("Command for stop cluster: %s" % cmd) CmdExecutor.execCommandWithMode(cmd, self.sshTool, ! self.localMode or self.isSingle, self.mpprcFile) self.logger.log("Successfully stopped the cluster.") else: self.cm_stop_cluster() *************** *** 250,256 **** self.localLog) self.logger.debug("Command for deleting instance: %s" % cmd) CmdExecutor.execCommandWithMode(cmd, ! self.sshTool, self.localMode, self.mpprcFile) # clean upgrade temp backup path --- 251,257 ---- self.localLog) self.logger.debug("Command for deleting instance: %s" % cmd) CmdExecutor.execCommandWithMode(cmd, ! self.sshTool, self.localMode or self.isSingle, self.mpprcFile) # clean upgrade temp backup path *************** *** 258,264 **** cmd = g_file.SHELL_CMD_DICT["cleanDir"] % ( upgrade_bak_dir, upgrade_bak_dir, upgrade_bak_dir) CmdExecutor.execCommandWithMode(cmd, ! self.sshTool, self.localMode, self.mpprcFile) self.logger.log("Successfully deleted instances.", "constant") --- 259,265 ---- cmd = g_file.SHELL_CMD_DICT["cleanDir"] % ( upgrade_bak_dir, upgrade_bak_dir, upgrade_bak_dir) CmdExecutor.execCommandWithMode(cmd, ! self.sshTool, self.localMode or self.isSingle, self.mpprcFile) self.logger.log("Successfully deleted instances.", "constant") *************** *** 285,298 **** copyPath, copyPath, appPath) CmdExecutor.execCommandWithMode( copyCmd, ! self.sshTool, self.localMode, self.mpprcFile) cmd = g_file.SHELL_CMD_DICT["cleanDir"] % ( self.tmpDir, self.tmpDir, self.tmpDir) # clean dir of PGHOST CmdExecutor.execCommandWithMode(cmd, ! self.sshTool, self.localMode, self.mpprcFile) except Exception as e: self.logger.logExit(str(e)) --- 286,299 ---- copyPath, copyPath, appPath) CmdExecutor.execCommandWithMode( copyCmd, ! self.sshTool, self.localMode or self.isSingle, self.mpprcFile) cmd = g_file.SHELL_CMD_DICT["cleanDir"] % ( self.tmpDir, self.tmpDir, self.tmpDir) # clean dir of PGHOST CmdExecutor.execCommandWithMode(cmd, ! self.sshTool, self.localMode or self.isSingle, self.mpprcFile) except Exception as e: self.logger.logExit(str(e)) *************** *** 312,318 **** self.logger.debug("Command for Uninstalling: %s" % cmd) # clean application CmdExecutor.execCommandWithMode(cmd, ! self.sshTool, self.localMode, self.mpprcFile) self.logger.log("Successfully uninstalled application.", "constant") --- 313,319 ---- self.logger.debug("Command for Uninstalling: %s" % cmd) # clean application CmdExecutor.execCommandWithMode(cmd, ! self.sshTool, self.localMode or self.isSingle, self.mpprcFile) self.logger.log("Successfully uninstalled application.", "constant") *************** *** 328,334 **** # delete bin dir in GAUSSHOME CmdExecutor.execCommandWithMode( cmd, ! self.sshTool, self.localMode, self.mpprcFile) except Exception as e: self.logger.exitWithError(str(e)) --- 329,335 ---- # delete bin dir in GAUSSHOME CmdExecutor.execCommandWithMode( cmd, ! self.sshTool, self.localMode or self.isSingle, self.mpprcFile) except Exception as e: self.logger.exitWithError(str(e)) *************** *** 349,355 **** if os.path.isfile(rack_conf_file): cmd = "rm -f %s" % rack_conf_file CmdExecutor.execCommandWithMode(cmd, ! self.sshTool, self.localMode, mpprc_file=self.mpprcFile) self.logger.debug("Successfully deleted rack information file.") --- 350,356 ---- if os.path.isfile(rack_conf_file): cmd = "rm -f %s" % rack_conf_file CmdExecutor.execCommandWithMode(cmd, ! self.sshTool, self.localMode or self.isSingle, mpprc_file=self.mpprcFile) self.logger.debug("Successfully deleted rack information file.") *************** *** 372,378 **** dss_home, dss_home, dss_home) # delete log dir CmdExecutor.execCommandWithMode(cmd, ! self.sshTool, self.localMode, self.mpprcFile) except Exception as e: self.logger.exitWithError(str(e)) --- 373,379 ---- dss_home, dss_home, dss_home) # delete log dir CmdExecutor.execCommandWithMode(cmd, ! self.sshTool, self.localMode or self.isSingle, self.mpprcFile) except Exception as e: self.logger.exitWithError(str(e)) *************** *** 398,404 **** userLogDir, userLogDir, userLogDir) # delete log dir CmdExecutor.execCommandWithMode(cmd, ! self.sshTool, self.localMode, self.mpprcFile) except Exception as e: self.logger.exitWithError(str(e)) --- 399,405 ---- userLogDir, userLogDir, userLogDir) # delete log dir CmdExecutor.execCommandWithMode(cmd, ! self.sshTool, self.localMode or self.isSingle, self.mpprcFile) except Exception as e: self.logger.exitWithError(str(e)) diff -crN script/local/LocalCheckOS.py script_adapt/local/LocalCheckOS.py *** script/local/LocalCheckOS.py 2024-09-29 18:57:52.000000000 +0800 --- script_adapt/local/LocalCheckOS.py 2024-12-20 20:30:57.000000000 +0800 *************** *** 1506,1517 **** stderr=subprocess.PIPE) result = p.communicate() - if p.returncode != 0: # No ntpd process found - p = subprocess.Popen(["pgrep", "chronyd"], shell=False, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - result = p.communicate() - if data.errormsg: data.errormsg = "%s\n%s" % (data.errormsg, result[1].strip()) else: --- 1506,1511 ---- *************** *** 1678,1684 **** # The IO Schedulers in ubuntu system is default value, # so that it cannot be modified distname, version = LinuxDistro.linux_distribution()[0:2] ! if distname == "debian" and version == "buster/sid": return data = collectIOschedulers() for dev in list(data.devices.keys()): --- 1672,1678 ---- # The IO Schedulers in ubuntu system is default value, # so that it cannot be modified distname, version = LinuxDistro.linux_distribution()[0:2] ! if distname == "debian": return data = collectIOschedulers() for dev in list(data.devices.keys()): diff -crN script/local/PreInstallUtility.py script_adapt/local/PreInstallUtility.py *** script/local/PreInstallUtility.py 2024-09-29 18:57:52.000000000 +0800 --- script_adapt/local/PreInstallUtility.py 2024-12-21 14:57:11.000000000 +0800 *************** *** 63,68 **** --- 63,69 ---- from base_utils.os.user_util import UserUtil from gspylib.component.DSS.dss_comp import DssInitCfg, Dss, UdevContext from gspylib.component.DSS.dss_checker import DssConfig + from os_platform.common import DEBIAN, UBUNTU ACTION_PREPARE_PATH = "prepare_path" ACTION_CHECK_OS_VERSION = "check_os_Version" *************** *** 655,663 **** if not self.mpprcFile: self.mpprcFile = ProfileFile.get_user_bashrc(self.user) retry = 1 ! node = self.clusterInfo.getDbNodeByName(node_name) ! node_ip = node.sshIps[0] ! cmd = "source %s;pssh -s -H %s hostname" % (self.mpprcFile, node_ip) while True: (status, output) = subprocess.getstatusoutput(cmd) self.logger.debug("Checking hostname mapping for node [%s]. output: %s" % (node_name, output)) --- 656,662 ---- if not self.mpprcFile: self.mpprcFile = ProfileFile.get_user_bashrc(self.user) retry = 1 ! cmd = "source %s;pssh -s -H %s hostname" % (self.mpprcFile, node_name) while True: (status, output) = subprocess.getstatusoutput(cmd) self.logger.debug("Checking hostname mapping for node [%s]. output: %s" % (node_name, output)) *************** *** 670,676 **** retry += 1 time.sleep(1) ! hostname_cmd = "source %s;pssh -s -H %s 'cat /etc/hostname'" % (self.mpprcFile, node_ip) (status, output) = subprocess.getstatusoutput(hostname_cmd) if status == 0 and output.strip() == node_name: pass --- 669,675 ---- retry += 1 time.sleep(1) ! hostname_cmd = "pssh -s -H %s 'cat /etc/hostname'" % (node_name) (status, output) = subprocess.getstatusoutput(hostname_cmd) if status == 0 and output.strip() == node_name: pass *************** *** 1282,1299 **** + " Command:%s. Error:\n%s" % ( cmd, output)) - bin_crontab = "/bin/crontab" - if os.path.exists(bin_crontab): - FileUtil.changeOwner("root", bin_crontab) - FileUtil.changeMode(DefaultValue.MAX_DIRECTORY_MODE, bin_crontab) - cmd = "chmod u+s '%s'" % bin_crontab - (status, output) = subprocess.getstatusoutput(cmd) - if status != 0: - self.logger.logExit(ErrorCode.GAUSS_501[ - "GAUSS_50107"] % bin_crontab - + " Command:%s. Error:\n%s" % ( - cmd, output)) - ##2.make sure user have permission to use cron cron_allow_file = "/etc/cron.allow" if not os.path.isfile(cron_allow_file): --- 1281,1286 ---- *************** *** 1670,1677 **** FileUtil.deleteLine(userProfile, "^\\s*export\\s*PGDATA*") # clean PGPORT FileUtil.deleteLine(userProfile, "^\\s*export\\s*PGPORT*") - # clean IP_TYPE - FileUtil.deleteLine(userProfile, "^\\s*export\\s*IP_TYPE*") # clean PGDATABASE FileUtil.deleteLine(userProfile, "^\\s*export\\s*PGDATABASE*") # clean LD_LIBRARY_PATH --- 1657,1662 ---- *************** *** 1693,1699 **** "^\\s*export\\s*PATH=\\$PATH:\\$GPHOME\\/script\\/gspylib\\" "/pssh\\/bin:\\$GPHOME\\/script$") FileUtil.deleteLine(userProfile, ! "^\\s*export\\s*PATH=\\$PATH:\\/home\\/%s\\/gauss_om\\" "/script$" % self.user) FileUtil.deleteLine(userProfile, "^\\s*export\\s*PATH=\\$GPHOME\\/pssh-2.3.1\\/bin:" --- 1678,1684 ---- "^\\s*export\\s*PATH=\\$PATH:\\$GPHOME\\/script\\/gspylib\\" "/pssh\\/bin:\\$GPHOME\\/script$") FileUtil.deleteLine(userProfile, ! "^\\s*export\\s*PATH=\\$PATH:\\/root\\/gauss_om\\/%s\\" "/script$" % self.user) FileUtil.deleteLine(userProfile, "^\\s*export\\s*PATH=\\$GPHOME\\/pssh-2.3.1\\/bin:" *************** *** 1702,1708 **** "^\\s*export\\s*PATH=\\$GPHOME\\/script\\/gspylib\\" "/pssh\\/bin:\\$GPHOME\\/script:\\$PATH$") FileUtil.deleteLine(userProfile, ! "^\\s*export\\s*PATH=\\/home\\/%s\\/gauss_om\\" "/script:\\$PATH$" % self.user) self.logger.debug("Deleting crash PATH in user environment variables.") # clean PYTHONPATH --- 1687,1693 ---- "^\\s*export\\s*PATH=\\$GPHOME\\/script\\/gspylib\\" "/pssh\\/bin:\\$GPHOME\\/script:\\$PATH$") FileUtil.deleteLine(userProfile, ! "^\\s*export\\s*PATH=\\/root\\/gauss_om\\/%s\\" "/script:\\$PATH$" % self.user) self.logger.debug("Deleting crash PATH in user environment variables.") # clean PYTHONPATH *************** *** 1761,1770 **** basePort = node_info.datanodes[0].port FileUtil.writeFile(userProfile, ["export PGPORT=%d" % basePort]) - # set IP_TYPE - ip_type = NetUtil.get_ip_version(node_info.backIps[0]) - FileUtil.writeFile(userProfile, ["export IP_TYPE=%s" % ip_type]) - # set PATH if userProfile is ClusterConstants.ETC_PROFILE: FileUtil.writeFile(userProfile, [ --- 1746,1751 ---- *************** *** 1973,1978 **** --- 1954,1966 ---- def checkaio(self): # check libaio.so file exist + distname, version = LinuxDistro.linux_distribution()[0:2] + if distname in [UBUNTU, DEBIAN]: + cmd = "ls /usr/lib/*-linux-gnu/ | grep '^libaio.so' | wc -l" + (status, output) = subprocess.getstatusoutput(cmd) + if status == 0 and int(output) > 0: + return + cmd = "ls /usr/local/lib | grep '^libaio.so' | wc -l" (status, output) = subprocess.getstatusoutput(cmd) if status != 0: diff -crN script/os_platform/rhel_platform.py script_adapt/os_platform/rhel_platform.py *** script/os_platform/rhel_platform.py 2024-09-29 18:57:52.000000000 +0800 --- script_adapt/os_platform/rhel_platform.py 2024-12-20 20:30:57.000000000 +0800 *************** *** 93,99 **** distname, version = LinuxDistro.linux_distribution()[0:2] if self.isSupportSystemctl(): return self.getSystemctlCmd("crond.service", action) ! elif distname == "debian" and version == "buster/sid": return self.getServiceCmd("cron", action) return self.getServiceCmd("crond", action) --- 93,99 ---- distname, version = LinuxDistro.linux_distribution()[0:2] if self.isSupportSystemctl(): return self.getSystemctlCmd("crond.service", action) ! elif distname == "debian": return self.getServiceCmd("cron", action) return self.getServiceCmd("crond", action) *************** *** 176,182 **** (dist_name.lower() == H3LINUX) or (dist_name.lower() == NINGOS) or (dist_name.lower() == FUSIONOS) or ! (dist_name.lower() == DEBIAN and version == "buster/sid") )): return dist_name.lower(), version[0:3] elif((bits == BIT_VERSION and --- 176,182 ---- (dist_name.lower() == H3LINUX) or (dist_name.lower() == NINGOS) or (dist_name.lower() == FUSIONOS) or ! (dist_name.lower() == DEBIAN) )): return dist_name.lower(), version[0:3] elif((bits == BIT_VERSION and