!710 预安装增加校验 cpu rdtscp和avx指令
Merge pull request !710 from liuheng/fix43
This commit is contained in:
commit
a3454305cd
@ -81,6 +81,8 @@ ACTION_CHECK_OS_SOFTWARE = "check_os_software"
|
||||
ACTION_CHANGE_TOOL_ENV = "change_tool_env"
|
||||
#check config
|
||||
ACTION_CHECK_CONFIG = "check_config"
|
||||
# check cpu
|
||||
ACTION_CHECK_CPU_INSTRUCTIONS = "check_cpu_instructions"
|
||||
#############################################################################
|
||||
# Global variables
|
||||
# self.context.logger: globle logger
|
||||
@ -748,6 +750,30 @@ class PreinstallImpl:
|
||||
raise Exception(str(e))
|
||||
self.context.logger.log("Successfully checked OS version.", "constant")
|
||||
|
||||
def check_cpu_instructions(self):
|
||||
"""
|
||||
function: Check if CPU instructions support rdtscp and avx
|
||||
input:NA
|
||||
output:NA
|
||||
"""
|
||||
self.context.logger.log("Checking cpu instructions.", "addStep")
|
||||
try:
|
||||
# Checking OS version
|
||||
cmd = "%s -t %s -u %s -l %s" % (
|
||||
OMCommand.getLocalScript("Local_PreInstall"),
|
||||
ACTION_CHECK_CPU_INSTRUCTIONS,
|
||||
self.context.user,
|
||||
self.context.localLog)
|
||||
self.context.logger.debug("Checking cpu instructions: %s" % cmd)
|
||||
CmdExecutor.execCommandWithMode(
|
||||
cmd,
|
||||
self.context.sshTool,
|
||||
self.context.localMode or self.context.isSingle,
|
||||
self.context.mpprcFile)
|
||||
except Exception as e:
|
||||
self.context.logger.log("Warning: This cluster is missing the rdtscp or avx instruction.")
|
||||
self.context.logger.log("Successfully checked cpu instructions.", "constant")
|
||||
|
||||
def createOSUser(self):
|
||||
"""
|
||||
function:
|
||||
@ -1664,6 +1690,8 @@ class PreinstallImpl:
|
||||
self.checkOSSoftware()
|
||||
# check os version
|
||||
self.checkOSVersion()
|
||||
# check cpu instructions
|
||||
self.check_cpu_instructions()
|
||||
# create path and set mode
|
||||
self.createDirs()
|
||||
# set os parameters
|
||||
|
@ -30,6 +30,7 @@ import pwd
|
||||
import grp
|
||||
import configparser
|
||||
import re
|
||||
import platform
|
||||
|
||||
|
||||
sys.path.append(sys.path[0] + "/../")
|
||||
@ -86,6 +87,7 @@ ACTION_CHANGE_TOOL_ENV = "change_tool_env"
|
||||
ACTION_SET_CGROUP = "set_cgroup"
|
||||
ACTION_CHECK_CONFIG = "check_config"
|
||||
ACTION_DSS_NIT = "dss_init"
|
||||
ACTION_CHECK_CPU_INSTRUCTIONS = "check_cpu_instructions"
|
||||
|
||||
g_nodeInfo = None
|
||||
envConfig = {}
|
||||
@ -277,7 +279,7 @@ Common options:
|
||||
ACTION_SET_ARM_OPTIMIZATION,
|
||||
ACTION_CHECK_DISK_SPACE, ACTION_SET_WHITELIST,
|
||||
ACTION_FIX_SERVER_PACKAGE_OWNER, ACTION_DSS_NIT,
|
||||
ACTION_CHANGE_TOOL_ENV, ACTION_CHECK_CONFIG]
|
||||
ACTION_CHANGE_TOOL_ENV, ACTION_CHECK_CONFIG, ACTION_CHECK_CPU_INSTRUCTIONS]
|
||||
if self.action == "":
|
||||
GaussLog.exitWithError(
|
||||
ErrorCode.GAUSS_500["GAUSS_50001"] % 't' + ".")
|
||||
@ -1968,6 +1970,28 @@ Common options:
|
||||
for etcd_inst in g_nodeInfo.etcds:
|
||||
UserUtil.check_path_owner(etcd_inst.datadir)
|
||||
|
||||
def check_cpu_instructions(self):
|
||||
"""
|
||||
function: Check if CPU instructions support rdtscp and avx
|
||||
input:NA
|
||||
output:NA
|
||||
"""
|
||||
if "x86_64" not in platform.machine():
|
||||
return
|
||||
self.logger.debug("Checking cpu instructions.")
|
||||
cpu_mission = "Warning: This cluster is missing the rdtscp or avx instruction."
|
||||
try:
|
||||
cmd = "lscpu | grep rdtscp && lscpu | grep avx"
|
||||
# Checking cpu instructions
|
||||
(status, output) = subprocess.getstatusoutput(cmd)
|
||||
if status != 0 or not output:
|
||||
raise Exception(cpu_mission)
|
||||
else:
|
||||
self.logger.debug("Successfully checked cpu instructions.")
|
||||
except Exception as e:
|
||||
self.logger.debug(cpu_mission)
|
||||
raise Exception(cpu_mission)
|
||||
|
||||
def checkPlatformArm(self):
|
||||
"""
|
||||
function: Setting ARM Optimization
|
||||
@ -3093,6 +3117,8 @@ Common options:
|
||||
self.setCgroup()
|
||||
elif self.action == ACTION_CHECK_CONFIG:
|
||||
self.check_config()
|
||||
elif self.action == ACTION_CHECK_CPU_INSTRUCTIONS:
|
||||
self.check_cpu_instructions()
|
||||
else:
|
||||
self.logger.logExit(ErrorCode.GAUSS_500["GAUSS_50000"]
|
||||
% self.action)
|
||||
|
Loading…
x
Reference in New Issue
Block a user