Browse Source

Implement ResetConfig and ClearForeignConfig functionality

For raid deletion, existing delete_virtual_disk functionality is not
freeing up foreign drives and spares, so have added ResetConfig and
ClearForeignConfig functionality for freeing up foreign drives and
spares.

Change-Id: I76390dc4fcf8de2fe5aa3d660f77edcef4a4dec1
(cherry picked from commit 6857a6d000)
changes/78/665478/2
mpardhi23 3 years ago committed by Christopher Dearborn
parent
commit
db1eae0ca0
  1. 44
      dracclient/client.py
  2. 68
      dracclient/resources/raid.py
  3. 71
      dracclient/tests/test_raid.py
  4. 12
      dracclient/tests/utils.py
  5. 17
      dracclient/tests/wsman_mocks/raid_service-invoke-clear_foreign_config-error.xml
  6. 16
      dracclient/tests/wsman_mocks/raid_service-invoke-clear_foreign_config-ok.xml
  7. 2
      dracclient/tests/wsman_mocks/raid_service-invoke-delete_virtual_disk-error.xml
  8. 2
      dracclient/tests/wsman_mocks/raid_service-invoke-delete_virtual_disk-ok.xml
  9. 17
      dracclient/tests/wsman_mocks/raid_service-invoke-reset_raid_config-error.xml
  10. 16
      dracclient/tests/wsman_mocks/raid_service-invoke-reset_raid_config-ok.xml

44
dracclient/client.py

@ -788,6 +788,50 @@ class DRACClient(object):
"""
return self._raid_mgmt.delete_virtual_disk(virtual_disk)
def reset_raid_config(self, raid_controller):
"""Delete all the virtual disks and unassign all hot spare physical disks
The job to reset the RAID controller config will be in pending state.
For the changes to be applied, a config job must be created.
:param raid_controller: id of the RAID controller
:returns: a dictionary containing:
- The is_commit_required key with the value always set to
True indicating that a config job must be created to
reset configuration.
- The is_reboot_required key with a RebootRequired enumerated
value indicating whether the server must be rebooted to
reset configuration.
:raises: WSManRequestFailure on request failures
:raises: WSManInvalidResponse when receiving invalid response
:raises: DRACOperationFailed on error reported back by the DRAC
interface
:raises: DRACUnexpectedReturnValue on return value mismatch
"""
return self._raid_mgmt.reset_raid_config(raid_controller)
def clear_foreign_config(self, raid_controller):
"""Free up foreign drives
The job to clear foreign config will be in pending state.
For the changes to be applied, a config job must be created.
:param raid_controller: id of the RAID controller
:returns: a dictionary containing:
- The is_commit_required key with the value always set to
True indicating that a config job must be created to
clear foreign configuration.
- The is_reboot_required key with a RebootRequired enumerated
value indicating whether the server must be rebooted to
clear foreign configuration.
:raises: WSManRequestFailure on request failures
:raises: WSManInvalidResponse when receiving invalid response
:raises: DRACOperationFailed on error reported back by the DRAC
interface
:raises: DRACUnexpectedReturnValue on return value mismatch
"""
return self._raid_mgmt.clear_foreign_config(raid_controller)
def commit_pending_raid_changes(self, raid_controller, reboot=False,
start_time='TIME_NOW', realtime=False):
"""Applies all pending changes on a RAID controller

68
dracclient/resources/raid.py

@ -805,3 +805,71 @@ class RAIDManagement(object):
return True
return False
def reset_raid_config(self, raid_controller):
"""Delete all virtual disk and unassign all hotspares
The job to reset the RAID controller config will be in pending state.
For the changes to be applied, a config job must be created.
:param raid_controller: id of the RAID controller
:returns: a dictionary containing:
- The is_commit_required key with the value always set to
True indicating that a config job must be created to
reset configuration.
- The is_reboot_required key with a RebootRequired enumerated
value indicating whether the server must be rebooted to
reset configuration.
:raises: WSManRequestFailure on request failures
:raises: WSManInvalidResponse when receiving invalid response
:raises: DRACOperationFailed on error reported back by the DRAC
interface
:raises: DRACUnexpectedReturnValue on return value mismatch
"""
selectors = {'SystemCreationClassName': 'DCIM_ComputerSystem',
'CreationClassName': 'DCIM_RAIDService',
'SystemName': 'DCIM:ComputerSystem',
'Name': 'DCIM:RAIDService'}
properties = {'Target': raid_controller}
doc = self.client.invoke(uris.DCIM_RAIDService, 'ResetConfig',
selectors, properties,
expected_return_value=utils.RET_SUCCESS)
return utils.build_return_dict(doc, uris.DCIM_RAIDService,
is_commit_required_value=True)
def clear_foreign_config(self, raid_controller):
"""Free up foreign drives
The job to clear foreign config will be in pending state.
For the changes to be applied, a config job must be created.
:param raid_controller: id of the RAID controller
:returns: a dictionary containing:
- The is_commit_required key with the value always set to
True indicating that a config job must be created to
clear foreign configuration.
- The is_reboot_required key with a RebootRequired enumerated
value indicating whether the server must be rebooted to
clear foreign configuration.
:raises: WSManRequestFailure on request failures
:raises: WSManInvalidResponse when receiving invalid response
:raises: DRACOperationFailed on error reported back by the DRAC
interface
:raises: DRACUnexpectedReturnValue on return value mismatch
"""
selectors = {'SystemCreationClassName': 'DCIM_ComputerSystem',
'CreationClassName': 'DCIM_RAIDService',
'SystemName': 'DCIM:ComputerSystem',
'Name': 'DCIM:RAIDService'}
properties = {'Target': raid_controller}
doc = self.client.invoke(uris.DCIM_RAIDService, 'ClearForeignConfig',
selectors, properties,
expected_return_value=utils.RET_SUCCESS)
return utils.build_return_dict(doc, uris.DCIM_RAIDService,
is_commit_required_value=True)

