def deploy(self, task): """Start deployment of the task's node. This method sets the boot device to 'NETWORK' and then calls PXEDeploy's deploy method to deploy on the given node. :param task: a TaskManager instance containing the node to act on. :returns: deploy state DEPLOYWAIT. """ ilo_common.set_boot_device(task.node, 'NETWORK', False) return super(IloPXEDeploy, self).deploy(task)
def vendor_passthru(self, task, **kwargs): """Calls a valid vendor passthru method. :param task: a TaskManager instance containing the node to act on. :param kwargs: kwargs containing the vendor passthru method and its parameters. """ method = kwargs['method'] if method == 'pass_deploy_info': ilo_common.set_boot_device(task.node, 'NETWORK', True) return super(IloPXEVendorPassthru, self).vendor_passthru(task, **kwargs)
def _attach_boot_iso(task): """Attaches boot ISO for a deployed node. This method checks the instance info of the baremetal node for a boot iso. It attaches the boot ISO on the baremetal node, and then sets the node to boot from virtual media cdrom. :param task: a TaskManager instance containing the node to act on. """ i_info = task.node.instance_info if 'ilo_boot_iso' in i_info: ilo_common.setup_vmedia_for_boot(task, i_info['ilo_boot_iso']) ilo_common.set_boot_device(task.node, 'CDROM')
def _continue_deploy(self, task, **kwargs): """Continues the iSCSI deployment from where ramdisk left off. Continues the iSCSI deployment from the conductor node, finds the boot ISO to boot the node, and sets the node to boot from boot ISO. :param task: a TaskManager instance containing the node to act on. :param kwargs: kwargs containing parameters for iSCSI deployment. """ node = task.node if node.provision_state != states.DEPLOYWAIT: LOG.error(_LE('Node %s is not waiting to be deployed.'), node.uuid) return ilo_common.cleanup_vmedia_boot(task) root_uuid = iscsi_deploy.continue_deploy(task, **kwargs) if not root_uuid: return try: boot_iso = _get_boot_iso(task, root_uuid) if not boot_iso: LOG.error(_LE("Cannot get boot ISO for node %s"), node.uuid) return ilo_common.setup_vmedia_for_boot(task, boot_iso) ilo_common.set_boot_device(node, 'CDROM') address = kwargs.get('address') deploy_utils.notify_deploy_complete(address) node.provision_state = states.ACTIVE node.target_provision_state = states.NOSTATE i_info = node.instance_info i_info['ilo_boot_iso'] = boot_iso node.instance_info = i_info node.save() LOG.info(_LI('Deployment to node %s done'), node.uuid) 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.') iscsi_deploy.set_failed_state(task, msg)
def _continue_deploy(self, task, **kwargs): """Continues the iSCSI deployment from where ramdisk left off. Continues the iSCSI deployment from the conductor node, finds the boot ISO to boot the node, and sets the node to boot from boot ISO. :param task: a TaskManager instance containing the node to act on. :param kwargs: kwargs containing parameters for iSCSI deployment. """ node = task.node if node.provision_state != states.DEPLOYWAIT: LOG.error(_LE('Node %s is not waiting to be deployed.'), node.uuid) return ilo_common.cleanup_vmedia_boot(task) root_uuid = iscsi_deploy.continue_deploy(task, **kwargs) if not root_uuid: return try: boot_iso = _get_boot_iso(task, root_uuid) if not boot_iso: LOG.error(_LE("Cannot get boot ISO for node %s"), node.uuid) return ilo_common.setup_vmedia_for_boot(task, boot_iso) ilo_common.set_boot_device(node, 'CDROM') address = kwargs.get('address') deploy_utils.notify_deploy_complete(address) node.provision_state = states.ACTIVE node.target_provision_state = states.NOSTATE i_info = node.instance_info i_info['ilo_boot_iso'] = boot_iso node.instance_info = i_info node.save() LOG.info(_LI('Deployment to node %s done'), node.uuid) 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.') iscsi_deploy.set_failed_state(task, msg)
def _reboot_into(task, iso, ramdisk_options): """Reboots the node into a given boot ISO. This method attaches the given bootable ISO as virtual media, prepares the arguments for ramdisk in virtual media floppy, and then reboots the node. :param task: a TaskManager instance containing the node to act on. :param iso: a bootable ISO image to attach to. The boot iso should be present in either Glance or in Swift. If present in Glance, it should be of format 'glance:<glance-image-uuid>'. If present in Swift, it should be of format 'swift:<object-name>'. It is assumed that object is present in CONF.ilo.swift_ilo_container. :param ramdisk_options: the options to be passed to the ramdisk in virtual media floppy. :raises: ImageCreationFailed, if it failed while creating the floppy image. :raises: IloOperationError, if some operation on iLO failed. """ ilo_common.setup_vmedia_for_boot(task, iso, ramdisk_options) ilo_common.set_boot_device(task.node, 'CDROM') manager_utils.node_power_action(task, states.REBOOT)
def set_boot_device(self, task, device, persistent=False): """Set the boot device for the task's node. Set the boot device to use on next reboot of the node. :param task: a task from TaskManager. :param device: the boot device, one of :mod:`ironic.common.boot_devices`. :param persistent: Boolean value. True if the boot device will persist to all future boots, False if not. Default: False. :raises: InvalidParameterValue if an invalid boot device is specified :raises: MissingParameterValue if required ilo credentials are missing. :raises: IloOperationError, if unable to set the boot device. """ try: boot_device = BOOT_DEVICE_MAPPING_TO_ILO[device] except KeyError: raise exception.InvalidParameterValue( _("Invalid boot device %s specified.") % device) ilo_common.parse_driver_info(task.node) ilo_common.set_boot_device(task.node, boot_device, persistent)
def set_boot_device(self, task, device, persistent=False): """Set the boot device for the task's node. Set the boot device to use on next reboot of the node. :param task: a task from TaskManager. :param device: the boot device, one of :mod:`ironic.common.boot_devices`. :param persistent: Boolean value. True if the boot device will persist to all future boots, False if not. Default: False. :raises: InvalidParameterValue if an invalid boot device is specified :raises: MissingParameterValue if required ilo credentials are missing. :raises: IloOperationError, if unable to set the boot device. """ try: boot_device = BOOT_DEVICE_MAPPING_TO_ILO[device] except KeyError: raise exception.InvalidParameterValue(_( "Invalid boot device %s specified.") % device) ilo_common.parse_driver_info(task.node) ilo_common.set_boot_device(task.node, boot_device, persistent)
def test_set_boot_device_persistent_true(self, get_ilo_object_mock): ilo_mock = get_ilo_object_mock.return_value ilo_common.set_boot_device(self.node, 'NETWORK', True) get_ilo_object_mock.assert_called_once_with(self.node) ilo_mock.update_persistent_boot.assert_called_once_with(['NETWORK'])
def test_set_boot_device(self, get_ilo_object_mock): ilo_object_mock = get_ilo_object_mock.return_value ilo_common.set_boot_device(self.node, 'CDROM') get_ilo_object_mock.assert_called_once_with(self.node) ilo_object_mock.set_one_time_boot.assert_called_once_with('CDROM')
def _continue_deploy(self, task, **kwargs): ilo_common.set_boot_device(task.node, 'NETWORK', True) super(IloPXEVendorPassthru, self)._continue_deploy(task, **kwargs)