support ubuntu system

This commit is contained in:
zhengxue
2021-04-13 22:56:32 +08:00
parent d333de5e54
commit 5f830fc34c
5 changed files with 52 additions and 6 deletions

View File

@ -64,8 +64,10 @@ elif [ X$(echo $PLAT_FORM_STR | grep "openeuler") != X"" ]; then
dist_version="openEuler" dist_version="openEuler"
elif [ X$(echo $PLAT_FORM_STR | grep "euleros") != X"" ]; then elif [ X$(echo $PLAT_FORM_STR | grep "euleros") != X"" ]; then
dist_version="EulerOS" dist_version="EulerOS"
elif [ X$(echo $PLAT_FORM_STR | grep "ubuntu") != X"" ]; then
dist_version="Ubuntu"
else else
echo "We only support openEuler(aarch64), EulerOS(aarch64), CentOS platform." echo "We only support openEuler(aarch64), EulerOS(aarch64), CentOS, Ubuntu(x86) platform."
echo "Kernel is $kernel" echo "Kernel is $kernel"
exit 1 exit 1
fi fi

View File

@ -27,6 +27,8 @@ function get_os_str() {
os_str=openeuler_aarch64 os_str=openeuler_aarch64
elif [ "$os_name"x = "openEuler"x ] && [ "$cpu_arc"x = "x86_64"x ]; then elif [ "$os_name"x = "openEuler"x ] && [ "$cpu_arc"x = "x86_64"x ]; then
os_str=openeuler_x86_64 os_str=openeuler_x86_64
elif [ "$os_name"x = "ubuntu"x ] && [ "$cpu_arc"x = "x86_64"x ]; then
os_str=ubuntu18.04_x86_64
else else
os_str="Failed" os_str="Failed"
fi fi

View File

@ -797,6 +797,7 @@ class DefaultValue():
""" """
SuSENetWorkConfPath = "/etc/sysconfig/network" SuSENetWorkConfPath = "/etc/sysconfig/network"
RedHatNetWorkConfPath = "/etc/sysconfig/network-scripts" RedHatNetWorkConfPath = "/etc/sysconfig/network-scripts"
UbuntuNetWorkConfPath = "/etc/network"
NetWorkConfFile = "" NetWorkConfFile = ""
distname, version, idnum = g_Platform.dist() distname, version, idnum = g_Platform.dist()
distname = distname.lower() distname = distname.lower()
@ -812,6 +813,9 @@ class DefaultValue():
"redhat", "centos", "euleros", "openeuler")): "redhat", "centos", "euleros", "openeuler")):
cmd = "find %s -iname 'ifcfg-*-%s' -print" % ( cmd = "find %s -iname 'ifcfg-*-%s' -print" % (
RedHatNetWorkConfPath, networkCardNum) RedHatNetWorkConfPath, networkCardNum)
elif (distname == "debian" and version == "buster/sid"):
cmd = "find %s -iname 'ifcfg-*-%s' -print" % (
UbuntuNetWorkConfPath, networkCardNum)
else: else:
cmd = "find %s -iname 'ifcfg-*-%s' -print" % ( cmd = "find %s -iname 'ifcfg-*-%s' -print" % (
SuSENetWorkConfPath, networkCardNum) SuSENetWorkConfPath, networkCardNum)
@ -889,6 +893,12 @@ class DefaultValue():
# get local host by os function # get local host by os function
hostIp = socket.gethostbyname(hostname) hostIp = socket.gethostbyname(hostname)
# 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 = g_Platform.dist()[1].split('/')[0]
if version == "buster" and hostIp == "127.0.1.1":
hostIp = "127.0.0.1"
return hostIp return hostIp
@staticmethod @staticmethod
@ -1468,9 +1478,10 @@ class DefaultValue():
systemDir = "/usr/lib/systemd/system/" systemDir = "/usr/lib/systemd/system/"
systemFile = "/usr/lib/systemd/system/gs-OS-set.service" systemFile = "/usr/lib/systemd/system/gs-OS-set.service"
# OS init file # OS init file
# now we only support SuSE and RHEL/CentOS # now we only support SuSE, RHEL/CentOS and Ubuntu
initFileSuse = "/etc/init.d/boot.local" initFileSuse = "/etc/init.d/boot.local"
initFileRedhat = "/etc/rc.d/rc.local" initFileRedhat = "/etc/rc.d/rc.local"
initFileUbuntu = "/lib/systemd/system/rc.local.service"
# system init file # system init file
initSystemFile = "/usr/local/gauss/script/gauss-OS-set.sh" initSystemFile = "/usr/local/gauss/script/gauss-OS-set.sh"
initSystemPath = "/usr/local/gauss/script" initSystemPath = "/usr/local/gauss/script"
@ -1515,6 +1526,9 @@ class DefaultValue():
elif (distname in ("redhat", "centos", "euleros", "openEuler") and elif (distname in ("redhat", "centos", "euleros", "openEuler") and
os.path.isfile(initFileRedhat)): os.path.isfile(initFileRedhat)):
initFile = initFileRedhat initFile = initFileRedhat
elif (distname == "debian" and version == "buster/sid" and
os.path.isfile(initFileUbuntu)):
initFile = initFileUbuntu
else: else:
initFile = "" initFile = ""

