Example #1
0
    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 database.

        :param task: a task from TaskManager.
        :returns: None
        """
        if task.node.driver_internal_info.get('boot_from_volume'):
            LOG.debug(
                'Node %(node)s is configured for booting from a remote '
                'volume.', {'node': task.node.uuid})
            self._configure_boot_from_volume(task)
            return

        _cleanup_vmedia_boot(task)

        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:
            driver_internal_info = node.driver_internal_info
            root_uuid_or_disk_id = driver_internal_info['root_uuid_or_disk_id']
            self._configure_vmedia_boot(task, root_uuid_or_disk_id)

        # Enable secure boot, if being requested
        if deploy_utils.is_secure_boot_requested(node):
            irmc_common.set_secure_boot_mode(node, enable=True)
Example #2
0
    def clean_up_instance(self, task):
        """Cleans up the boot of instance.

        This method cleans up the environment that was setup for booting
        the instance.

        :param task: a task from TaskManager.
        :returns: None
        :raises: IRMCOperationError if iRMC operation failed.
        """
        if task.node.driver_internal_info.get('boot_from_volume'):
            self._cleanup_boot_from_volume(task)
            return

        # Disable secure boot, if enabled secure boot
        if deploy_utils.is_secure_boot_requested(task.node):
            irmc_common.set_secure_boot_mode(task.node, enable=False)

        _remove_share_file(_get_iso_name(task.node, label='boot'))
        driver_internal_info = task.node.driver_internal_info
        driver_internal_info.pop('irmc_boot_iso', None)

        task.node.driver_internal_info = driver_internal_info
        task.node.save()
        _cleanup_vmedia_boot(task)
Example #3
0
    def clean_up_instance(self, task):
        """Cleans up the boot of instance.

        This method cleans up the environment that was setup for booting
        the instance.

        :param task: a task from TaskManager.
        :returns: None
        :raises: IRMCOperationError if iRMC operation failed.
        """
        if task.node.driver_internal_info.get('boot_from_volume'):
            self._cleanup_boot_from_volume(task)
            return

        # Disable secure boot, if enabled secure boot
        if deploy_utils.is_secure_boot_requested(task.node):
            irmc_common.set_secure_boot_mode(task.node, enable=False)

        _remove_share_file(_get_boot_iso_name(task.node))
        driver_internal_info = task.node.driver_internal_info
        driver_internal_info.pop('irmc_boot_iso', None)
        driver_internal_info.pop('root_uuid_or_disk_id', None)
        task.node.driver_internal_info = driver_internal_info
        task.node.save()
        _cleanup_vmedia_boot(task)
Example #4
0
    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 database.

        :param task: a task from TaskManager.
        :returns: None
        """
        if task.node.driver_internal_info.get('boot_from_volume'):
            LOG.debug('Node %(node)s is configured for booting from a remote '
                      'volume.',
                      {'node': task.node.uuid})
            self._configure_boot_from_volume(task)
            return

        _cleanup_vmedia_boot(task)

        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:
            driver_internal_info = node.driver_internal_info
            root_uuid_or_disk_id = driver_internal_info['root_uuid_or_disk_id']
            self._configure_vmedia_boot(task, root_uuid_or_disk_id)

        # Enable secure boot, if being requested
        if deploy_utils.is_secure_boot_requested(node):
            irmc_common.set_secure_boot_mode(node, enable=True)
