Update get_essential_properties() for empty CPU socket
This patch updates get_essential_properties() so that "'NoneType' object has no attribute 'text'" exception is not thrown when one of CPU sockets is empty in bare metal server. Change-Id: Ib5a8f0cd93c03049d1810678fc4ddfbd69b0b499
This commit is contained in:
@@ -477,7 +477,8 @@ def get_essential_properties(report, prop_keys):
|
|||||||
[int(int(size.text) / 1000)
|
[int(int(size.text) / 1000)
|
||||||
for size in report.findall('.//PhysicalDrive/PhysicalSize')])
|
for size in report.findall('.//PhysicalDrive/PhysicalSize')])
|
||||||
v['cpus'] = sum([int(cpu.find('./CoreNumber').text)
|
v['cpus'] = sum([int(cpu.find('./CoreNumber').text)
|
||||||
for cpu in report.find('./System/Processor')])
|
for cpu in report.find('./System/Processor')
|
||||||
|
if cpu.find('./CoreNumber') is not None])
|
||||||
# v['cpus'] = sum([int(cpu.find('./LogicalCpuNumber').text)
|
# v['cpus'] = sum([int(cpu.find('./LogicalCpuNumber').text)
|
||||||
# for cpu in report.find('./System/Processor')])
|
# for cpu in report.find('./System/Processor')])
|
||||||
v['cpu_arch'] = 'x86_64'
|
v['cpu_arch'] = 'x86_64'
|
||||||
|
|||||||
@@ -85,6 +85,10 @@
|
|||||||
<Level2CacheSize Unit="KByte">2048</Level2CacheSize>
|
<Level2CacheSize Unit="KByte">2048</Level2CacheSize>
|
||||||
<Level3CacheSize Unit="KByte">20480</Level3CacheSize>
|
<Level3CacheSize Unit="KByte">20480</Level3CacheSize>
|
||||||
</CPU>
|
</CPU>
|
||||||
|
<CPU Boot="false">
|
||||||
|
<SocketDesignation>CPU2</SocketDesignation>
|
||||||
|
<Status Description="empty">0</Status>
|
||||||
|
</CPU>
|
||||||
</Processor>
|
</Processor>
|
||||||
<Memory Schema="2">
|
<Memory Schema="2">
|
||||||
<Installed>8192</Installed>
|
<Installed>8192</Installed>
|
||||||
|
|||||||
@@ -672,3 +672,16 @@ class SCCITestCase(testtools.TestCase):
|
|||||||
self.report_ok_xml, ESSENTIAL_PROPERTIES_KEYS)
|
self.report_ok_xml, ESSENTIAL_PROPERTIES_KEYS)
|
||||||
|
|
||||||
self.assertEqual(expected, result)
|
self.assertEqual(expected, result)
|
||||||
|
|
||||||
|
def test_get_essential_properties_empty_cpu_socket(self):
|
||||||
|
ESSENTIAL_PROPERTIES_KEYS = {
|
||||||
|
'memory_mb', 'local_gb', 'cpus', 'cpu_arch'}
|
||||||
|
expected = {'memory_mb': 8192,
|
||||||
|
'local_gb': 190,
|
||||||
|
'cpus': 16,
|
||||||
|
'cpu_arch': 'x86_64'}
|
||||||
|
|
||||||
|
result = scci.get_essential_properties(
|
||||||
|
self.report_ng_xml, ESSENTIAL_PROPERTIES_KEYS)
|
||||||
|
|
||||||
|
self.assertEqual(expected, result)
|
||||||
|
|||||||
Reference in New Issue
Block a user