summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-05-16 10:17:29 +0000
committerGerrit Code Review <review@openstack.org>2017-05-16 10:17:29 +0000
commit2932ddfe904749e95b42c38e340ddca712f0b779 (patch)
treeb3e93a26ff96186a923983cbe22df58c1577a06c
parentc0ca2d71265c4a256bd32b734bfd5d66816e7982 (diff)
parentf3c4ffc92be2914db594f3d4d214ac065242501e (diff)
Merge "Set 'trusted_boot' capability only when TPM chip is present"
-rwxr-xr-xproliantutils/ilo/ris.py7
-rwxr-xr-xproliantutils/tests/ilo/test_ris.py44
2 files changed, 42 insertions, 9 deletions
diff --git a/proliantutils/ilo/ris.py b/proliantutils/ilo/ris.py
index 784b699..86eaea3 100755
--- a/proliantutils/ilo/ris.py
+++ b/proliantutils/ilo/ris.py
@@ -975,7 +975,9 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
975 capabilities['rom_firmware_version'] = rom_firmware_version 975 capabilities['rom_firmware_version'] = rom_firmware_version
976 capabilities.update(self._get_ilo_firmware_version()) 976 capabilities.update(self._get_ilo_firmware_version())
977 capabilities.update(self._get_number_of_gpu_devices_connected()) 977 capabilities.update(self._get_number_of_gpu_devices_connected())
978 capabilities.update(self._get_tpm_capability()) 978 if self._get_tpm_capability():
979 capabilities['trusted_boot'] = 'true'
980
979 if self._get_cpu_virtualization(): 981 if self._get_cpu_virtualization():
980 capabilities['cpu_vt'] = 'true' 982 capabilities['cpu_vt'] = 'true'
981 if self._get_nvdimm_n_status(): 983 if self._get_nvdimm_n_status():
@@ -1514,8 +1516,7 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
1514 except exception.IloCommandNotSupportedError: 1516 except exception.IloCommandNotSupportedError:
1515 tpm_state = "NotPresent" 1517 tpm_state = "NotPresent"
1516 tpm_result = tpm_values[tpm_state] 1518 tpm_result = tpm_values[tpm_state]
1517 1519 return tpm_result
1518 return {'trusted_boot': tpm_result}
1519 1520
1520 def _get_cpu_virtualization(self): 1521 def _get_cpu_virtualization(self):
1521 """get cpu virtualization status.""" 1522 """get cpu virtualization status."""
diff --git a/proliantutils/tests/ilo/test_ris.py b/proliantutils/tests/ilo/test_ris.py
index 60d8059..1097115 100755
--- a/proliantutils/tests/ilo/test_ris.py
+++ b/proliantutils/tests/ilo/test_ris.py
@@ -393,14 +393,46 @@ class IloRisTestCase(testtools.TestCase):
393 gpu_mock.return_value = {'pci_gpu_devices': 2} 393 gpu_mock.return_value = {'pci_gpu_devices': 2}
394 cpu_vt_mock.return_value = True 394 cpu_vt_mock.return_value = True
395 secure_mock.return_value = False 395 secure_mock.return_value = False
396 tpm_mock.return_value = {'trusted_boot': True}
397 nvdimm_n_mock.return_value = True 396 nvdimm_n_mock.return_value = True
397 tpm_mock.return_value = True
398 expected_caps = {'secure_boot': 'true',
399 'ilo_firmware_version': 'iLO 4 v2.20',
400 'rom_firmware_version': u'I36 v1.40 (01/28/2015)',
401 'server_model': u'ProLiant BL460c Gen9',
402 'pci_gpu_devices': 2,
403 'trusted_boot': 'true',
404 'cpu_vt': 'true',
405 'nvdimm_n': 'true'}
406 capabilities = self.client.get_server_capabilities()
407 self.assertEqual(expected_caps, capabilities)
408
409 @mock.patch.object(ris.RISOperations, '_get_nvdimm_n_status')
410 @mock.patch.object(ris.RISOperations,
411 '_get_cpu_virtualization')
412 @mock.patch.object(ris.RISOperations, '_get_tpm_capability')
413 @mock.patch.object(ris.RISOperations,
414 '_get_number_of_gpu_devices_connected')
415 @mock.patch.object(ris.RISOperations, 'get_secure_boot_mode')
416 @mock.patch.object(ris.RISOperations, '_get_ilo_firmware_version')
417 @mock.patch.object(ris.RISOperations, '_get_host_details')
418 def test_get_server_capabilities_tp_absent(self,
419 get_details_mock,
420 ilo_firm_mock, secure_mock,
421 gpu_mock, tpm_mock,
422 cpu_vt_mock, nvdimm_n_mock):
423 host_details = json.loads(ris_outputs.RESPONSE_BODY_FOR_REST_OP)
424 get_details_mock.return_value = host_details
425 ilo_firm_mock.return_value = {'ilo_firmware_version': 'iLO 4 v2.20'}
426 gpu_mock.return_value = {'pci_gpu_devices': 2}
427 secure_mock.return_value = False
428 nvdimm_n_mock.return_value = True
429 tpm_mock.return_value = False
430 cpu_vt_mock.return_value = True
398 expected_caps = {'secure_boot': 'true', 431 expected_caps = {'secure_boot': 'true',
399 'ilo_firmware_version': 'iLO 4 v2.20', 432 'ilo_firmware_version': 'iLO 4 v2.20',
400 'rom_firmware_version': u'I36 v1.40 (01/28/2015)', 433 'rom_firmware_version': u'I36 v1.40 (01/28/2015)',
401 'server_model': u'ProLiant BL460c Gen9', 434 'server_model': u'ProLiant BL460c Gen9',
402 'pci_gpu_devices': 2, 435 'pci_gpu_devices': 2,
403 'trusted_boot': True,
404 'cpu_vt': 'true', 436 'cpu_vt': 'true',
405 'nvdimm_n': 'true'} 437 'nvdimm_n': 'true'}
406 capabilities = self.client.get_server_capabilities() 438 capabilities = self.client.get_server_capabilities()
@@ -1798,21 +1830,21 @@ class TestRISOperationsPrivateMethods(testtools.TestCase):
1798 @mock.patch.object(ris.RISOperations, '_get_bios_setting') 1830 @mock.patch.object(ris.RISOperations, '_get_bios_setting')
1799 def test__get_tpm_capability_notpresent(self, bios_mock): 1831 def test__get_tpm_capability_notpresent(self, bios_mock):
1800 bios_mock.return_value = 'NotPresent' 1832 bios_mock.return_value = 'NotPresent'
1801 expected_out = {'trusted_boot': False} 1833 expected_out = False
1802 status = self.client._get_tpm_capability() 1834 status = self.client._get_tpm_capability()
1803 self.assertEqual(expected_out, status) 1835 self.assertEqual(expected_out, status)
1804 1836
1805 @mock.patch.object(ris.RISOperations, '_get_bios_setting') 1837 @mock.patch.object(ris.RISOperations, '_get_bios_setting')
1806 def test__get_tpm_capability_presentdisabled(self, bios_mock): 1838 def test__get_tpm_capability_presentdisabled(self, bios_mock):
1807 bios_mock.return_value = 'PresentDisabled' 1839 bios_mock.return_value = 'PresentDisabled'
1808 expected_out = {'trusted_boot': True} 1840 expected_out = True
1809 status = self.client._get_tpm_capability() 1841 status = self.client._get_tpm_capability()
1810 self.assertEqual(expected_out, status) 1842 self.assertEqual(expected_out, status)
1811 1843
1812 @mock.patch.object(ris.RISOperations, '_get_bios_setting') 1844 @mock.patch.object(ris.RISOperations, '_get_bios_setting')
1813 def test__get_tpm_capability_presentenabled(self, bios_mock): 1845 def test__get_tpm_capability_presentenabled(self, bios_mock):
1814 bios_mock.return_value = 'PresentEnabled' 1846 bios_mock.return_value = 'PresentEnabled'
1815 expected_out = {'trusted_boot': True} 1847 expected_out = True
1816 status = self.client._get_tpm_capability() 1848 status = self.client._get_tpm_capability()
1817 self.assertEqual(expected_out, status) 1849 self.assertEqual(expected_out, status)
1818 1850
@@ -1820,7 +1852,7 @@ class TestRISOperationsPrivateMethods(testtools.TestCase):
1820 def test__get_tpm_capability_resource_notpresent(self, bios_mock): 1852 def test__get_tpm_capability_resource_notpresent(self, bios_mock):
1821 msg = 'BIOS Property TpmState is not supported on this system.' 1853 msg = 'BIOS Property TpmState is not supported on this system.'
1822 bios_mock.side_effect = exception.IloCommandNotSupportedError(msg) 1854 bios_mock.side_effect = exception.IloCommandNotSupportedError(msg)
1823 expected_out = {'trusted_boot': False} 1855 expected_out = False
1824 status = self.client._get_tpm_capability() 1856 status = self.client._get_tpm_capability()
1825 self.assertEqual(expected_out, status) 1857 self.assertEqual(expected_out, status)
1826 1858