Skip to content

Commit 98d3231

Browse files
authored
Adding support for RHEL8 binary-compatible variants (#5158)
* Adding support for RHEL binary-compatible variants * Skip ipmi related tests * Fixing security_groups.py
1 parent 72182b6 commit 98d3231

File tree

6 files changed

+63
-67
lines changed

6 files changed

+63
-67
lines changed

python/lib/cloudutils/serviceConfig.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,6 @@
2323
import os
2424
import shutil
2525

26-
# exit() error constants
27-
Unknown = 0
28-
CentOS6 = 1
29-
CentOS7 = 2
30-
CentOS8 = 3
31-
Ubuntu = 4
32-
RHEL6 = 5
33-
RHEL7 = 6
34-
RHEL8 = 7
35-
distro = None
36-
37-
#=================== DISTRIBUTION DETECTION =================
38-
if os.path.exists("/etc/centos-release"):
39-
version = open("/etc/centos-release").readline()
40-
if version.find("CentOS release 6") != -1:
41-
distro = CentOS6
42-
elif version.find("CentOS Linux release 7") != -1:
43-
distro = CentOS7
44-
elif version.find("CentOS Linux release 8") != -1:
45-
distro = CentOS8
46-
elif os.path.exists("/etc/redhat-release"):
47-
version = open("/etc/redhat-release").readline()
48-
if version.find("Red Hat Enterprise Linux Server release 6") != -1:
49-
distro = RHEL6
50-
elif version.find("Red Hat Enterprise Linux Server 7") != -1:
51-
distro = RHEL7
52-
elif version.find("Red Hat Enterprise Linux Server 8") != -1:
53-
distro = RHEL8
54-
elif os.path.exists("/etc/lsb-release") and "Ubuntu" in open("/etc/lsb-release").read(-1): distro = Ubuntu
55-
else: distro = Unknown
56-
#=================== DISTRIBUTION DETECTION =================
57-
5826
class serviceCfgBase(object):
5927
def __init__(self, syscfg):
6028
self.status = None
@@ -531,8 +499,6 @@ def config(self):
531499
configureLibvirtConfig(self.syscfg.env.secure, self)
532500

533501
cfo = configFileOps("/etc/sysconfig/libvirtd", self)
534-
if distro in (CentOS6,RHEL6):
535-
cfo.addEntry("export CGROUP_DAEMON", "'cpu:/virt'")
536502
cfo.addEntry("LIBVIRTD_ARGS", "-l")
537503
cfo.save()
538504
if os.path.exists("/lib/systemd/system/libvirtd.socket"):

python/lib/cloudutils/utilities.py

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
# to you under the Apache License, Version 2.0 (the
66
# "License"); you may not use this file except in compliance
77
# with the License. You may obtain a copy of the License at
8-
#
8+
#
99
# http://www.apache.org/licenses/LICENSE-2.0
10-
#
10+
#
1111
# Unless required by applicable law or agreed to in writing,
1212
# software distributed under the License is distributed on an
1313
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -53,25 +53,25 @@ def alarm_handler(signum, frame):
5353
except:
5454
raise CloudRuntimeException(formatExceptionInfo())
5555

56-
if not self.success:
56+
if not self.success:
5757
logging.debug("Failed to execute:" + self.getErrMsg())
5858

5959
def isSuccess(self):
6060
return self.success
61-
61+
6262
def getStdout(self):
6363
return self.stdout.decode('utf-8').strip('\n')
64-
64+
6565
def getLines(self):
6666
return self.stdout.decode('utf-8').strip('\n')
6767

6868
def getStderr(self):
6969
return self.stderr.decode('utf-8').strip('\n')
70-
70+
7171
def getErrMsg(self):
7272
if self.isSuccess():
7373
return ""
74-
74+
7575
if self.getStderr() is None or self.getStderr() == "":
7676
return self.getStdout()
7777
else:
@@ -80,11 +80,11 @@ def getErrMsg(self):
8080
def initLoging(logFile=None):
8181
try:
8282
if logFile is None:
83-
logging.basicConfig(level=logging.DEBUG)
84-
else:
85-
logging.basicConfig(filename=logFile, level=logging.DEBUG)
83+
logging.basicConfig(level=logging.DEBUG)
84+
else:
85+
logging.basicConfig(filename=logFile, level=logging.DEBUG)
8686
except:
87-
logging.basicConfig(level=logging.DEBUG)
87+
logging.basicConfig(level=logging.DEBUG)
8888

8989
def writeProgressBar(msg, result):
9090
output = "[%-6s]\n"%"Failed"
@@ -100,7 +100,7 @@ def writeProgressBar(msg, result):
100100
class UnknownSystemException(Exception):
101101
"This Excption is raised if the current operating enviornment is unknown"
102102
pass
103-
103+
104104
class Distribution:
105105
def __init__(self):
106106
self.distro = "Unknown"
@@ -110,11 +110,15 @@ def __init__(self):
110110
self.distro = "Fedora"
111111
elif os.path.exists("/etc/redhat-release"):
112112
version = open("/etc/redhat-release").readline()
113-
if version.find("Red Hat Enterprise Linux Server release 6") != -1 or version.find("Scientific Linux release 6") != -1 or version.find("CentOS Linux release 6") != -1 or version.find("CentOS release 6.") != -1:
113+
if (version.find("Red Hat Enterprise Linux Server release 6") != -1 or version.find("Scientific Linux release 6") != -1 or
114+
version.find("CentOS Linux release 6") != -1 or version.find("CentOS release 6.") != -1):
114115
self.distro = "RHEL6"
115-
elif version.find("Red Hat Enterprise Linux Server release 7") != -1 or version.find("Scientific Linux release 7") != -1 or version.find("CentOS Linux release 7") != -1 or version.find("CentOS release 7.") != -1:
116+
elif (version.find("Red Hat Enterprise Linux Server release 7") != -1 or version.find("Scientific Linux release 7") != -1 or
117+
version.find("CentOS Linux release 7") != -1 or version.find("CentOS release 7.") != -1):
116118
self.distro = "RHEL7"
117-
elif version.find("Red Hat Enterprise Linux Server release 8") != -1 or version.find("Scientific Linux release 8") != -1 or version.find("CentOS Linux release 8") != -1 or version.find("CentOS release 8.") != -1:
119+
elif (version.find("Red Hat Enterprise Linux Server release 8") != -1 or version.find("Scientific Linux release 8") != -1 or
120+
version.find("CentOS Linux release 8") != -1 or version.find("CentOS release 8.") != -1 or
121+
version.find("Linux release 8") != -1):
118122
self.distro = "RHEL8"
119123
elif version.find("CentOS") != -1:
120124
self.distro = "CentOS"
@@ -134,17 +138,17 @@ def __init__(self):
134138
self.distro = "Ubuntu"
135139
else:
136140
raise UnknownSystemException(distributor)
137-
else:
141+
else:
138142
raise UnknownSystemException
139143

140144
def getVersion(self):
141-
return self.distro
145+
return self.distro
142146
def getRelease(self):
143147
return self.release
144148
def getArch(self):
145149
return self.arch
146-
147-
150+
151+
148152
class serviceOps:
149153
pass
150154
class serviceOpsRedhat(serviceOps):
@@ -161,7 +165,7 @@ def isServiceRunning(self, servicename):
161165
def stopService(self, servicename,force=False):
162166
if self.isServiceRunning(servicename) or force:
163167
return bash("service " + servicename +" stop").isSuccess()
164-
168+
165169
return True
166170
def disableService(self, servicename):
167171
result = self.stopService(servicename)
@@ -176,13 +180,13 @@ def startService(self, servicename,force=False):
176180
def enableService(self, servicename,forcestart=False):
177181
bash("chkconfig --level 2345 " + servicename + " on")
178182
return self.startService(servicename,force=forcestart)
179-
183+
180184
def isKVMEnabled(self):
181185
if os.path.exists("/dev/kvm"):
182186
return True
183187
else:
184188
return False
185-
189+
186190
class serviceOpsUbuntu(serviceOps):
187191
def isServiceRunning(self, servicename):
188192
try:
@@ -202,7 +206,7 @@ def disableService(self, servicename):
202206
result = self.stopService(servicename)
203207
bash("sudo update-rc.d -f " + servicename + " remove")
204208
return result
205-
209+
206210
def startService(self, servicename,force=True):
207211
if not self.isServiceRunning(servicename) or force:
208212
return bash("sudo /usr/sbin/service " + servicename + " start").isSuccess()

scripts/vm/network/security_group.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def destroy_network_rules_for_nic(vm_name, vm_ip, vm_mac, vif, sec_ips):
185185
logging.debug("Ignoring failure to delete ebtable rules for vm: " + vm_name)
186186

187187
def get_bridge_physdev(brname):
188-
physdev = execute("bridge -o link show | awk '/master %s / && !/^[0-9]+: vnet/ {print $2}' | head -1 | cut -d ':' -f1" % brname)
188+
physdev = execute("bridge -o link show | awk '/master %s / && !/^[0-9]+: vnet/ {print $2}' | head -1 | cut -d ':' -f1 | cut -d '@' -f1" % brname)
189189
return physdev.strip()
190190

191191

test/integration/smoke/test_deploy_vm_iso_uefi.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def setUpClass(cls):
5858

5959
if not cls.isUefiEnabledOnAtLeastOnHost(hosts):
6060
raise unittest.SkipTest("At least one host should support UEFI")
61-
61+
6262
cls.hostConfig = cls.config.__dict__["zones"][0].__dict__["pods"][0].__dict__["clusters"][0].__dict__["hosts"][0].__dict__
6363

6464
# Create service, disk offerings etc
@@ -179,12 +179,12 @@ def getVirshXML(self, host, instancename):
179179
def checkBootTypeAndMode(self, root, bootmodesecure, isWindowsIso):
180180

181181
machine = root.find(".os/type").get("machine")
182-
183182
self.assertEqual(("q35" in machine), True, "The virtual machine is not with UEFI boot type")
184183

185-
bootmode = root.find(".os/loader").get("secure")
186-
187-
self.assertEqual((bootmode == bootmodesecure), True, "The VM is not in the right boot mode")
184+
if root.find(".os/loader") is not None :
185+
bootmode = root.find(".os/loader").get("secure")
186+
if bootmode is not None :
187+
self.assertEqual((bootmode == bootmodesecure), True, "The VM is not in the right boot mode")
188188

189189
if isWindowsIso:
190190
disks = root.findall("devices/disk")

test/integration/smoke/test_hostha_kvm.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,18 @@ def deployVM(self):
209209
except Exception as e:
210210
raise self.skipTest("Failed to deploy VM, skipping kvm host-ha test case")
211211

212+
def skipIfMSIsUnsupported(self) :
213+
os_details = SshClient(self.mgtSvrDetails["mgtSvrIp"], 22, self.mgtSvrDetails["user"], self.mgtSvrDetails["passwd"]).execute \
214+
("/usr/share/cloudstack-common/scripts/vm/hypervisor/versions.sh | cut -d '=' -f2")
215+
os = os_details[0].lower()
216+
if 'ubuntu' in os or 'debian' in os :
217+
return
218+
# RHEL < 8 works fine
219+
os_ver = os_details[1].split('.')[0]
220+
if float(os_ver) < 8:
221+
return
222+
self.skipTest("Skipping since RHEL8 / SUSE have known IPMI issues")
223+
212224
@attr(tags=["devcloud", "advanced", "advancedns", "smoke", "basic", "sg"], required_hardware="true")
213225
def test_disable_oobm_ha_state_ineligible(self):
214226
"""
@@ -276,10 +288,10 @@ def test_hostha_enable_ha_when_host_in_maintenance(self):
276288
self.logger.debug("Starting test_hostha_enable_ha_when_host_in_maintenance")
277289
self.logger.debug("Pausing to wait for VMs to have finished starting")
278290
time.sleep(300)
279-
291+
280292
# Enable HA
281293
self.configureAndEnableHostHa()
282-
294+
283295

284296
# Prepare for maintenance Host
285297
self.setHostToMaintanance(self.host.id)
@@ -351,6 +363,7 @@ def test_hostha_kvm_host_degraded(self):
351363
Tests degraded HA state when agent is stopped/killed
352364
"""
353365

366+
self.skipIfMSIsUnsupported()
354367
self.configureAndStartIpmiServer()
355368
self.assertIssueCommandState('ON', 'On')
356369
self.configureAndEnableHostHa()
@@ -387,6 +400,7 @@ def test_hostha_kvm_host_recovering(self):
387400
Tests recovery and fencing HA state transitions
388401
"""
389402

403+
self.skipIfMSIsUnsupported()
390404
self.configureAndStartIpmiServer()
391405
self.assertIssueCommandState('ON', 'On')
392406
self.configureAndEnableHostHa()
@@ -426,7 +440,7 @@ def test_hostha_kvm_host_fencing(self):
426440
"""
427441
self.logger.debug("Starting test_ha_kvm_host_fencing")
428442

429-
443+
self.skipIfMSIsUnsupported()
430444
self.configureAndStartIpmiServer()
431445
self.assertIssueCommandState('ON', 'On')
432446
self.configureAndEnableHostHa()

test/integration/smoke/test_outofbandmanagement.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ class TestOutOfBandManagement(cloudstackTestCase):
4242
def setUpClass(cls):
4343
testClient = super(TestOutOfBandManagement, cls).getClsTestClient()
4444
cls.apiclient = testClient.getApiClient()
45+
cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__
4546
cls.services = testClient.getParsedTestDataConfig()
4647
cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
4748
cls.host = None
4849
cls.cleanup = []
50+
cls.skipIfMSIsUnsupported(cls)
4951

5052
# use random port for ipmisim
5153
s = socket.socket()
@@ -82,7 +84,6 @@ def setUp(self):
8284
self.fakeMsId = random.randint(10000, 99999) * random.randint(10, 20)
8385
self.cleanup = []
8486

85-
8687
def tearDown(self):
8788
try:
8889
self.dbclient.execute("delete from oobm where port=%d" % self.getIpmiServerPort())
@@ -94,6 +95,17 @@ def tearDown(self):
9495
except Exception as e:
9596
raise Exception("Warning: Exception during cleanup : %s" % e)
9697

98+
def skipIfMSIsUnsupported(self) :
99+
os_details = SshClient(self.mgtSvrDetails["mgtSvrIp"], 22, self.mgtSvrDetails["user"], self.mgtSvrDetails["passwd"]).execute \
100+
("/usr/share/cloudstack-common/scripts/vm/hypervisor/versions.sh | cut -d '=' -f2")
101+
os = os_details[0].lower()
102+
if 'ubuntu' in os or 'debian' in os :
103+
return
104+
# RHEL < 8 works fine
105+
os_ver = os_details[1].split('.')[0]
106+
if float(os_ver) < 8:
107+
return
108+
self.skipTest(self, reason="Skipping since RHEL8 / SUSE have known IPMI issues")
97109

98110
def getFakeMsId(self):
99111
return self.fakeMsId

0 commit comments

Comments
 (0)