def prepare(self, task): """Prepare the deployment environment for this task's node. If the node's 'capabilities' property includes a boot_mode, that boot mode will be applied for the node. Otherwise, the existing boot mode of the node is used in the node's 'capabilities' property. PXEDeploys' prepare method is then called, to prepare the deploy environment for the node :param task: a TaskManager instance containing the node to act on. :raises: IloOperationError, if some operation on iLO failed. :raises: InvalidParameterValue, if some information is invalid. """ ilo_common.update_boot_mode(task) # Check if 'boot_option' is compatible with 'boot_mode' and image. # Whole disk image deploy is not supported in UEFI boot mode if # 'boot_option' is not 'local'. # If boot_mode is not set in the node properties/capabilities then # PXEDeploy.validate() would pass. # Boot mode gets updated in prepare stage. It is possible that the # deploy boot mode is 'uefi' after call to update_boot_mode(). # Hence a re-check is required here. pxe.validate_boot_option_for_uefi(task.node) super(IloPXEDeploy, self).prepare(task)
def _prepare_node_for_deploy(task): """Common preparatory steps for all iLO drivers. This method performs common preparatory steps required for all drivers. 1. Power off node 2. Disables secure boot, if it is in enabled state. 3. Updates boot_mode capability to 'uefi' if secure boot is requested. 4. Changes boot mode of the node if secure boot is disabled currently. :param task: a TaskManager instance containing the node to act on. :raises: IloOperationError, if some operation on iLO failed. """ manager_utils.node_power_action(task, states.POWER_OFF) # Boot mode can be changed only if secure boot is in disabled state. # secure boot and boot mode cannot be changed together. change_boot_mode = True # Disable secure boot on the node if it is in enabled state. if _disable_secure_boot(task): change_boot_mode = False if change_boot_mode: ilo_common.update_boot_mode(task) else: # Need to update boot mode that will be used during deploy, if one is # not provided. # Since secure boot was disabled, we are in 'uefi' boot mode. if deploy_utils.get_boot_mode_for_deploy(task.node) is None: instance_info = task.node.instance_info instance_info['deploy_boot_mode'] = 'uefi' task.node.instance_info = instance_info task.node.save()
def test_update_boot_mode_prop_boot_mode_exist(self, set_boot_mode_mock): properties = {"capabilities": "boot_mode:uefi"} with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: task.node.properties = properties ilo_common.update_boot_mode(task) set_boot_mode_mock.assert_called_once_with(task.node, "uefi")
def test_update_boot_mode_capabilities_exist(self, set_boot_mode_mock): with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: task.node.properties['capabilities'] = 'boot_mode:bios' ilo_common.update_boot_mode(task) set_boot_mode_mock.assert_called_once_with(task.node, 'bios')
def test_update_boot_mode_instance_info_exists(self, set_boot_mode_mock): with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: task.node.instance_info['deploy_boot_mode'] = 'bios' ilo_common.update_boot_mode(task) set_boot_mode_mock.assert_called_once_with(task.node, 'bios')
def pass_deploy_info(self, task, **kwargs): """Continues the iSCSI deployment from where ramdisk left off. This method continues the iSCSI deployment from the conductor node and writes the deploy image to the bare metal's disk. After that, it does the following depending on boot_option for deploy: - If the boot_option requested for this deploy is 'local', then it sets the node to boot from disk (ramdisk installs the boot loader present within the image to the bare metal's disk). - If the boot_option requested is 'netboot' or no boot_option is requested, it finds/creates the boot ISO to boot the instance image, attaches the boot ISO to the bare metal and then sets the node to boot from CDROM. :param task: a TaskManager instance containing the node to act on. :param kwargs: kwargs containing parameters for iSCSI deployment. :raises: InvalidState """ node = task.node task.process_event('resume') iwdi = node.driver_internal_info.get('is_whole_disk_image') ilo_common.cleanup_vmedia_boot(task) uuid_dict = iscsi_deploy.continue_deploy(task, **kwargs) root_uuid_or_disk_id = uuid_dict.get( 'root uuid', uuid_dict.get('disk identifier')) try: # Set boot mode ilo_common.update_boot_mode(task) # Need to enable secure boot, if being requested _update_secure_boot_mode(task, True) # For iscsi_ilo driver, we boot from disk every time if the image # deployed is a whole disk image. if iscsi_deploy.get_boot_option(node) == "local" or iwdi: manager_utils.node_set_boot_device(task, boot_devices.DISK, persistent=True) # Ask the ramdisk to install bootloader and # wait for the call-back through the vendor passthru # 'pass_bootloader_install_info', if it's not a whole # disk image. if not iwdi: deploy_utils.notify_ramdisk_to_proceed(kwargs['address']) task.process_event('wait') return else: self._configure_vmedia_boot(task, root_uuid_or_disk_id) except Exception as e: LOG.error(_LE('Deploy failed for instance %(instance)s. ' 'Error: %(error)s'), {'instance': node.instance_uuid, 'error': e}) msg = _('Failed to continue iSCSI deployment.') deploy_utils.set_failed_state(task, msg) else: iscsi_deploy.finish_deploy(task, kwargs.get('address'))
def test_update_boot_mode_use_def_boot_mode(self, set_boot_mode_mock): self.config(default_boot_mode='bios', group='ilo') with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: ilo_common.update_boot_mode(task) set_boot_mode_mock.assert_called_once_with(task.node, 'bios') self.assertEqual('bios', task.node.instance_info['deploy_boot_mode'])
def test_update_boot_mode_prop_boot_mode_exist(self, set_boot_mode_mock): properties = {'capabilities': 'boot_mode:uefi'} with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: task.node.properties = properties ilo_common.update_boot_mode(task) set_boot_mode_mock.assert_called_once_with(task.node, 'uefi')
def pass_deploy_info(self, task, **kwargs): LOG.debug("Pass deploy info for the deployment on node %s", task.node.uuid) manager_utils.node_set_boot_device(task, boot_devices.PXE, persistent=True) # Set boot mode ilo_common.update_boot_mode(task) # Need to enable secure boot, if being requested _update_secure_boot_mode(task, True) super(IloPXEVendorPassthru, self).pass_deploy_info(task, **kwargs)
def test_update_boot_mode(self, get_ilo_object_mock): ilo_mock_obj = get_ilo_object_mock.return_value ilo_mock_obj.get_pending_boot_mode.return_value = "LEGACY" with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: ilo_common.update_boot_mode(task) get_ilo_object_mock.assert_called_once_with(task.node) ilo_mock_obj.get_pending_boot_mode.assert_called_once_with() self.assertEqual("bios", task.node.instance_info["deploy_boot_mode"])
def continue_deploy(self, task, **kwargs): """Method invoked when deployed with the IPA ramdisk. This method is invoked during a heartbeat from an agent when the node is in wait-call-back state. This updates boot mode and secure boot settings, if required. """ ilo_common.update_boot_mode(task) ilo_common.update_secure_boot_mode(task, True) super(IloIscsiDeployMixin, self).continue_deploy(task, **kwargs)
def test_update_boot_mode_legacy(self, get_ilo_object_mock): ilo_mock_obj = get_ilo_object_mock.return_value exc = ilo_error.IloCommandNotSupportedError("error") ilo_mock_obj.get_pending_boot_mode.side_effect = exc with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: ilo_common.update_boot_mode(task) get_ilo_object_mock.assert_called_once_with(task.node) ilo_mock_obj.get_pending_boot_mode.assert_called_once_with() self.assertEqual("bios", task.node.instance_info["deploy_boot_mode"])
def continue_deploy(self, task, **kwargs): """Method invoked when deployed with the IPA ramdisk. This method is invoked during a heartbeat from an agent when the node is in wait-call-back state. This updates boot mode and secure boot settings, if required. """ ilo_common.update_boot_mode(task) ilo_common.update_secure_boot_mode(task, True) super(VendorPassthru, self).continue_deploy(task, **kwargs)
def test_update_boot_mode(self, get_ilo_object_mock): ilo_mock_obj = get_ilo_object_mock.return_value ilo_mock_obj.get_pending_boot_mode.return_value = 'LEGACY' with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: ilo_common.update_boot_mode(task) get_ilo_object_mock.assert_called_once_with(task.node) ilo_mock_obj.get_pending_boot_mode.assert_called_once_with() self.assertEqual('bios', task.node.instance_info['deploy_boot_mode'])
def test_update_boot_mode_unknown(self, get_ilo_object_mock): ilo_mock_obj = get_ilo_object_mock.return_value ilo_mock_obj.get_pending_boot_mode.return_value = "UNKNOWN" set_pending_boot_mode_mock = ilo_mock_obj.set_pending_boot_mode with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: ilo_common.update_boot_mode(task) get_ilo_object_mock.assert_called_once_with(task.node) ilo_mock_obj.get_pending_boot_mode.assert_called_once_with() set_pending_boot_mode_mock.assert_called_once_with("UEFI") self.assertEqual("uefi", task.node.instance_info["deploy_boot_mode"])
def pass_deploy_info(self, task, **kwargs): LOG.debug('Pass deploy info for the deployment on node %s', task.node.uuid) manager_utils.node_set_boot_device(task, boot_devices.PXE, persistent=True) # Set boot mode ilo_common.update_boot_mode(task) # Need to enable secure boot, if being requested _update_secure_boot_mode(task, True) super(IloPXEVendorPassthru, self).pass_deploy_info(task, **kwargs)
def test_update_boot_mode_legacy(self, get_ilo_object_mock): ilo_mock_obj = get_ilo_object_mock.return_value exc = ilo_error.IloCommandNotSupportedError('error') ilo_mock_obj.get_pending_boot_mode.side_effect = exc with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: ilo_common.update_boot_mode(task) get_ilo_object_mock.assert_called_once_with(task.node) ilo_mock_obj.get_pending_boot_mode.assert_called_once_with() self.assertEqual('bios', task.node.instance_info['deploy_boot_mode'])
def reboot_to_instance(self, task): node = task.node LOG.debug('Preparing to reboot to instance for node %s', node.uuid) error = self.check_deploy_success(node) if error is None: # Set boot mode ilo_common.update_boot_mode(task) # Need to enable secure boot, if being requested ilo_common.update_secure_boot_mode(task, True) super(IloVirtualMediaAgentDeploy, self).reboot_to_instance(task)
def test_update_boot_mode_unknown(self, get_ilo_object_mock): ilo_mock_obj = get_ilo_object_mock.return_value ilo_mock_obj.get_pending_boot_mode.return_value = 'UNKNOWN' set_pending_boot_mode_mock = ilo_mock_obj.set_pending_boot_mode with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: ilo_common.update_boot_mode(task) get_ilo_object_mock.assert_called_once_with(task.node) ilo_mock_obj.get_pending_boot_mode.assert_called_once_with() set_pending_boot_mode_mock.assert_called_once_with('UEFI') self.assertEqual('uefi', task.node.instance_info['deploy_boot_mode'])
def reboot_to_instance(self, task, **kwargs): node = task.node LOG.debug("Preparing to reboot to instance for node %s", node.uuid) error = self.check_deploy_success(node) if error is None: # Set boot mode ilo_common.update_boot_mode(task) # Need to enable secure boot, if being requested ilo_common.update_secure_boot_mode(task, True) super(IloVirtualMediaAgentVendorInterface, self).reboot_to_instance(task, **kwargs)
def pass_deploy_info(self, task, **kwargs): """Continues the deployment of baremetal node over iSCSI. This method continues the deployment of the baremetal node over iSCSI from where the deployment ramdisk has left off. This updates boot mode and secure boot settings, if required. :param task: a TaskManager instance containing the node to act on. :param **kwargs: kwargs for performing iscsi deployment. :raises: InvalidState """ ilo_common.update_boot_mode(task) ilo_common.update_secure_boot_mode(task, True) super(VendorPassthru, self).pass_deploy_info(task, **kwargs)
def prepare_instance(self, task): """Prepares the boot of instance. This method prepares the boot of the instance after reading relevant information from the node's instance_info. In case of netboot, it updates the dhcp entries and switches the PXE config. In case of localboot, it cleans up the PXE config. :param task: a task from TaskManager. :returns: None :raises: IloOperationError, if some operation on iLO failed. """ # Set boot mode ilo_common.update_boot_mode(task) # Need to enable secure boot, if being requested ilo_common.update_secure_boot_mode(task, True) super(IloPXEBoot, self).prepare_instance(task)
def continue_deploy(self, task, **kwargs): """Method invoked when deployed with the IPA ramdisk. This method is invoked during a heartbeat from an agent when the node is in wait-call-back state. This deploys the image on the node and then configures the node to boot according to the desired boot option (netboot or localboot). :param task: a TaskManager object containing the node. :param kwargs: the kwargs passed from the heartbeat method. :raises: InstanceDeployFailure, if it encounters some error during the deploy. """ task.process_event('resume') node = task.node LOG.debug('Continuing the deployment on node %s', node.uuid) ilo_common.cleanup_vmedia_boot(task) iwdi = node.driver_internal_info.get('is_whole_disk_image') uuid_dict = iscsi_deploy.do_agent_iscsi_deploy(task, self._client) root_uuid = uuid_dict.get('root uuid') if iscsi_deploy.get_boot_option(node) == "local" or iwdi: efi_system_part_uuid = uuid_dict.get( 'efi system partition uuid') self.configure_local_boot( task, root_uuid=root_uuid, efi_system_part_uuid=efi_system_part_uuid) else: # Agent vendorpassthru are made without auth token. # We require auth_token to talk to glance while building boot iso. task.context.auth_token = keystone.get_admin_auth_token() self._configure_vmedia_boot(task, root_uuid) # Set boot mode ilo_common.update_boot_mode(task) # Need to enable secure boot, if being requested _update_secure_boot_mode(task, True) self.reboot_and_finish_deploy(task)
def continue_deploy(self, task, **kwargs): """Method invoked when deployed with the IPA ramdisk. This method is invoked during a heartbeat from an agent when the node is in wait-call-back state. This deploys the image on the node and then configures the node to boot according to the desired boot option (netboot or localboot). :param task: a TaskManager object containing the node. :param kwargs: the kwargs passed from the heartbeat method. :raises: InstanceDeployFailure, if it encounters some error during the deploy. """ task.process_event('resume') node = task.node LOG.debug('Continuing the deployment on node %s', node.uuid) ilo_common.cleanup_vmedia_boot(task) iwdi = node.driver_internal_info.get('is_whole_disk_image') uuid_dict = iscsi_deploy.do_agent_iscsi_deploy(task, self._client) root_uuid = uuid_dict.get('root uuid') if iscsi_deploy.get_boot_option(node) == "local" or iwdi: efi_system_part_uuid = uuid_dict.get('efi system partition uuid') self.configure_local_boot( task, root_uuid=root_uuid, efi_system_part_uuid=efi_system_part_uuid) else: # Agent vendorpassthru are made without auth token. # We require auth_token to talk to glance while building boot iso. task.context.auth_token = keystone.get_admin_auth_token() self._configure_vmedia_boot(task, root_uuid) # Set boot mode ilo_common.update_boot_mode(task) # Need to enable secure boot, if being requested _update_secure_boot_mode(task, True) self.reboot_and_finish_deploy(task)
def continue_deploy(self, task, **kwargs): """Method invoked when deployed with the IPA ramdisk. This method is invoked during a heartbeat from an agent when the node is in wait-call-back state. This deploys the image on the node and then configures the node to boot according to the desired boot option (netboot or localboot). :param task: a TaskManager object containing the node. :param kwargs: the kwargs passed from the heartbeat method. :raises: InstanceDeployFailure, if it encounters some error during the deploy. :raises: IloOperationError, if some operation on iLO failed. """ LOG.debug('Continuing the deployment on node %s', task.node.uuid) # Set boot mode ilo_common.update_boot_mode(task) # Need to enable secure boot, if being requested _update_secure_boot_mode(task, True) super(IloPXEVendorPassthru, self).continue_deploy(task, **kwargs)
def prepare_instance(self, task): """Prepares the boot of instance. This method prepares the boot of the instance after reading relevant information from the node's instance_info. It does the following depending on boot_option for deploy: - If the boot_option requested for this deploy is 'local' or image is a whole disk image, then it sets the node to boot from disk. - Otherwise it finds/creates the boot ISO to boot the instance image, attaches the boot ISO to the bare metal and then sets the node to boot from CDROM. :param task: a task from TaskManager. :returns: None :raises: IloOperationError, if some operation on iLO failed. """ ilo_common.cleanup_vmedia_boot(task) # For iscsi_ilo driver, we boot from disk every time if the image # deployed is a whole disk image. node = task.node iwdi = node.driver_internal_info.get('is_whole_disk_image') if deploy_utils.get_boot_option(node) == "local" or iwdi: manager_utils.node_set_boot_device(task, boot_devices.DISK, persistent=True) else: drv_int_info = node.driver_internal_info root_uuid_or_disk_id = drv_int_info.get('root_uuid_or_disk_id') if root_uuid_or_disk_id: self._configure_vmedia_boot(task, root_uuid_or_disk_id) else: LOG.warning("The UUID for the root partition could not " "be found for node %s", node.uuid) # Set boot mode ilo_common.update_boot_mode(task) # Need to enable secure boot, if being requested ilo_common.update_secure_boot_mode(task, True)
def prepare_instance(self, task): """Prepares the boot of instance. This method prepares the boot of the instance after reading relevant information from the node's instance_info. In case of netboot, it updates the dhcp entries and switches the PXE config. In case of localboot, it cleans up the PXE config. In case of 'boot from volume', it updates the iSCSI info onto iLO and sets the node to boot from 'UefiTarget' boot device. :param task: a task from TaskManager. :returns: None :raises: IloOperationError, if some operation on iLO failed. """ # Set boot mode ilo_common.update_boot_mode(task) # Need to enable secure boot, if being requested ilo_common.update_secure_boot_mode(task, True) boot_mode = boot_mode_utils.get_boot_mode(task.node) if deploy_utils.is_iscsi_boot(task) and boot_mode == 'uefi': # Need to set 'ilo_uefi_iscsi_boot' param for clean up driver_internal_info = task.node.driver_internal_info driver_internal_info['ilo_uefi_iscsi_boot'] = True task.node.driver_internal_info = driver_internal_info task.node.save() # It will set iSCSI info onto iLO task.driver.management.set_iscsi_boot_target(task) manager_utils.node_set_boot_device(task, boot_devices.ISCSIBOOT, persistent=True) else: # Volume boot in BIOS boot mode is handled using # PXE boot interface super(IloiPXEBoot, self).prepare_instance(task)
def prepare_instance(self, task): """Prepares the boot of instance. This method prepares the boot of the instance after reading relevant information from the node's instance_info. In case of netboot, it updates the dhcp entries and switches the PXE config. In case of localboot, it cleans up the PXE config. In case of 'boot from volume', it updates the iSCSI info onto iLO and sets the node to boot from 'UefiTarget' boot device. :param task: a task from TaskManager. :returns: None :raises: IloOperationError, if some operation on iLO failed. """ # Set boot mode ilo_common.update_boot_mode(task) # Need to enable secure boot, if being requested ilo_common.update_secure_boot_mode(task, True) boot_mode = boot_mode_utils.get_boot_mode(task.node) if deploy_utils.is_iscsi_boot(task) and boot_mode == 'uefi': # Need to set 'ilo_uefi_iscsi_boot' param for clean up driver_internal_info = task.node.driver_internal_info driver_internal_info['ilo_uefi_iscsi_boot'] = True task.node.driver_internal_info = driver_internal_info task.node.save() # It will set iSCSI info onto iLO task.driver.management.set_iscsi_boot_target(task) manager_utils.node_set_boot_device(task, boot_devices.ISCSIBOOT, persistent=True) else: # Volume boot in BIOS boot mode is handled using # PXE boot interface super(IloPXEBoot, self).prepare_instance(task)
def test_update_boot_mode_use_def_boot_mode(self, set_boot_mode_mock): self.config(default_boot_mode="bios", group="ilo") with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: ilo_common.update_boot_mode(task) set_boot_mode_mock.assert_called_once_with(task.node, "bios") self.assertEqual("bios", task.node.instance_info["deploy_boot_mode"])
def pass_deploy_info(self, task, **kwargs): """Continues the iSCSI deployment from where ramdisk left off. This method continues the iSCSI deployment from the conductor node and writes the deploy image to the bare metal's disk. After that, it does the following depending on boot_option for deploy: - If the boot_option requested for this deploy is 'local', then it sets the node to boot from disk (ramdisk installs the boot loader present within the image to the bare metal's disk). - If the boot_option requested is 'netboot' or no boot_option is requested, it finds/creates the boot ISO to boot the instance image, attaches the boot ISO to the bare metal and then sets the node to boot from CDROM. :param task: a TaskManager instance containing the node to act on. :param kwargs: kwargs containing parameters for iSCSI deployment. :raises: InvalidState """ node = task.node task.process_event('resume') iwdi = node.driver_internal_info.get('is_whole_disk_image') ilo_common.cleanup_vmedia_boot(task) uuid_dict = iscsi_deploy.continue_deploy(task, **kwargs) root_uuid_or_disk_id = uuid_dict.get('root uuid', uuid_dict.get('disk identifier')) try: # Set boot mode ilo_common.update_boot_mode(task) # Need to enable secure boot, if being requested _update_secure_boot_mode(task, True) # For iscsi_ilo driver, we boot from disk every time if the image # deployed is a whole disk image. if iscsi_deploy.get_boot_option(node) == "local" or iwdi: manager_utils.node_set_boot_device(task, boot_devices.DISK, persistent=True) # Ask the ramdisk to install bootloader and # wait for the call-back through the vendor passthru # 'pass_bootloader_install_info', if it's not a whole # disk image. if not iwdi: deploy_utils.notify_ramdisk_to_proceed(kwargs['address']) task.process_event('wait') return else: self._configure_vmedia_boot(task, root_uuid_or_disk_id) except Exception as e: LOG.error( _LE('Deploy failed for instance %(instance)s. ' 'Error: %(error)s'), { 'instance': node.instance_uuid, 'error': e }) msg = _('Failed to continue iSCSI deployment.') deploy_utils.set_failed_state(task, msg) else: iscsi_deploy.finish_deploy(task, kwargs.get('address'))
def prepare_instance(self, task): """Prepares the boot of instance. This method prepares the boot of the instance after reading relevant information from the node's instance_info. It does the following depending on boot_option for deploy: - If the boot mode is 'uefi' and its booting from volume, then it sets the iSCSI target info and node to boot from 'UefiTarget' boot device. - If not 'boot from volume' and the boot_option requested for this deploy is 'local' or image is a whole disk image, then it sets the node to boot from disk. - Otherwise it finds/creates the boot ISO to boot the instance image, attaches the boot ISO to the bare metal and then sets the node to boot from CDROM. :param task: a task from TaskManager. :returns: None :raises: IloOperationError, if some operation on iLO failed. :raises: InstanceDeployFailure, if its try to boot iSCSI volume in 'BIOS' boot mode. """ ilo_common.cleanup_vmedia_boot(task) boot_mode = boot_mode_utils.get_boot_mode(task.node) boot_option = deploy_utils.get_boot_option(task.node) if deploy_utils.is_iscsi_boot(task): # It will set iSCSI info onto iLO if boot_mode == 'uefi': # Need to set 'ilo_uefi_iscsi_boot' param for clean up driver_internal_info = task.node.driver_internal_info driver_internal_info['ilo_uefi_iscsi_boot'] = True task.node.driver_internal_info = driver_internal_info task.node.save() task.driver.management.set_iscsi_boot_target(task) manager_utils.node_set_boot_device( task, boot_devices.ISCSIBOOT, persistent=True) else: msg = 'Virtual media can not boot volume in BIOS boot mode.' raise exception.InstanceDeployFailure(msg) elif boot_option == "ramdisk": boot_iso = _get_boot_iso(task, None) ilo_common.setup_vmedia_for_boot(task, boot_iso) manager_utils.node_set_boot_device(task, boot_devices.CDROM, persistent=True) else: # Boot from disk every time if the image deployed is # a whole disk image. node = task.node iwdi = node.driver_internal_info.get('is_whole_disk_image') if deploy_utils.get_boot_option(node) == "local" or iwdi: manager_utils.node_set_boot_device(task, boot_devices.DISK, persistent=True) else: drv_int_info = node.driver_internal_info root_uuid_or_disk_id = drv_int_info.get('root_uuid_or_disk_id') if root_uuid_or_disk_id: self._configure_vmedia_boot(task, root_uuid_or_disk_id) else: LOG.warning("The UUID for the root partition could not " "be found for node %s", node.uuid) # Set boot mode ilo_common.update_boot_mode(task) # Need to enable secure boot, if being requested ilo_common.update_secure_boot_mode(task, True)
def prepare_instance(self, task): """Prepares the boot of instance. This method prepares the boot of the instance after reading relevant information from the node's instance_info. It does the following depending on boot_option for deploy: - If the boot mode is 'uefi' and its booting from volume, then it sets the iSCSI target info and node to boot from 'UefiTarget' boot device. - If not 'boot from volume' and the boot_option requested for this deploy is 'local' or image is a whole disk image, then it sets the node to boot from disk. - Otherwise it finds/creates the boot ISO to boot the instance image, attaches the boot ISO to the bare metal and then sets the node to boot from CDROM. :param task: a task from TaskManager. :returns: None :raises: IloOperationError, if some operation on iLO failed. :raises: InstanceDeployFailure, if its try to boot iSCSI volume in 'BIOS' boot mode. """ ilo_common.cleanup_vmedia_boot(task) boot_mode = boot_mode_utils.get_boot_mode_for_deploy(task.node) boot_option = deploy_utils.get_boot_option(task.node) if deploy_utils.is_iscsi_boot(task): # It will set iSCSI info onto iLO if boot_mode == 'uefi': # Need to set 'ilo_uefi_iscsi_boot' param for clean up driver_internal_info = task.node.driver_internal_info driver_internal_info['ilo_uefi_iscsi_boot'] = True task.node.driver_internal_info = driver_internal_info task.node.save() task.driver.management.set_iscsi_boot_target(task) manager_utils.node_set_boot_device( task, boot_devices.ISCSIBOOT, persistent=True) else: msg = 'Virtual media can not boot volume in BIOS boot mode.' raise exception.InstanceDeployFailure(msg) elif boot_option == "ramdisk": boot_iso = _get_boot_iso(task, None) ilo_common.setup_vmedia_for_boot(task, boot_iso) manager_utils.node_set_boot_device(task, boot_devices.CDROM, persistent=True) else: # Boot from disk every time if the image deployed is # a whole disk image. node = task.node iwdi = node.driver_internal_info.get('is_whole_disk_image') if deploy_utils.get_boot_option(node) == "local" or iwdi: manager_utils.node_set_boot_device(task, boot_devices.DISK, persistent=True) else: drv_int_info = node.driver_internal_info root_uuid_or_disk_id = drv_int_info.get('root_uuid_or_disk_id') if root_uuid_or_disk_id: self._configure_vmedia_boot(task, root_uuid_or_disk_id) else: LOG.warning("The UUID for the root partition could not " "be found for node %s", node.uuid) # Set boot mode ilo_common.update_boot_mode(task) # Need to enable secure boot, if being requested ilo_common.update_secure_boot_mode(task, True)