Example #5
0
    def clean_up_instance(self, task):
        """Cleans up the boot of instance.

        This method cleans up the environment that was setup for booting
        the instance.

        :param task: a task from TaskManager.
        :returns: None
        :raises: IRMCOperationError if iRMC operation failed.
        """
        if task.node.driver_internal_info.get('boot_from_volume'):
            self._cleanup_boot_from_volume(task)
            return

        # Disable secure boot, if enabled secure boot
        if deploy_utils.is_secure_boot_requested(task.node):
            irmc_common.set_secure_boot_mode(task.node, enable=False)

        _remove_share_file(_get_iso_name(task.node, label='boot'))
        driver_internal_info = task.node.driver_internal_info
        driver_internal_info.pop('irmc_boot_iso', None)

        # When rescue, this function is called. But we need to retain the
        # root_uuid_or_disk_id to use on unrescue (see prepare_instance).
        boot_local_or_iwdi = (
            deploy_utils.get_boot_option(task.node) == "local"
            or driver_internal_info.get('is_whole_disk_image'))
        if task.node.provision_state != states.RESCUING or boot_local_or_iwdi:
            driver_internal_info.pop('root_uuid_or_disk_id', None)

        task.node.driver_internal_info = driver_internal_info
        task.node.save()
        _cleanup_vmedia_boot(task)
Example #6
0
    def clean_up_instance(self, task):
        """Cleans up the boot of instance.

        This method cleans up the environment that was setup for booting
        the instance. It unlinks the instance kernel/ramdisk in node's
        directory in tftproot and removes the PXE config.

        :param task: a task from TaskManager.
        :raises: IRMCOperationError, if some operation on iRMC failed.
        :returns: None
        """
        node = task.node
        if deploy_utils.is_secure_boot_requested(node):
            irmc_common.set_secure_boot_mode(node, enable=False)
        super(IRMCPXEBoot, self).clean_up_instance(task)
Example #7
0
    def clean_up_instance(self, task):
        """Cleans up the boot of instance.

        This method cleans up the environment that was setup for booting
        the instance. It unlinks the instance kernel/ramdisk in node's
        directory in tftproot and removes the PXE config.

        :param task: a task from TaskManager.
        :raises: IRMCOperationError, if some operation on iRMC failed.
        :returns: None
        """
        node = task.node
        if deploy_utils.is_secure_boot_requested(node):
            irmc_common.set_secure_boot_mode(node, enable=False)
        super(IRMCPXEBoot, self).clean_up_instance(task)
Example #8
0
    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: IRMCOperationError, if some operation on iRMC failed.
        """

        super(IRMCPXEBoot, self).prepare_instance(task)
        node = task.node
        if deploy_utils.is_secure_boot_requested(node):
            irmc_common.set_secure_boot_mode(node, enable=True)
Example #9
0
    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: IRMCOperationError, if some operation on iRMC failed.
        """

        super(IRMCPXEBoot, self).prepare_instance(task)
        node = task.node
        if deploy_utils.is_secure_boot_requested(node):
            irmc_common.set_secure_boot_mode(node, enable=True)
Example #10
0
    def set_secure_boot_state(self, task, state):
        """Set the current secure boot state for the node.

        NOTE: Not all drivers support this method. Older hardware
              may not implement that.

        :param task: A task from TaskManager.
        :param state: A new state as a boolean.
        :raises: MissingParameterValue if a required parameter is missing
        :raises: DriverOperationError or its derivative in case
                 of driver runtime error.
        :raises: UnsupportedDriverExtension if secure boot is
                 not supported by the driver or the hardware
        """
        return irmc_common.set_secure_boot_mode(task.node, state)
Example #11
0
 def test_set_secure_boot_mode_disable(self, mock_elcm):
     mock_elcm.set_secure_boot_mode.return_value = 'set_secure_boot_mode'
     info = irmc_common.parse_driver_info(self.node)
     irmc_common.set_secure_boot_mode(self.node, False)
     mock_elcm.set_secure_boot_mode.assert_called_once_with(info, False)
Example #12
0
 def test_set_secure_boot_mode_disable(self, mock_elcm):
     mock_elcm.set_secure_boot_mode.return_value = 'set_secure_boot_mode'
     info = irmc_common.parse_driver_info(self.node)
     irmc_common.set_secure_boot_mode(self.node, False)
     mock_elcm.set_secure_boot_mode.assert_called_once_with(
         info, False)