Modify error message of InvalidInputException in hpssa
This commit adds details about controllers available in hpssa to the error message when InvalidInputException is raised Closes-Bug: #1609228 Change-Id: I0ad8472cf839e3823424583ed30a03ba1407bc5a
This commit is contained in:
@@ -134,7 +134,11 @@ def create_configuration(raid_config):
|
||||
|
||||
controller = server.get_controller_by_id(controller_id)
|
||||
if not controller:
|
||||
msg = ("Unable to find controller named '%s'" % controller_id)
|
||||
msg = ("Unable to find controller named '%(controller)s'."
|
||||
" The available controllers are '%(ctrl_list)s'." %
|
||||
{'controller': controller_id,
|
||||
'ctrl_list': ', '.join(
|
||||
[c.id for c in server.controllers])})
|
||||
raise exception.InvalidInputError(reason=msg)
|
||||
|
||||
if 'physical_disks' in logical_disk:
|
||||
|
||||
@@ -114,6 +114,21 @@ class ManagerTestCases(testtools.TestCase):
|
||||
manager.create_configuration,
|
||||
raid_info)
|
||||
|
||||
no_drives = raid_constants.HPSSA_NO_DRIVES
|
||||
get_all_details_mock.return_value = no_drives
|
||||
raid_info = {'logical_disks': [
|
||||
{'size_gb': 50,
|
||||
'raid_level': '1',
|
||||
'controller': 'Smart Array P822 in Slot 0',
|
||||
'physical_disks': ["6I:1:5", "6I:1:6"]}]}
|
||||
msg = ("Invalid Input: Unable to find controller named 'Smart Array "
|
||||
"P822 in Slot 0'. The available controllers are "
|
||||
"'Smart Array P822 in Slot 2'.")
|
||||
ex = self.assertRaises(exception.InvalidInputError,
|
||||
manager.create_configuration,
|
||||
raid_info)
|
||||
self.assertEqual(msg, str(ex))
|
||||
|
||||
@mock.patch.object(objects.Controller, 'execute_cmd')
|
||||
def test_create_configuration_without_disk_input_succeeds(
|
||||
self, controller_exec_cmd_mock, get_all_details_mock):
|
||||
|
||||
Reference in New Issue
Block a user