Bug Fixes

This commit addresses some of the bug fixes which includes -
1. Changing boot_mode to lower, as accepted by set_pending_boot_mode
2. Increasing the timeout and number of retries to check for status
   of iLO
3. Fallback to RIBCL for reset_ilo for 'gen9' servers.

Change-Id: Iacd122ffecaecbda671bcf21fad660f5c9592a61
This commit is contained in:
Anusha Ramineni
2015-04-08 18:26:28 +05:30
parent cffe85f287
commit ec4c3f4323
5 changed files with 22 additions and 10 deletions

View File

@@ -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',

View File

@@ -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)

View File

@@ -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)

View File

@@ -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()
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()

View File

@@ -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)