Merge "Fixes problem in is_boss_controller function"

This commit is contained in:
Zuul 2019-01-24 12:31:03 +00:00 committed by Gerrit Code Review
commit 82480155bf
3 changed files with 57 additions and 6 deletions

View File

@ -956,14 +956,23 @@ class DRACClient(object):
"""
return self._raid_mgmt.is_raid_controller(raid_controller_fqdd)
def is_boss_controller(self, raid_controller_fqdd):
def is_boss_controller(self, raid_controller_fqdd, raid_controllers=None):
"""Find out if a RAID controller a BOSS card or not
:param raid_controller_fqdd: The object's fqdd we are testing to see
if it is a BOSS card or not.
:param raid_controllers: A list of RAIDController to scan for presence
of BOSS card, if None the drac will be queried
for the list of controllers which will then be
scanned.
:returns: boolean, True if the device is a BOSS card, False if not.
:raises: WSManRequestFailure on request failures
:raises: WSManInvalidResponse when receiving invalid response
:raises: DRACOperationFailed on error reported back by the DRAC
interface
"""
return self._raid_mgmt.is_boss_controller(raid_controller_fqdd)
return self._raid_mgmt.is_boss_controller(raid_controller_fqdd,
raid_controllers)
def change_physical_disk_state(self, mode,
controllers_to_physical_disk_ids=None):

View File

@ -504,14 +504,26 @@ class RAIDManagement(object):
"""
return raid_controller_fqdd.startswith('RAID.')
def is_boss_controller(self, raid_controller_fqdd):
def is_boss_controller(self, raid_controller_fqdd, raid_controllers=None):
"""Find out if a RAID controller a BOSS card or not
:param raid_controller_fqdd: The object's fqdd we are testing to see
if it is a BOSS card or not.
:param raid_controllers: A list of RAIDController to scan for presence
of BOSS card, if None the drac will be queried
for the list of controllers which will then be
scanned.
:returns: boolean, True if the device is a BOSS card, False if not.
:raises: WSManRequestFailure on request failures
:raises: WSManInvalidResponse when receiving invalid response
:raises: DRACOperationFailed on error reported back by the DRAC
interface
"""
return raid_controller_fqdd.startswith('AHCI.')
if raid_controllers is None:
raid_controllers = self.list_raid_controllers()
boss_raid_controllers = [
c.id for c in raid_controllers if c.model.startswith('BOSS')]
return raid_controller_fqdd in boss_raid_controllers
def _check_disks_status(self, mode, physical_disks,
controllers_to_physical_disk_ids):

View File

@ -772,11 +772,41 @@ class ClientRAIDManagementTestCase(base.BaseTest):
self.assertFalse(self.drac_client
.is_raid_controller("notRAID.Integrated.1-1"))
def test_is_boss_controller(self, mock_requests):
@mock.patch.object(dracclient.client.WSManClient,
'wait_until_idrac_is_ready', spec_set=True,
autospec=True)
def test_is_boss_controller(self, mock_requests,
mock_wait_until_idrac_is_ready):
mock_requests.post(
'https://1.2.3.4:443/wsman',
text=test_utils.RAIDEnumerations[uris.DCIM_ControllerView]['ok'])
self.assertTrue(self.drac_client
.is_boss_controller("AHCI.Integrated.1-1"))
@mock.patch.object(dracclient.client.WSManClient,
'wait_until_idrac_is_ready', spec_set=True,
autospec=True)
def test_is_not_boss_controller(self, mock_requests,
mock_wait_until_idrac_is_ready):
mock_requests.post(
'https://1.2.3.4:443/wsman',
text=test_utils.RAIDEnumerations[uris.DCIM_ControllerView]['ok'])
self.assertFalse(self.drac_client
.is_boss_controller("notAHCI.Integrated.1-1"))
.is_boss_controller("notAHCI.Integrated.1-1"),
None)
@mock.patch.object(dracclient.client.WSManClient,
'wait_until_idrac_is_ready', spec_set=True,
autospec=True)
def test_is_boss_controller_with_cntl_list(self, mock_requests,
mock_wait_until_idrac_is_ready):
mock_requests.post(
'https://1.2.3.4:443/wsman',
text=test_utils.RAIDEnumerations[uris.DCIM_ControllerView]['ok'])
controllers = self.drac_client.list_raid_controllers()
self.assertTrue(self.drac_client
.is_boss_controller("AHCI.Integrated.1-1",
controllers))
def test_check_disks_status_no_controllers(self, mock_requests):
physical_disks = [self.disk_1, self.disk_2, self.disk_3, self.disk_4]