View File

@ -100,8 +100,10 @@ EULEROS = "euleros"
KYLIN = "kylin" KYLIN = "kylin"
OPENEULER = "openeuler" OPENEULER = "openeuler"
ASIANUX = "asianux" ASIANUX = "asianux"
DEBIAN = "debian"
UBUNTU = "ubuntu"
SUPPORT_WHOLE_PLATFORM_LIST = [SUSE, REDHAT, CENTOS, EULEROS, SUPPORT_WHOLE_PLATFORM_LIST = [SUSE, REDHAT, CENTOS, EULEROS,
OPENEULER, KYLIN, ASIANUX] OPENEULER, KYLIN, ASIANUX, DEBIAN, UBUNTU]
# RedhatX platform # RedhatX platform
SUPPORT_RHEL_SERIES_PLATFORM_LIST = [REDHAT, CENTOS, "kylin", "asianux"] 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"] SUPPORT_RHEL6X_VERSION_LIST = ["6.4", "6.5", "6.6", "6.7", "6.8", "6.9", "10"]
@ -129,12 +131,13 @@ PAK_EULER = "Euler"
PAK_OPENEULER = "openEuler" PAK_OPENEULER = "openEuler"
PAK_REDHAT = "RedHat" PAK_REDHAT = "RedHat"
PAK_ASIANUX = "asianux" PAK_ASIANUX = "asianux"
PAK_UBUNTU = "Ubuntu"
####################################################### #######################################################
_supported_dists = ( _supported_dists = (
'SuSE', 'debian', 'fedora', 'redhat', 'centos', 'euleros', "openEuler", 'SuSE', 'debian', 'fedora', 'redhat', 'centos', 'euleros', "openEuler",
'mandrake', 'mandriva', 'rocks', 'slackware', 'yellowdog', 'gentoo', 'mandrake', 'mandriva', 'rocks', 'slackware', 'yellowdog', 'gentoo',
'UnitedLinux', 'turbolinux', 'kylin', 'asianux') 'UnitedLinux', 'turbolinux', 'kylin', 'asianux', 'ubuntu')
_release_filename = re.compile(r'(\w+)[-_](release|version)') _release_filename = re.compile(r'(\w+)[-_](release|version)')
_lsb_release_version = re.compile(r'(.+)' _lsb_release_version = re.compile(r'(.+)'
' release ' ' release '
@ -1561,6 +1564,12 @@ class LinuxPlatform(GenericPlatform):
prefixStr, packageVersion, prefixStr, packageVersion,
PAK_OPENEULER, PAK_OPENEULER,
BIT_VERSION, postfixStr)) BIT_VERSION, postfixStr))
elif distname in DEBIAN and (version == "buster/sid"):
fileName = os.path.join(dirName, "./../../../",
"%s-%s-%s-%s.%s" % (
prefixStr, packageVersion,
PAK_UBUNTU,
BIT_VERSION, postfixStr))
else: else:
raise Exception(ErrorCode.GAUSS_519["GAUSS_51900"] + raise Exception(ErrorCode.GAUSS_519["GAUSS_51900"] +
"Supported platforms are: %s." % str( "Supported platforms are: %s." % str(
@ -1853,8 +1862,13 @@ class RHELPlatform(LinuxPlatform):
input : action input : action
output : str output : str
""" """
# get system information
distname, version = g_Platform.dist()[0:2]
if self.isSupportSystemctl(): if self.isSupportSystemctl():
return self.getSystemctlCmd("crond.service", action) return self.getSystemctlCmd("crond.service", action)
elif distname == "debian" and version == "buster/sid":
return self.getServiceCmd("cron", action)
else: else:
return self.getServiceCmd("crond", action) return self.getServiceCmd("crond", action)
@ -1917,12 +1931,14 @@ class RHELPlatform(LinuxPlatform):
try: try:
distName, version, currentId = dist() distName, version, currentId = dist()
bits = platform.architecture()[0] bits = platform.architecture()[0]
if ((bits == BIT_VERSION and if ((bits == BIT_VERSION and
((distName.lower() == EULEROS and version[0:3] in ((distName.lower() == EULEROS and version[0:3] in
SUPPORT_EULEROS_VERSION_LIST) or SUPPORT_EULEROS_VERSION_LIST) or
(distName.lower() in SUPPORT_RHEL_SERIES_PLATFORM_LIST and (distName.lower() in SUPPORT_RHEL_SERIES_PLATFORM_LIST and
version[0:3] in SUPPORT_RHEL_SERIES_VERSION_LIST)) or version[0:3] in SUPPORT_RHEL_SERIES_VERSION_LIST)) or
(distName.lower() == OPENEULER) (distName.lower() == OPENEULER) or
(distName.lower() == DEBIAN and version == "buster/sid")
)): )):
return distName.lower(), version[0:3] return distName.lower(), version[0:3]
else: else:
@ -1935,6 +1951,10 @@ class RHELPlatform(LinuxPlatform):
" The current system is: %s%s%s" % ( " The current system is: %s%s%s" % (
distName.lower(), distName.lower(),
version[0:3], currentId)) version[0:3], currentId))
if distName.lower() == DEBIAN:
raise Exception(ErrorCode.GAUSS_519["GAUSS_51900"] +
" The current system is: %s/%s" % (
distName.lower(), version))
else: else:
raise Exception(ErrorCode.GAUSS_519["GAUSS_51900"] + raise Exception(ErrorCode.GAUSS_519["GAUSS_51900"] +
" The current system is: %s%s" % ( " The current system is: %s%s" % (
@ -1974,6 +1994,7 @@ class UserPlatform():
# SuSE11 sp1/2/3/4 64bit # SuSE11 sp1/2/3/4 64bit
# SuSE12 sp0/1/2/3 64bit # SuSE12 sp0/1/2/3 64bit
# Kylin "10" 64bit # Kylin "10" 64bit
# Ubuntu "18.04" 64bit
distName, version, idNum = dist() distName, version, idNum = dist()
if distName.lower() not in SUPPORT_WHOLE_PLATFORM_LIST: if distName.lower() not in SUPPORT_WHOLE_PLATFORM_LIST:
raise Exception(ErrorCode.GAUSS_519["GAUSS_51900"] + raise Exception(ErrorCode.GAUSS_519["GAUSS_51900"] +

View File

@ -1696,7 +1696,11 @@ def CheckIOSchedulers(isSetting=False):
input : Bool input : Bool
output : NA output : NA
""" """
# The IO Schedulers in ubuntu system is default value,
# so that it cannot be modified
distname, version = g_Platform.dist()[0:2]
if distname == "debian" and version == "buster/sid":
return
data = collectIOschedulers() data = collectIOschedulers()
for dev in list(data.devices.keys()): for dev in list(data.devices.keys()):
expectedScheduler = "deadline" expectedScheduler = "deadline"
@ -1926,6 +1930,9 @@ def CheckPlatformInfo():
elif (data.distname == "euleros" or data.distname == "openEuler" or data.distname == "kylin"): elif (data.distname == "euleros" or data.distname == "openEuler" or data.distname == "kylin"):
mixedType = "%s" % data.distname mixedType = "%s" % data.distname
platformStr = "%s_%s_%s" % (data.distname, data.version, data.bits) platformStr = "%s_%s_%s" % (data.distname, data.version, data.bits)
elif (data.distname == "debian" or data.version == "buster/sid"):
mixedType = "%s" % data.distname
platformStr = "%s_%s_%s" % (data.distname, data.version, data.bits)
else: else:
platformStr = "%s_%s_%s" % (data.distname, data.version, data.bits) platformStr = "%s_%s_%s" % (data.distname, data.version, data.bits)
g_logger.log("False unknown %s" % platformStr) g_logger.log("False unknown %s" % platformStr)