diff --git a/proliantutils/ilo/client.py b/proliantutils/ilo/client.py index f7ae096..672eead 100644 --- a/proliantutils/ilo/client.py +++ b/proliantutils/ilo/client.py @@ -26,7 +26,6 @@ SUPPORTED_RIS_METHODS = [ 'get_product_name', 'get_secure_boot_mode', 'reset_bios_to_default', - 'reset_ilo', 'reset_ilo_credential', 'reset_secure_boot_keys', 'set_http_boot_url', diff --git a/proliantutils/ilo/common.py b/proliantutils/ilo/common.py index 3aaf403..f2bae79 100644 --- a/proliantutils/ilo/common.py +++ b/proliantutils/ilo/common.py @@ -19,21 +19,23 @@ import time from proliantutils import exception # Max number of times an operation to be retried -RETRY_COUNT = 2 +RETRY_COUNT = 10 def wait_for_ilo_after_reset(ilo_object): """Checks if iLO is up after reset.""" retry_count = RETRY_COUNT + # Delay for 10 sec, for the reset operation to take effect. + time.sleep(10) + while retry_count: try: - # Delay for 5 sec, for the reset operation to take effect. - time.sleep(5) ilo_object.get_product_name() break except exception.IloError: retry_count -= 1 + time.sleep(5) else: msg = ('iLO is not up after reset.') raise exception.IloConnectionError(msg) diff --git a/proliantutils/ilo/ris.py b/proliantutils/ilo/ris.py index 09d52ea..412fc3b 100644 --- a/proliantutils/ilo/ris.py +++ b/proliantutils/ilo/ris.py @@ -561,7 +561,8 @@ class RISOperations(operations.IloOperations): :raises: IloCommandNotSupportedError, if the command is not supported on the server. """ - if boot_mode.lower() not in ['uefi', 'legacy']: + boot_mode = boot_mode.lower() + if boot_mode not in ['uefi', 'legacy']: msg = 'Invalid Boot mode specified' raise exception.IloInvalidInputError(msg) diff --git a/proliantutils/tests/ilo/test_client.py b/proliantutils/tests/ilo/test_client.py index 8606317..530e878 100644 --- a/proliantutils/tests/ilo/test_client.py +++ b/proliantutils/tests/ilo/test_client.py @@ -39,4 +39,10 @@ class IloClientTestCase(testtools.TestCase): def test__call_method_ris(self, power_mock): self.client.model = 'Gen9' self.client._call_method('get_host_power_status') - power_mock.assert_called_once_with() \ No newline at end of file + power_mock.assert_called_once_with() + + @mock.patch.object(ribcl.RIBCLOperations, 'reset_ilo') + def test__call_method_gen9_ribcl(self, ilo_mock): + self.client.model = 'Gen9' + self.client._call_method('reset_ilo') + ilo_mock.assert_called_once_with() diff --git a/proliantutils/tests/ilo/test_common.py b/proliantutils/tests/ilo/test_common.py index f2dcee4..a801f0b 100644 --- a/proliantutils/tests/ilo/test_common.py +++ b/proliantutils/tests/ilo/test_common.py @@ -13,6 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. """Test Class for Common Operations.""" + +import time import unittest import mock @@ -36,18 +38,20 @@ class IloCommonModuleTestCase(unittest.TestCase): common.wait_for_ilo_after_reset(self.ribcl) name_mock.assert_called_once_with() + @mock.patch.object(time, 'sleep') @mock.patch.object(ribcl.RIBCLOperations, 'get_product_name') - def test__check_link_status_retry(self, name_mock): + def test_wait_for_ilo_after_reset_retry(self, name_mock, sleep_mock): exc = exception.IloError('error') name_mock.side_effect = [exc, ribcl_output.GET_PRODUCT_NAME] common.wait_for_ilo_after_reset(self.ribcl) - self.assertEqual(common.RETRY_COUNT, name_mock.call_count) + self.assertEqual(2, name_mock.call_count) name_mock.assert_called_with() + @mock.patch.object(time, 'sleep') @mock.patch.object(ribcl.RIBCLOperations, 'get_product_name') - def test__check_link_status_fail(self, name_mock): + def test_wait_for_ilo_after_reset_fail(self, name_mock, time_mock): exc = exception.IloError('error') - name_mock.side_effect = [exc, exc] + name_mock.side_effect = exc self.assertRaises(exception.IloConnectionError, common.wait_for_ilo_after_reset, self.ribcl)