def test_filter_target_raid_config_skip_nonroot(self): result = raid.filter_target_raid_config( self.node, create_nonroot_volumes=False) exp_target_raid_config = { "logical_disks": [{'size_gb': 200, 'raid_level': 0, 'is_root_volume': True}]} self.assertEqual(exp_target_raid_config, result)
def test_filter_target_raid_config_skip_root(self): result = raid.filter_target_raid_config(self.node, create_root_volume=False) exp_target_raid_config = { "logical_disks": [{ 'size_gb': 200, 'raid_level': 5 }] } self.assertEqual(exp_target_raid_config, result)
def create_configuration(self, task, create_root_volume=True, create_nonroot_volumes=True, delete_existing=False): """Create a RAID configuration. This method creates a RAID configuration on the given node. :param task: a TaskManager instance. :param create_root_volume: If True, a root volume is created during RAID configuration. Otherwise, no root volume is created. Default is True. :param create_nonroot_volumes: If True, non-root volumes are created. If False, no non-root volumes are created. Default is True. :param delete_existing: Setting this to True indicates to delete RAID configuration prior to creating the new configuration. Default is False. :raises: MissingParameterValue, if node.target_raid_config is missing or empty after skipping root volume and/or non-root volumes. :raises: IBMCError, on failure to execute step. """ node = task.node raid_config = raid.filter_target_raid_config( node, create_root_volume=create_root_volume, create_nonroot_volumes=create_nonroot_volumes) LOG.info( _("Invoke RAID create_configuration step for node %s(uuid). " "Current provision state is: %(status)s. " "Target RAID configuration is: %(config)s."), { 'uuid': node.uuid, 'status': node.provision_state, 'target': raid_config }) # cache current raid config to node's driver_internal_info node.driver_internal_info['raid_config'] = raid_config node.save() # delete exist volumes if necessary if delete_existing: self._delete_raid_configuration(task) # create raid configuration logical_disks = raid_config.get('logical_disks', []) self._create_raid_configuration(task, logical_disks) LOG.info(_("Succeed to create raid configuration on node %s."), task.node.uuid)
def create_configuration(self, task, create_root_volume=True, create_nonroot_volumes=True): """Create a RAID configuration on a bare metal using agent ramdisk. This method creates a RAID configuration on the given node. :param task: a TaskManager instance. :param create_root_volume: If True, a root volume is created during RAID configuration. Otherwise, no root volume is created. Default is True. :param create_nonroot_volumes: If True, non-root volumes are created. If False, no non-root volumes are created. Default is True. :returns: states.CLEANWAIT if operation was successfully invoked. :raises: MissingParameterValue, if node.target_raid_config is missing or was found to be empty after skipping root volume and/or non-root volumes. """ node = task.node LOG.debug( "Agent RAID create_configuration invoked for node %(node)s " "with create_root_volume=%(create_root_volume)s and " "create_nonroot_volumes=%(create_nonroot_volumes)s with the " "following target_raid_config: %(target_raid_config)s.", { 'node': node.uuid, 'create_root_volume': create_root_volume, 'create_nonroot_volumes': create_nonroot_volumes, 'target_raid_config': node.target_raid_config }) target_raid_config = raid.filter_target_raid_config( node, create_root_volume=create_root_volume, create_nonroot_volumes=create_nonroot_volumes) # Rewrite it back to the node object, but no need to save it as # we need to just send this to the agent ramdisk. node.driver_internal_info['target_raid_config'] = target_raid_config LOG.debug( "Calling agent RAID create_configuration for node %(node)s " "with the following target RAID configuration: %(target)s", { 'node': node.uuid, 'target': target_raid_config }) step = node.clean_step return agent_base.execute_clean_step(task, step)
def test_filter_target_raid_config(self): result = raid.filter_target_raid_config(self.node) self.assertEqual(self.node.target_raid_config, result)
def create_configuration(self, task, create_root_volume=True, create_nonroot_volumes=True): """Create a RAID configuration on a bare metal using agent ramdisk. This method creates a RAID configuration on the given node. :param task: a TaskManager instance. :param create_root_volume: If True, a root volume is created during RAID configuration. Otherwise, no root volume is created. Default is True. :param create_nonroot_volumes: If True, non-root volumes are created. If False, no non-root volumes are created. Default is True. :raises: MissingParameterValue, if node.target_raid_config is missing or was found to be empty after skipping root volume and/or non-root volumes. :raises: NodeCleaningFailure, on failure to execute clean step. :raises: InstanceDeployFailure, on failure to execute deploy step. """ node = task.node target_raid_config = raid.filter_target_raid_config( node, create_root_volume=create_root_volume, create_nonroot_volumes=create_nonroot_volumes) driver_internal_info = node.driver_internal_info driver_internal_info['target_raid_config'] = target_raid_config node.driver_internal_info = driver_internal_info node.save() LOG.debug( "Calling OOB RAID create_configuration for node %(node)s " "with the following target RAID configuration: %(target)s", { 'node': node.uuid, 'target': target_raid_config }) ilo_object = ilo_common.get_ilo_object(node) try: # Raid configuration in progress, checking status if not driver_internal_info.get('ilo_raid_create_in_progress'): ilo_object.create_raid_configuration(target_raid_config) self._prepare_for_read_raid(task, 'create_raid') return deploy_utils.get_async_step_return_state(node) else: # Raid configuration is done, updating raid_config raid_conf = (ilo_object.read_raid_configuration( raid_config=target_raid_config)) fields = ['ilo_raid_create_in_progress'] if node.clean_step: fields.append('skip_current_clean_step') else: fields.append('skip_current_deploy_step') self._pop_driver_internal_values(task, *fields) if len(raid_conf['logical_disks']): raid.update_raid_info(node, raid_conf) LOG.debug("Node %(uuid)s raid create clean step is done.", {'uuid': node.uuid}) else: # Raid configuration failed msg = (_("Step create_configuration failed " "on node %(node)s with error: " "Unable to create raid") % { 'node': node.uuid }) if node.clean_step: raise exception.NodeCleaningFailure(msg) else: raise exception.InstanceDeployFailure(reason=msg) except ilo_error.IloError as ilo_exception: operation = (_("Failed to create raid configuration on node %s") % node.uuid) fields = ['ilo_raid_create_in_progress'] if node.clean_step: fields.append('skip_current_clean_step') else: fields.append('skip_current_deploy_step') self._pop_driver_internal_values(task, *fields) self._set_step_failed(task, operation, ilo_exception)
def create_configuration(self, task, create_root_volume=True, create_nonroot_volumes=True): """Create a RAID configuration on a bare metal using agent ramdisk. This method creates a RAID configuration on the given node. :param task: a TaskManager instance. :param create_root_volume: If True, a root volume is created during RAID configuration. Otherwise, no root volume is created. Default is True. :param create_nonroot_volumes: If True, non-root volumes are created. If False, no non-root volumes are created. Default is True. :raises: MissingParameterValue, if node.target_raid_config is missing or was found to be empty after skipping root volume and/or non-root volumes. :raises: NodeCleaningFailure, on failure to execute step. """ node = task.node target_raid_config = raid.filter_target_raid_config( node, create_root_volume=create_root_volume, create_nonroot_volumes=create_nonroot_volumes) driver_internal_info = node.driver_internal_info driver_internal_info['target_raid_config'] = target_raid_config LOG.debug("Calling OOB RAID create_configuration for node %(node)s " "with the following target RAID configuration: %(target)s", {'node': node.uuid, 'target': target_raid_config}) ilo_object = ilo_common.get_ilo_object(node) try: # Raid configuration in progress, checking status if not driver_internal_info.get('ilo_raid_create_in_progress'): ilo_object.create_raid_configuration(target_raid_config) self._prepare_for_read_raid(task, 'create_raid') return states.CLEANWAIT else: # Raid configuration is done, updating raid_config raid_conf = ( ilo_object.read_raid_configuration( raid_config=target_raid_config)) if len(raid_conf['logical_disks']): raid.update_raid_info(node, raid_conf) LOG.debug("Node %(uuid)s raid create clean step is done.", {'uuid': node.uuid}) self._pop_driver_internal_values( task, 'ilo_raid_create_in_progress', 'cleaning_reboot', 'skip_current_clean_step') node.driver_internal_info = driver_internal_info node.save() else: # Raid configuration failed msg = "Unable to create raid" self._pop_driver_internal_values( task, 'ilo_raid_create_in_progress', 'cleaning_reboot', 'skip_current_clean_step') node.driver_internal_info = driver_internal_info node.save() raise exception.NodeCleaningFailure( "Clean step create_configuration failed " "on node %(node)s with error: %(err)s" % {'node': node.uuid, 'err': msg}) except ilo_error.IloError as ilo_exception: operation = (_("Failed to create raid configuration on node %s") % node.uuid) self._pop_driver_internal_values(task, 'ilo_raid_create_in_progress', 'cleaning_reboot', 'skip_current_clean_step') node.driver_internal_info = driver_internal_info node.save() self._set_clean_failed(task, operation, ilo_exception)
def test_filter_target_raid_config(self): result = raid.filter_target_raid_config(self.node) self.assertEqual(self.node.target_raid_config, result)