Make case-insensitive search for Blade server model string

Closes-bug: 1761243
Co-Authored-By: M V P Nitesh <parimalanitesh@gmail.com>

Change-Id: Ia7db061bb8848388c769411d84208b7c925864c8
This commit is contained in:
Nisha Agarwal 2018-04-09 23:53:52 -07:00 committed by mvpnitesh
parent fd12088a11
commit 258b18d302
2 changed files with 44 additions and 8 deletions

View File

@ -886,7 +886,7 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations):
LOG.debug(self._("Node is already in '%(power)s' power state."),
{'power': power})
return
if power == 'ON' and 'Proliant BL' in self.get_product_name():
if power == 'ON' and 'PROLIANT BL' in self.get_product_name().upper():
self._retry_until_powered_on(power)
else:
self._perform_power_op(POWER_STATE[power])

View File

@ -1189,24 +1189,60 @@ class IloRisTestCase(testtools.TestCase):
@mock.patch.object(ris.RISOperations, '_perform_power_op')
@mock.patch.object(ris.RISOperations, 'get_host_power_status')
def test_set_host_power_change(self, host_power_status_mock,
perform_power_op_mock):
@mock.patch.object(ris.RISOperations, 'get_product_name')
@mock.patch.object(ris.RISOperations, '_retry_until_powered_on')
def test_set_host_power_off_for_blade_servers(self, retry_mock,
product_mock,
host_power_status_mock,
perform_power_op_mock):
host_power_status_mock.return_value = 'ON'
product_mock.return_value = 'ProLiant BL460'
self.client.set_host_power('off')
host_power_status_mock.assert_called_once_with()
perform_power_op_mock.assert_called_once_with('ForceOff')
self.assertFalse(retry_mock.called)
@mock.patch.object(ris.RISOperations, '_perform_power_op')
@mock.patch.object(ris.RISOperations, 'get_host_power_status')
@mock.patch.object(ris.RISOperations, 'get_product_name')
def test_set_host_power_change_on(self, product_mock,
host_power_status_mock,
perform_power_op_mock):
@mock.patch.object(ris.RISOperations, '_retry_until_powered_on')
def test_set_host_power_on_for_blade_servers(self, retry_mock,
product_mock,
host_power_status_mock,
perform_power_op_mock):
host_power_status_mock.return_value = 'OFF'
product_mock.return_value = 'ProLiant BL460'
self.client.set_host_power('On')
product_mock.return_value = 'BL460'
host_power_status_mock.assert_called_once_with()
perform_power_op_mock.assert_called_once_with('On')
self.assertTrue(product_mock.called)
self.assertFalse(perform_power_op_mock.called)
self.assertTrue(retry_mock.called)
@mock.patch.object(ris.RISOperations, '_perform_power_op')
@mock.patch.object(ris.RISOperations, 'get_host_power_status')
@mock.patch.object(ris.RISOperations, '_retry_until_powered_on')
def test_set_host_power_off_for_non_blade_servers(
self, retry_mock, host_power_status_mock, perform_power_op_mock):
host_power_status_mock.return_value = 'ON'
self.client.set_host_power('off')
host_power_status_mock.assert_called_once_with()
perform_power_op_mock.assert_called_once_with('ForceOff')
self.assertFalse(retry_mock.called)
@mock.patch.object(ris.RISOperations, '_perform_power_op')
@mock.patch.object(ris.RISOperations, 'get_host_power_status')
@mock.patch.object(ris.RISOperations, 'get_product_name')
@mock.patch.object(ris.RISOperations, '_retry_until_powered_on')
def test_set_host_power_on_for_non_blade_servers(
self, retry_mock, product_mock, host_power_status_mock,
perform_power_op_mock):
host_power_status_mock.return_value = 'OFF'
product_mock.return_value = 'ProLiant DL380'
self.client.set_host_power('On')
host_power_status_mock.assert_called_once_with()
self.assertTrue(product_mock.called)
self.assertTrue(perform_power_op_mock.called)
self.assertFalse(retry_mock.called)
@mock.patch.object(ris.RISOperations, '_perform_power_op')
@mock.patch.object(ris.RISOperations, 'get_host_power_status')