"Fossies" - the Fresh Open Source Software Archive

Member "ironic-16.0.3/ironic/tests/unit/drivers/modules/ilo/test_raid.py" (18 Jan 2021, 29543 Bytes) of package /linux/misc/openstack/ironic-16.0.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "test_raid.py": 16.0.2_vs_16.0.3.

    1 # Copyright 2018 Hewlett Packard Enterprise Development LP
    2 #
    3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
    4 # not use this file except in compliance with the License. You may obtain
    5 # a copy of the License at
    6 #
    7 #      http://www.apache.org/licenses/LICENSE-2.0
    8 #
    9 # Unless required by applicable law or agreed to in writing, software
   10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
   11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   12 # License for the specific language governing permissions and limitations
   13 # under the License.
   14 
   15 """Test class for Raid Interface used by iLO5."""
   16 
   17 from unittest import mock
   18 
   19 from oslo_utils import importutils
   20 
   21 from ironic.common import exception
   22 from ironic.common import raid
   23 from ironic.common import states
   24 from ironic.conductor import task_manager
   25 from ironic.conductor import utils as manager_utils
   26 from ironic.drivers.modules import deploy_utils
   27 from ironic.drivers.modules.ilo import common as ilo_common
   28 from ironic.drivers.modules.ilo import raid as ilo_raid
   29 from ironic.tests.unit.db import base as db_base
   30 from ironic.tests.unit.db import utils as db_utils
   31 from ironic.tests.unit.objects import utils as obj_utils
   32 
   33 ilo_error = importutils.try_import('proliantutils.exception')
   34 
   35 INFO_DICT = db_utils.get_test_ilo_info()
   36 
   37 
   38 class Ilo5RAIDTestCase(db_base.DbTestCase):
   39 
   40     def setUp(self):
   41         super(Ilo5RAIDTestCase, self).setUp()
   42         self.driver = mock.Mock(raid=ilo_raid.Ilo5RAID())
   43         self.target_raid_config = {
   44             "logical_disks": [
   45                 {'size_gb': 200, 'raid_level': 0, 'is_root_volume': True},
   46                 {'size_gb': 200, 'raid_level': 5}
   47             ]}
   48         n = {
   49             'driver': 'ilo5',
   50             'driver_info': INFO_DICT,
   51             'target_raid_config': self.target_raid_config,
   52         }
   53         self.config(enabled_hardware_types=['ilo5'],
   54                     enabled_boot_interfaces=['ilo-virtual-media'],
   55                     enabled_console_interfaces=['ilo'],
   56                     enabled_deploy_interfaces=['iscsi'],
   57                     enabled_inspect_interfaces=['ilo'],
   58                     enabled_management_interfaces=['ilo5'],
   59                     enabled_power_interfaces=['ilo'],
   60                     enabled_raid_interfaces=['ilo5'])
   61         self.node = obj_utils.create_test_node(self.context, **n)
   62 
   63     @mock.patch.object(deploy_utils, 'build_agent_options', autospec=True)
   64     @mock.patch.object(manager_utils, 'node_power_action', autospec=True)
   65     def _test__prepare_for_read_raid_create_raid(
   66             self, mock_reboot, mock_build_opt):
   67         with task_manager.acquire(self.context, self.node.uuid) as task:
   68             mock_build_opt.return_value = []
   69             task.driver.raid._prepare_for_read_raid(task, 'create_raid')
   70             self.assertTrue(
   71                 task.node.driver_internal_info.get(
   72                     'ilo_raid_create_in_progress'))
   73             if task.node.clean_step:
   74                 self.assertTrue(
   75                     task.node.driver_internal_info.get(
   76                         'cleaning_reboot'))
   77                 self.assertFalse(
   78                     task.node.driver_internal_info.get(
   79                         'skip_current_clean_step'))
   80             if task.node.deploy_step:
   81                 self.assertTrue(
   82                     task.node.driver_internal_info.get(
   83                         'deployment_reboot'))
   84                 self.assertFalse(
   85                     task.node.driver_internal_info.get(
   86                         'skip_current_deploy_step'))
   87             mock_reboot.assert_called_once_with(task, states.REBOOT)
   88 
   89     def test__prepare_for_read_raid_create_raid_cleaning(self):
   90         self.node.clean_step = {'step': 'create_configuration',
   91                                 'interface': 'raid'}
   92         self.node.save()
   93         self._test__prepare_for_read_raid_create_raid()
   94 
   95     def test__prepare_for_read_raid_create_raid_deploying(self):
   96         self.node.deploy_step = {'step': 'create_configuration',
   97                                  'interface': 'raid'}
   98         self.node.save()
   99         self._test__prepare_for_read_raid_create_raid()
  100 
  101     @mock.patch.object(deploy_utils, 'build_agent_options', autospec=True)
  102     @mock.patch.object(manager_utils, 'node_power_action', autospec=True)
  103     def _test__prepare_for_read_raid_delete_raid(
  104             self, mock_reboot, mock_build_opt):
  105         with task_manager.acquire(self.context, self.node.uuid) as task:
  106             mock_build_opt.return_value = []
  107             task.driver.raid._prepare_for_read_raid(task, 'delete_raid')
  108             self.assertTrue(
  109                 task.node.driver_internal_info.get(
  110                     'ilo_raid_delete_in_progress'))
  111             if task.node.clean_step:
  112                 self.assertTrue(
  113                     task.node.driver_internal_info.get(
  114                         'cleaning_reboot'))
  115                 self.assertEqual(
  116                     task.node.driver_internal_info.get(
  117                         'skip_current_clean_step'), False)
  118             else:
  119                 self.assertTrue(
  120                     task.node.driver_internal_info.get(
  121                         'deployment_reboot'))
  122                 self.assertEqual(
  123                     task.node.driver_internal_info.get(
  124                         'skip_current_deploy_step'), False)
  125             mock_reboot.assert_called_once_with(task, states.REBOOT)
  126 
  127     def test__prepare_for_read_raid_delete_raid_cleaning(self):
  128         self.node.clean_step = {'step': 'create_configuration',
  129                                 'interface': 'raid'}
  130         self.node.save()
  131         self._test__prepare_for_read_raid_delete_raid()
  132 
  133     def test__prepare_for_read_raid_delete_raid_deploying(self):
  134         self.node.deploy_step = {'step': 'create_configuration',
  135                                  'interface': 'raid'}
  136         self.node.save()
  137         self._test__prepare_for_read_raid_delete_raid()
  138 
  139     @mock.patch.object(ilo_raid.Ilo5RAID, '_prepare_for_read_raid',
  140                        autospec=True)
  141     @mock.patch.object(raid, 'filter_target_raid_config', autospec=True)
  142     @mock.patch.object(ilo_common, 'get_ilo_object', autospec=True)
  143     def _test_create_configuration(
  144             self, ilo_mock, filter_target_raid_config_mock, prepare_raid_mock):
  145         ilo_mock_object = ilo_mock.return_value
  146         with task_manager.acquire(self.context, self.node.uuid) as task:
  147             filter_target_raid_config_mock.return_value = (
  148                 self.target_raid_config)
  149             result = task.driver.raid.create_configuration(task)
  150             prepare_raid_mock.assert_called_once_with(
  151                 mock.ANY, task, 'create_raid')
  152             if task.node.clean_step:
  153                 self.assertEqual(states.CLEANWAIT, result)
  154             else:
  155                 self.assertEqual(states.DEPLOYWAIT, result)
  156         (ilo_mock_object.create_raid_configuration.
  157          assert_called_once_with(self.target_raid_config))
  158 
  159     def test_create_configuration_cleaning(self):
  160         self.node.clean_step = {'step': 'create_configuration',
  161                                 'interface': 'raid'}
  162         self.node.save()
  163         self._test_create_configuration()
  164 
  165     def test_create_configuration_deploying(self):
  166         self.node.deploy_step = {'step': 'create_configuration',
  167                                  'interface': 'raid'}
  168         self.node.save()
  169         self._test_create_configuration()
  170 
  171     @mock.patch.object(raid, 'update_raid_info', autospec=True)
  172     @mock.patch.object(raid, 'filter_target_raid_config', autospec=True)
  173     @mock.patch.object(ilo_common, 'get_ilo_object', autospec=True)
  174     def _test_create_configuration_with_read_raid(
  175             self, ilo_mock, filter_target_raid_config_mock, update_raid_mock):
  176         raid_conf = {u'logical_disks':
  177                      [{u'size_gb': 89,
  178                        u'physical_disks': [u'5I:1:1'],
  179                        u'raid_level': u'0',
  180                        u'root_device_hint': {u'wwn': u'0x600508b1001c7e87'},
  181                        u'controller': u'Smart Array P822 in Slot 1',
  182                        u'volume_name': u'0006EB7BPDVTF0BRH5L0EAEDDA'}]
  183                      }
  184         ilo_mock_object = ilo_mock.return_value
  185         driver_internal_info = self.node.driver_internal_info
  186         driver_internal_info['ilo_raid_create_in_progress'] = True
  187         if self.node.clean_step:
  188             driver_internal_info['skip_current_clean_step'] = False
  189             driver_internal_info['cleaning_reboot'] = True
  190         else:
  191             driver_internal_info['skip_current_deploy_step'] = False
  192             driver_internal_info['deployment_reboot'] = True
  193         self.node.driver_internal_info = driver_internal_info
  194         self.node.save()
  195 
  196         with task_manager.acquire(self.context, self.node.uuid) as task:
  197             filter_target_raid_config_mock.return_value = (
  198                 self.target_raid_config)
  199             ilo_mock_object.read_raid_configuration.return_value = raid_conf
  200             task.driver.raid.create_configuration(task)
  201             update_raid_mock.assert_called_once_with(task.node, raid_conf)
  202             self.assertNotIn('ilo_raid_create_in_progress',
  203                              task.node.driver_internal_info)
  204             if task.node.clean_step:
  205                 self.assertNotIn('skip_current_clean_step',
  206                                  task.node.driver_internal_info)
  207 
  208     def test_create_configuration_with_read_raid_cleaning(self):
  209         self.node.clean_step = {'step': 'create_configuration',
  210                                 'interface': 'raid'}
  211         self.node.save()
  212         self._test_create_configuration_with_read_raid()
  213 
  214     def test_create_configuration_with_read_raid_deploying(self):
  215         self.node.deploy_step = {'step': 'create_configuration',
  216                                  'interface': 'raid'}
  217         self.node.save()
  218         self._test_create_configuration_with_read_raid()
  219 
  220     @mock.patch.object(raid, 'filter_target_raid_config', autospec=True)
  221     @mock.patch.object(ilo_common, 'get_ilo_object', autospec=True)
  222     def _test_create_configuration_with_read_raid_failed(
  223             self, ilo_mock, filter_target_raid_config_mock):
  224         raid_conf = {u'logical_disks': []}
  225         driver_internal_info = self.node.driver_internal_info
  226         driver_internal_info['ilo_raid_create_in_progress'] = True
  227         driver_internal_info['skip_current_clean_step'] = False
  228         self.node.driver_internal_info = driver_internal_info
  229         self.node.save()
  230         ilo_mock_object = ilo_mock.return_value
  231         if self.node.clean_step:
  232             exept = exception.NodeCleaningFailure
  233         else:
  234             exept = exception.InstanceDeployFailure
  235         with task_manager.acquire(self.context, self.node.uuid) as task:
  236             filter_target_raid_config_mock.return_value = (
  237                 self.target_raid_config)
  238             ilo_mock_object.read_raid_configuration.return_value = raid_conf
  239             self.assertRaises(exept,
  240                               task.driver.raid.create_configuration, task)
  241             self.assertNotIn('ilo_raid_create_in_progress',
  242                              task.node.driver_internal_info)
  243             if task.node.clean_step:
  244                 self.assertNotIn('skip_current_clean_step',
  245                                  task.node.driver_internal_info)
  246             else:
  247                 self.assertNotIn('skip_current_deploy_step',
  248                                  task.node.driver_internal_info)
  249 
  250     def test_create_configuration_with_read_raid_failed_cleaning(self):
  251         self.node.clean_step = {'step': 'create_configuration',
  252                                 'interface': 'raid'}
  253         self.node.save()
  254         self._test_create_configuration_with_read_raid_failed()
  255 
  256     def test_create_configuration_with_read_raid_failed_deploying(self):
  257         self.node.deploy_step = {'step': 'create_configuration',
  258                                  'interface': 'raid'}
  259         self.node.save()
  260         self._test_create_configuration_with_read_raid_failed()
  261 
  262     @mock.patch.object(raid, 'filter_target_raid_config', autospec=True)
  263     @mock.patch.object(ilo_common, 'get_ilo_object', autospec=True)
  264     def _test_create_configuration_empty_target_raid_config(
  265             self, ilo_mock, filter_target_raid_config_mock):
  266         self.node.target_raid_config = {}
  267         self.node.save()
  268         ilo_mock_object = ilo_mock.return_value
  269         with task_manager.acquire(self.context, self.node.uuid) as task:
  270             msg = "Node %s has no target RAID configuration" % self.node.uuid
  271             filter_target_raid_config_mock.side_effect = (
  272                 exception.MissingParameterValue(msg))
  273             self.assertRaises(exception.MissingParameterValue,
  274                               task.driver.raid.create_configuration, task)
  275         self.assertFalse(ilo_mock_object.create_raid_configuration.called)
  276 
  277     def test_create_configuration_empty_target_raid_config_cleaning(self):
  278         self.node.clean_step = {'step': 'create_configuration',
  279                                 'interface': 'raid'}
  280         self.node.save()
  281         self._test_create_configuration_empty_target_raid_config()
  282 
  283     def test_create_configuration_empty_target_raid_config_deploying(self):
  284         self.node.deploy_step = {'step': 'create_configuration',
  285                                  'interface': 'raid'}
  286         self.node.save()
  287         self._test_create_configuration_empty_target_raid_config()
  288 
  289     @mock.patch.object(ilo_raid.Ilo5RAID, '_prepare_for_read_raid',
  290                        autospec=True)
  291     @mock.patch.object(raid, 'filter_target_raid_config', autospec=True)
  292     @mock.patch.object(ilo_common, 'get_ilo_object', autospec=True)
  293     def _test_create_configuration_skip_root(
  294             self, ilo_mock, filter_target_raid_config_mock,
  295             prepare_raid_mock):
  296         ilo_mock_object = ilo_mock.return_value
  297         with task_manager.acquire(self.context, self.node.uuid) as task:
  298             exp_target_raid_config = {
  299                 "logical_disks": [
  300                     {'size_gb': 200, 'raid_level': 5}
  301                 ]}
  302             filter_target_raid_config_mock.return_value = (
  303                 exp_target_raid_config)
  304             result = task.driver.raid.create_configuration(
  305                 task, create_root_volume=False)
  306             (ilo_mock_object.create_raid_configuration.
  307              assert_called_once_with(exp_target_raid_config))
  308             if task.node.clean_step:
  309                 self.assertEqual(states.CLEANWAIT, result)
  310             else:
  311                 self.assertEqual(states.DEPLOYWAIT, result)
  312             prepare_raid_mock.assert_called_once_with(
  313                 mock.ANY, task, 'create_raid')
  314             self.assertEqual(
  315                 exp_target_raid_config,
  316                 task.node.driver_internal_info['target_raid_config'])
  317 
  318     def test_create_configuration_skip_root_cleaning(self):
  319         self.node.clean_step = {'step': 'create_configuration',
  320                                 'interface': 'raid'}
  321         self.node.save()
  322         self._test_create_configuration_skip_root()
  323 
  324     def test_create_configuration_skip_root_deploying(self):
  325         self.node.deploy_step = {'step': 'create_configuration',
  326                                  'interface': 'raid'}
  327         self.node.save()
  328         self._test_create_configuration_skip_root()
  329 
  330     @mock.patch.object(ilo_raid.Ilo5RAID, '_prepare_for_read_raid',
  331                        autospec=True)
  332     @mock.patch.object(raid, 'filter_target_raid_config', autospec=True)
  333     @mock.patch.object(ilo_common, 'get_ilo_object', autospec=True)
  334     def _test_create_configuration_skip_non_root(
  335             self, ilo_mock, filter_target_raid_config_mock, prepare_raid_mock):
  336         ilo_mock_object = ilo_mock.return_value
  337         with task_manager.acquire(self.context, self.node.uuid) as task:
  338             exp_target_raid_config = {
  339                 "logical_disks": [
  340                     {'size_gb': 200, 'raid_level': 0, 'is_root_volume': True}
  341                 ]}
  342             filter_target_raid_config_mock.return_value = (
  343                 exp_target_raid_config)
  344             result = task.driver.raid.create_configuration(
  345                 task, create_nonroot_volumes=False)
  346             (ilo_mock_object.create_raid_configuration.
  347              assert_called_once_with(exp_target_raid_config))
  348             prepare_raid_mock.assert_called_once_with(
  349                 mock.ANY, task, 'create_raid')
  350             if task.node.clean_step:
  351                 self.assertEqual(states.CLEANWAIT, result)
  352             else:
  353                 self.assertEqual(states.DEPLOYWAIT, result)
  354             self.assertEqual(
  355                 exp_target_raid_config,
  356                 task.node.driver_internal_info['target_raid_config'])
  357 
  358     def test_create_configuration_skip_non_root_cleaning(self):
  359         self.node.clean_step = {'step': 'create_configuration',
  360                                 'interface': 'raid'}
  361         self.node.save()
  362         self._test_create_configuration_skip_non_root()
  363 
  364     def test_create_configuration_skip_non_root_deploying(self):
  365         self.node.deploy_step = {'step': 'create_configuration',
  366                                  'interface': 'raid'}
  367         self.node.save()
  368         self._test_create_configuration_skip_non_root()
  369 
  370     @mock.patch.object(raid, 'filter_target_raid_config', autospec=True)
  371     @mock.patch.object(ilo_common, 'get_ilo_object', autospec=True)
  372     def _test_create_configuration_skip_root_skip_non_root(
  373             self, ilo_mock, filter_target_raid_config_mock):
  374         ilo_mock_object = ilo_mock.return_value
  375         with task_manager.acquire(self.context, self.node.uuid) as task:
  376             msg = "Node %s has no target RAID configuration" % self.node.uuid
  377             filter_target_raid_config_mock.side_effect = (
  378                 exception.MissingParameterValue(msg))
  379             self.assertRaises(
  380                 exception.MissingParameterValue,
  381                 task.driver.raid.create_configuration,
  382                 task, False, False)
  383             self.assertFalse(ilo_mock_object.create_raid_configuration.called)
  384 
  385     def test_create_configuration_skip_root_skip_non_root_cleaning(self):
  386         self.node.clean_step = {'step': 'create_configuration',
  387                                 'interface': 'raid'}
  388         self.node.save()
  389         self._test_create_configuration_skip_root_skip_non_root()
  390 
  391     def test_create_configuration_skip_root_skip_non_root_deploying(self):
  392         self.node.deploy_step = {'step': 'create_configuration',
  393                                  'interface': 'raid'}
  394         self.node.save()
  395         self._test_create_configuration_skip_root_skip_non_root()
  396 
  397     @mock.patch.object(manager_utils, 'cleaning_error_handler',
  398                        autospec=True)
  399     @mock.patch.object(manager_utils, 'deploying_error_handler',
  400                        autospec=True)
  401     @mock.patch.object(ilo_common, 'get_ilo_object', autospec=True)
  402     def _test_create_configuration_ilo_error(self, ilo_mock,
  403                                              deploy_err_handler_mock,
  404                                              clean_err_handler_mock):
  405         ilo_mock_object = ilo_mock.return_value
  406         exc = ilo_error.IloError('error')
  407         ilo_mock_object.create_raid_configuration.side_effect = exc
  408         with task_manager.acquire(self.context, self.node.uuid) as task:
  409             task.driver.raid.create_configuration(
  410                 task, create_nonroot_volumes=False)
  411             self.assertNotIn('ilo_raid_create_in_progress',
  412                              task.node.driver_internal_info)
  413             if task.node.clean_step:
  414                 self.assertNotIn('skip_current_clean_step',
  415                                  task.node.driver_internal_info)
  416                 clean_err_handler_mock.assert_called_once_with(
  417                     task,
  418                     ("RAID configuration job failed for node %s. Message: "
  419                      "'Failed to create raid configuration on node %s'." %
  420                      (self.node.uuid, self.node.uuid)),
  421                     'Failed to create raid configuration '
  422                     'on node %s' % self.node.uuid)
  423             else:
  424                 self.assertNotIn('skip_current_deploy_step',
  425                                  task.node.driver_internal_info)
  426                 deploy_err_handler_mock.assert_called_once_with(
  427                     task,
  428                     ("RAID configuration job failed for node %s. Message: "
  429                      "'Failed to create raid configuration on node %s'." %
  430                      (self.node.uuid, self.node.uuid)),
  431                     'Failed to create raid configuration '
  432                     'on node %s' % self.node.uuid)
  433 
  434     def test_create_configuration_ilo_error_cleaning(self):
  435         self.node.clean_step = {'step': 'create_configuration',
  436                                 'interface': 'raid'}
  437         self.node.provision_state = states.CLEANING
  438         self.node.save()
  439         self._test_create_configuration_ilo_error()
  440 
  441     def test_create_configuration_ilo_error_cleaning_deploying(self):
  442         self.node.deploy_step = {'step': 'create_configuration',
  443                                  'interface': 'raid'}
  444         self.node.provision_state = states.DEPLOYING
  445         self.node.save()
  446         self._test_create_configuration_ilo_error()
  447 
  448     @mock.patch.object(ilo_raid.Ilo5RAID, '_prepare_for_read_raid',
  449                        autospec=True)
  450     @mock.patch.object(ilo_common, 'get_ilo_object', autospec=True)
  451     def _test_delete_configuration(self, ilo_mock, prepare_raid_mock):
  452         ilo_mock_object = ilo_mock.return_value
  453         with task_manager.acquire(self.context, self.node.uuid) as task:
  454             result = task.driver.raid.delete_configuration(task)
  455             if task.node.clean_step:
  456                 self.assertEqual(states.CLEANWAIT, result)
  457             else:
  458                 self.assertEqual(states.DEPLOYWAIT, result)
  459         ilo_mock_object.delete_raid_configuration.assert_called_once_with()
  460         prepare_raid_mock.assert_called_once_with(mock.ANY, task,
  461                                                   'delete_raid')
  462 
  463     def test_delete_configuration_cleaning(self):
  464         self.node.clean_step = {'step': 'create_configuration',
  465                                 'interface': 'raid'}
  466         self.node.save()
  467         self._test_delete_configuration()
  468 
  469     def test_delete_configuration_deploying(self):
  470         self.node.deploy_step = {'step': 'create_configuration',
  471                                  'interface': 'raid'}
  472         self.node.save()
  473         self._test_delete_configuration()
  474 
  475     @mock.patch.object(ilo_raid.LOG, 'info', spec_set=True,
  476                        autospec=True)
  477     @mock.patch.object(ilo_raid.Ilo5RAID, '_prepare_for_read_raid',
  478                        autospec=True)
  479     @mock.patch.object(ilo_common, 'get_ilo_object', autospec=True)
  480     def _test_delete_configuration_no_logical_drive(
  481             self, ilo_mock, prepare_raid_mock, log_mock):
  482         ilo_mock_object = ilo_mock.return_value
  483         exc = ilo_error.IloLogicalDriveNotFoundError('No logical drive found')
  484         with task_manager.acquire(self.context, self.node.uuid) as task:
  485             ilo_mock_object.delete_raid_configuration.side_effect = exc
  486             task.driver.raid.delete_configuration(task)
  487             self.assertTrue(log_mock.called)
  488 
  489     def test_delete_configuration_no_logical_drive_cleaning(self):
  490         self.node.clean_step = {'step': 'create_configuration',
  491                                 'interface': 'raid'}
  492         self.node.save()
  493         self._test_delete_configuration_no_logical_drive()
  494 
  495     def test_delete_configuration_no_logical_drive_deploying(self):
  496         self.node.deploy_step = {'step': 'create_configuration',
  497                                  'interface': 'raid'}
  498         self.node.save()
  499         self._test_delete_configuration_no_logical_drive()
  500 
  501     @mock.patch.object(ilo_common, 'get_ilo_object', autospec=True)
  502     def _test_delete_configuration_with_read_raid(self, ilo_mock):
  503         raid_conf = {u'logical_disks': []}
  504         driver_internal_info = self.node.driver_internal_info
  505         driver_internal_info['ilo_raid_delete_in_progress'] = True
  506         driver_internal_info['skip_current_clean_step'] = False
  507         self.node.driver_internal_info = driver_internal_info
  508         self.node.save()
  509         ilo_mock_object = ilo_mock.return_value
  510         if self.node.clean_step:
  511             skip_field_name = 'skip_current_clean_step'
  512         else:
  513             skip_field_name = 'skip_current_deploy_step'
  514         with task_manager.acquire(self.context, self.node.uuid) as task:
  515             ilo_mock_object.read_raid_configuration.return_value = raid_conf
  516             task.driver.raid.delete_configuration(task)
  517             self.assertEqual(self.node.raid_config, {})
  518             self.assertNotIn('ilo_raid_delete_in_progress',
  519                              task.node.driver_internal_info)
  520             self.assertNotIn(skip_field_name,
  521                              task.node.driver_internal_info)
  522 
  523     def test_delete_configuration_with_read_raid_cleaning(self):
  524         self.node.clean_step = {'step': 'create_configuration',
  525                                 'interface': 'raid'}
  526         self.node.save()
  527         self._test_delete_configuration_with_read_raid()
  528 
  529     def test_delete_configuration_with_read_raid_deploying(self):
  530         self.node.deploy_step = {'step': 'create_configuration',
  531                                  'interface': 'raid'}
  532         self.node.save()
  533         self._test_delete_configuration_with_read_raid()
  534 
  535     @mock.patch.object(ilo_common, 'get_ilo_object', autospec=True)
  536     def _test_delete_configuration_with_read_raid_failed(self, ilo_mock):
  537         raid_conf = {u'logical_disks': [{'size_gb': 200,
  538                                          'raid_level': 0,
  539                                          'is_root_volume': True}]}
  540         driver_internal_info = self.node.driver_internal_info
  541         driver_internal_info['ilo_raid_delete_in_progress'] = True
  542         driver_internal_info['skip_current_clean_step'] = False
  543         self.node.driver_internal_info = driver_internal_info
  544         self.node.save()
  545         ilo_mock_object = ilo_mock.return_value
  546         if self.node.clean_step:
  547             exept = exception.NodeCleaningFailure
  548         else:
  549             exept = exception.InstanceDeployFailure
  550         with task_manager.acquire(self.context, self.node.uuid) as task:
  551             ilo_mock_object.read_raid_configuration.return_value = raid_conf
  552             self.assertRaises(exept,
  553                               task.driver.raid.delete_configuration, task)
  554             self.assertNotIn('ilo_raid_delete_in_progress',
  555                              task.node.driver_internal_info)
  556             if task.node.clean_step:
  557                 self.assertNotIn('skip_current_clean_step',
  558                                  task.node.driver_internal_info)
  559             else:
  560                 self.assertNotIn('skip_current_deploy_step',
  561                                  task.node.driver_internal_info)
  562 
  563     def test_delete_configuration_with_read_raid_failed_cleaning(self):
  564         self.node.clean_step = {'step': 'create_configuration',
  565                                 'interface': 'raid'}
  566         self.node.save()
  567         self._test_delete_configuration_with_read_raid_failed()
  568 
  569     def test_delete_configuration_with_read_raid_failed_deploying(self):
  570         self.node.deploy_step = {'step': 'create_configuration',
  571                                  'interface': 'raid'}
  572         self.node.save()
  573         self._test_delete_configuration_with_read_raid_failed()
  574 
  575     @mock.patch.object(ilo_raid.Ilo5RAID, '_set_step_failed', autospec=True)
  576     @mock.patch.object(ilo_common, 'get_ilo_object', autospec=True)
  577     def _test_delete_configuration_ilo_error(self, ilo_mock,
  578                                              set_step_failed_mock):
  579         ilo_mock_object = ilo_mock.return_value
  580         exc = ilo_error.IloError('error')
  581         ilo_mock_object.delete_raid_configuration.side_effect = exc
  582         with task_manager.acquire(self.context, self.node.uuid) as task:
  583             task.driver.raid.delete_configuration(task)
  584             ilo_mock_object.delete_raid_configuration.assert_called_once_with()
  585             self.assertNotIn('ilo_raid_delete_in_progress',
  586                              task.node.driver_internal_info)
  587             self.assertNotIn('cleaning_reboot',
  588                              task.node.driver_internal_info)
  589             self.assertNotIn('skip_current_clean_step',
  590                              task.node.driver_internal_info)
  591             set_step_failed_mock.assert_called_once_with(
  592                 mock.ANY,
  593                 task,
  594                 'Failed to delete raid configuration '
  595                 'on node %s' % self.node.uuid, exc)
  596 
  597     def test_delete_configuration_ilo_error_cleaning(self):
  598         self.node.clean_step = {'step': 'create_configuration',
  599                                 'interface': 'raid'}
  600         self.node.save()
  601         self._test_delete_configuration_ilo_error()
  602 
  603     def test_delete_configuration_ilo_error_deploying(self):
  604         self.node.deploy_step = {'step': 'create_configuration',
  605                                  'interface': 'raid'}
  606         self.node.save()
  607         self._test_delete_configuration_ilo_error()