diff --git a/proliantutils/redfish/redfish.py b/proliantutils/redfish/redfish.py index 1d1827bc..b4df0cb1 100644 --- a/proliantutils/redfish/redfish.py +++ b/proliantutils/redfish/redfish.py @@ -25,7 +25,6 @@ from OpenSSL.crypto import FILETYPE_ASN1 from OpenSSL.crypto import load_certificate from six.moves.urllib import parse import sushy -from sushy.resources.system import mappings as sushy_map from sushy import utils from proliantutils import exception @@ -127,6 +126,15 @@ _CERTIFICATE_PATTERN = ( LOG = log.get_logger(__name__) +# Copied from ironic/drivers/modules/redfish/inspect.py +CPU_ARCH_MAP = { + sushy.PROCESSOR_ARCH_x86: 'x86_64', + sushy.PROCESSOR_ARCH_IA_64: 'ia64', + sushy.PROCESSOR_ARCH_ARM: 'arm', + sushy.PROCESSOR_ARCH_MIPS: 'mips', + sushy.PROCESSOR_ARCH_OEM: 'oem' +} + class RedfishOperations(operations.IloOperations): """Operations supported on redfish based hardware. @@ -1237,8 +1245,8 @@ class RedfishOperations(operations.IloOperations): # local_gb = sushy_system.storage_summary prop = {'memory_mb': (sushy_system.memory_summary.size_gib * 1024), 'cpus': sushy_system.processors.summary.count, - 'cpu_arch': sushy_map.PROCESSOR_ARCH_VALUE_MAP_REV.get( - sushy_system.processors.summary.architecture), + 'cpu_arch': CPU_ARCH_MAP.get( + sushy_system.processors.summary.architecture), 'local_gb': common_storage.get_local_gb(sushy_system)} return {'properties': prop, 'macs': sushy_system.ethernet_interfaces.summary} diff --git a/proliantutils/redfish/resources/system/ethernet_interface.py b/proliantutils/redfish/resources/system/ethernet_interface.py index 7b4d111a..afdfbc2b 100644 --- a/proliantutils/redfish/resources/system/ethernet_interface.py +++ b/proliantutils/redfish/resources/system/ethernet_interface.py @@ -14,14 +14,12 @@ # License for the specific language governing permissions and limitations # under the License. +import sushy from sushy.resources import base from sushy.resources.system import ethernet_interface from sushy import utils as sushy_utils -from proliantutils.redfish.resources.system import constants as sys_cons - - class EthernetInterface(ethernet_interface.EthernetInterface): uefi_device_path = base.Field('UefiDevicePath') @@ -50,8 +48,8 @@ class EthernetInterfaceCollection(base.ResourceCollectionBase): for eth in self.get_members(): if eth.mac_address is not None: if (eth.status is not None - and eth.status.health == sys_cons.HEALTH_OK - and eth.status.state == sys_cons.HEALTH_STATE_ENABLED): + and eth.status.health == sushy.HEALTH_OK + and eth.status.state == sushy.STATE_ENABLED): mac_dict.update( {'Port ' + eth.identity: eth.mac_address}) return mac_dict diff --git a/proliantutils/tests/redfish/resources/manager/test_https_cert.py b/proliantutils/tests/redfish/resources/manager/test_https_cert.py index 91481666..977008c1 100644 --- a/proliantutils/tests/redfish/resources/manager/test_https_cert.py +++ b/proliantutils/tests/redfish/resources/manager/test_https_cert.py @@ -110,16 +110,20 @@ class HttpsCertTestCase(testtools.TestCase): 'The Redfish controller failed to import certificate. Error', self.https_cert_inst.import_certificate, 'certificate') + @mock.patch('time.sleep', autospec=True) @mock.patch.object(https_cert.HttpsCert, 'get_generate_csr_refresh', autospec=True) - def test_wait_for_csr_to_create_ok(self, get_generate_csr_refresh_mock): + def test_wait_for_csr_to_create_ok(self, get_generate_csr_refresh_mock, + sleep_mock): self.cert_sign_request = 'certificate' self.https_cert_inst.wait_for_csr_to_create() self.assertTrue(get_generate_csr_refresh_mock.called) + @mock.patch('time.sleep', autospec=True) @mock.patch.object(https_cert.HttpsCert, 'get_generate_csr_refresh', autospec=True) - def test_wait_for_csr_to_create_fails(self, get_generate_csr_refresh_mock): + def test_wait_for_csr_to_create_fails(self, get_generate_csr_refresh_mock, + sleep_mock): exc = exception.IloError('error') get_generate_csr_refresh_mock.side_effect = exc self.assertRaises(exception.IloError, diff --git a/proliantutils/tests/redfish/resources/system/test_ethernet_interface.py b/proliantutils/tests/redfish/resources/system/test_ethernet_interface.py index 10c9fb3c..20e83446 100644 --- a/proliantutils/tests/redfish/resources/system/test_ethernet_interface.py +++ b/proliantutils/tests/redfish/resources/system/test_ethernet_interface.py @@ -16,9 +16,9 @@ import json import mock +import sushy import testtools -from proliantutils.redfish.resources.system import constants as sys_cons from proliantutils.redfish.resources.system import ethernet_interface @@ -48,9 +48,8 @@ class EthernetInterfaceTestCase(testtools.TestCase): self.assertEqual( '12:44:6A:3B:04:11', self.sys_eth.permanent_mac_address) self.assertEqual('12:44:6A:3B:04:11', self.sys_eth.mac_address) - self.assertEqual(sys_cons.HEALTH_STATE_ENABLED, - self.sys_eth.status.state) - self.assertEqual(sys_cons.HEALTH_OK, self.sys_eth.status.health) + self.assertEqual(sushy.STATE_ENABLED, self.sys_eth.status.state) + self.assertEqual(sushy.HEALTH_OK, self.sys_eth.status.health) self.assertEqual(1000, self.sys_eth.speed_mbps) diff --git a/proliantutils/tests/redfish/test_redfish.py b/proliantutils/tests/redfish/test_redfish.py index a93af2ba..62abc175 100644 --- a/proliantutils/tests/redfish/test_redfish.py +++ b/proliantutils/tests/redfish/test_redfish.py @@ -1081,7 +1081,7 @@ class RedfishOperationsTestCase(testtools.TestCase): count_mock = mock.PropertyMock(return_value=40) type(get_system_mock.return_value.processors.summary).count = ( count_mock) - arch_mock = mock.PropertyMock(return_value='x86 or x86-64') + arch_mock = mock.PropertyMock(return_value=sushy.PROCESSOR_ARCH_x86) type(get_system_mock.return_value.processors.summary).architecture = ( arch_mock) type(get_system_mock.return_value.ethernet_interfaces).summary = ( @@ -1090,7 +1090,7 @@ class RedfishOperationsTestCase(testtools.TestCase): local_gb_mock.return_value = 600 actual = self.rf_client.get_essential_properties() expected = {'properties': {'cpus': 40, - 'cpu_arch': 'x86', + 'cpu_arch': 'x86_64', 'memory_mb': 20480, 'local_gb': 600}, 'macs': {'1': '12:44:6A:3B:04:11'}}