71
dracclient/tests/test_raid.py

@ -593,6 +593,77 @@ class ClientRAIDManagementTestCase(base.BaseTest):
exceptions.DRACOperationFailed,
self.drac_client.delete_virtual_disk, 'disk1')
@mock.patch.object(dracclient.client.WSManClient, 'invoke',
spec_set=True, autospec=True)
def test_reset_raid_config(self, mock_requests, mock_invoke):
expected_selectors = {'SystemCreationClassName': 'DCIM_ComputerSystem',
'CreationClassName': 'DCIM_RAIDService',
'SystemName': 'DCIM:ComputerSystem',
'Name': 'DCIM:RAIDService'}
expected_properties = {'Target': self.raid_controller_fqdd}
mock_invoke.return_value = lxml.etree.fromstring(
test_utils.RAIDInvocations[uris.DCIM_RAIDService][
'ResetConfig']['ok'])
result = self.drac_client.reset_raid_config(self.raid_controller_fqdd)
self.assertEqual({'is_commit_required': True,
'is_reboot_required':
constants.RebootRequired.optional},
result)
mock_invoke.assert_called_once_with(
mock.ANY, uris.DCIM_RAIDService, 'ResetConfig',
expected_selectors, expected_properties,
expected_return_value=utils.RET_SUCCESS)
@mock.patch.object(dracclient.client.WSManClient,
'wait_until_idrac_is_ready', spec_set=True,
autospec=True)
def test_reset_raid_config_fail(self, mock_requests,
mock_wait_until_idrac_is_ready):
mock_requests.post(
'https://1.2.3.4:443/wsman',
text=test_utils.RAIDInvocations[
uris.DCIM_RAIDService]['ResetConfig']['error'])
self.assertRaises(
exceptions.DRACOperationFailed,
self.drac_client.reset_raid_config, self.raid_controller_fqdd)
@mock.patch.object(dracclient.client.WSManClient, 'invoke',
spec_set=True, autospec=True)
def test_clear_foreign_config(self, mock_requests, mock_invoke):
expected_selectors = {'SystemCreationClassName': 'DCIM_ComputerSystem',
'CreationClassName': 'DCIM_RAIDService',
'SystemName': 'DCIM:ComputerSystem',
'Name': 'DCIM:RAIDService'}
expected_properties = {'Target': self.raid_controller_fqdd}
mock_invoke.return_value = lxml.etree.fromstring(
test_utils.RAIDInvocations[uris.DCIM_RAIDService][
'ClearForeignConfig']['ok'])
result = self.drac_client.clear_foreign_config(
self.raid_controller_fqdd)
self.assertEqual({'is_commit_required': True,
'is_reboot_required':
constants.RebootRequired.optional},
result)
mock_invoke.assert_called_once_with(
mock.ANY, uris.DCIM_RAIDService, 'ClearForeignConfig',
expected_selectors, expected_properties,
expected_return_value=utils.RET_SUCCESS)
@mock.patch.object(dracclient.client.WSManClient,
'wait_until_idrac_is_ready', spec_set=True,
autospec=True)
def test_clear_foreign_config_fail(self, mock_requests,
mock_wait_until_idrac_is_ready):
mock_requests.post(
'https://1.2.3.4:443/wsman',
text=test_utils.RAIDInvocations[
uris.DCIM_RAIDService]['ClearForeignConfig']['error'])
self.assertRaises(
exceptions.DRACOperationFailed,
self.drac_client.clear_foreign_config, self.raid_controller_fqdd)
@mock.patch.object(dracclient.resources.job.JobManagement,
'create_config_job', spec_set=True, autospec=True)
def test_commit_pending_raid_changes(self, mock_requests,

12
dracclient/tests/utils.py

@ -253,6 +253,18 @@ RAIDInvocations = {
'raid_service-invoke-convert_physical_disks-ok'),
'error': load_wsman_xml(
'raid_service-invoke-convert_physical_disks-error'),
},
'ResetConfig': {
'ok': load_wsman_xml(
'raid_service-invoke-reset_raid_config-ok'),
'error': load_wsman_xml(
'raid_service-invoke-reset_raid_config-error'),
},
'ClearForeignConfig': {
'ok': load_wsman_xml(
'raid_service-invoke-clear_foreign_config-ok'),
'error': load_wsman_xml(
'raid_service-invoke-clear_foreign_config-error'),
}
}
}

17
dracclient/tests/wsman_mocks/raid_service-invoke-clear_foreign_config-error.xml

@ -0,0 +1,17 @@
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:n1="http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_RAIDService">
<s:Header>
<wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
<wsa:Action>http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_RAIDService/ClearForeignConfigResponse</wsa:Action>
<wsa:RelatesTo>uuid:f9487fcf-103a-103a-8002-fd0aa2bdb228</wsa:RelatesTo>
<wsa:MessageID>uuid:000852e6-1040-1040-8997-a36fc6fe83b0</wsa:MessageID>
</s:Header>
<s:Body>
<n1:ClearForeignConfig_OUTPUT>
<n1:Message>>No foreign drives detected</n1:Message>
<n1:MessageID>STOR018</n1:MessageID>
<n1:ReturnValue>2</n1:ReturnValue>
</n1:ClearForeignConfig_OUTPUT>
</s:Body>
</s:Envelope>

16
dracclient/tests/wsman_mocks/raid_service-invoke-clear_foreign_config-ok.xml

@ -0,0 +1,16 @@
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:n1="http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_RAIDService">
<s:Header>
<wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
<wsa:Action>http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_RAIDService/ClearForeignConfigResponse</wsa:Action>
<wsa:RelatesTo>uuid:fefa06de-103a-103a-8002-fd0aa2bdb228</wsa:RelatesTo>
<wsa:MessageID>uuid:05bc00f4-1040-1040-899d-a36fc6fe83b0</wsa:MessageID>
</s:Header>
<s:Body>
<n1:ClearForeignConfig_OUTPUT>
<n1:RebootRequired>OPTIONAL</n1:RebootRequired>
<n1:ReturnValue>0</n1:ReturnValue>
</n1:ClearForeignConfig_OUTPUT>
</s:Body>
</s:Envelope>

2
dracclient/tests/wsman_mocks/raid_service-invoke-delete_virtual_disk-error.xml

@ -14,4 +14,4 @@
<n1:ReturnValue>2</n1:ReturnValue>
</n1:DeleteVirtualDisk_OUTPUT>
</s:Body>
</s:Envelope>
</s:Envelope>

2
dracclient/tests/wsman_mocks/raid_service-invoke-delete_virtual_disk-ok.xml

@ -13,4 +13,4 @@
<n1:ReturnValue>0</n1:ReturnValue>
</n1:DeleteVirtualDisk_OUTPUT>
</s:Body>
</s:Envelope>
</s:Envelope>

17
dracclient/tests/wsman_mocks/raid_service-invoke-reset_raid_config-error.xml

@ -0,0 +1,17 @@
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:n1="http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_RAIDService">
<s:Header>
<wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
<wsa:Action>http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_RAIDService/ResetConfigResponse</wsa:Action>
<wsa:RelatesTo>uuid:f9487fcf-103a-103a-8002-fd0aa2bdb228</wsa:RelatesTo>
<wsa:MessageID>uuid:000852e6-1040-1040-8997-a36fc6fe83b0</wsa:MessageID>
</s:Header>
<s:Body>
<n1:ResetConfig_OUTPUT>
<n1:Message>Virtual Disk not found</n1:Message>
<n1:MessageID>STOR028</n1:MessageID>
<n1:ReturnValue>2</n1:ReturnValue>
</n1:ResetConfig_OUTPUT>
</s:Body>
</s:Envelope>

16
dracclient/tests/wsman_mocks/raid_service-invoke-reset_raid_config-ok.xml

@ -0,0 +1,16 @@
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:n1="http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_RAIDService">
<s:Header>
<wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
<wsa:Action>http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_RAIDService/ResetConfigResponse</wsa:Action>
<wsa:RelatesTo>uuid:fefa06de-103a-103a-8002-fd0aa2bdb228</wsa:RelatesTo>
<wsa:MessageID>uuid:05bc00f4-1040-1040-899d-a36fc6fe83b0</wsa:MessageID>
</s:Header>
<s:Body>
<n1:ResetConfig_OUTPUT>
<n1:RebootRequired>OPTIONAL</n1:RebootRequired>
<n1:ReturnValue>0</n1:ReturnValue>
</n1:ResetConfig_OUTPUT>
</s:Body>
</s:Envelope>
Loading…
Cancel
Save