image_utils.py (ironic-17.0.2) | : | image_utils.py (ironic-17.0.3) | ||
---|---|---|---|---|
skipping to change at line 397 | skipping to change at line 397 | |||
"""Prepare an ISO to boot the node. | """Prepare an ISO to boot the node. | |||
Build bootable ISO out of `kernel_href` and `ramdisk_href` (and | Build bootable ISO out of `kernel_href` and `ramdisk_href` (and | |||
`bootloader` if it's UEFI boot), then push built image up to Swift and | `bootloader` if it's UEFI boot), then push built image up to Swift and | |||
return a temporary URL. | return a temporary URL. | |||
:param task: a TaskManager instance containing the node to act on. | :param task: a TaskManager instance containing the node to act on. | |||
:param kernel_href: URL or Glance UUID of the kernel to use | :param kernel_href: URL or Glance UUID of the kernel to use | |||
:param ramdisk_href: URL or Glance UUID of the ramdisk to use | :param ramdisk_href: URL or Glance UUID of the ramdisk to use | |||
:param bootloader_href: URL or Glance UUID of the EFI bootloader | :param bootloader_href: URL or Glance UUID of the EFI bootloader | |||
image to use when creating UEFI bootbable ISO | image to use when creating UEFI bootable ISO | |||
:param root_uuid: optional uuid of the root partition. | :param root_uuid: optional uuid of the root partition. | |||
:param params: a dictionary containing 'parameter name'->'value' | :param params: a dictionary containing 'parameter name'->'value' | |||
mapping to be passed to kernel command line. | mapping to be passed to kernel command line. | |||
:param inject_files: Mapping of local source file paths to their location | :param inject_files: Mapping of local source file paths to their location | |||
on the final ISO image. | on the final ISO image. | |||
:returns: bootable ISO HTTP URL. | :returns: bootable ISO HTTP URL. | |||
:raises: MissingParameterValue, if any of the required parameters are | :raises: MissingParameterValue, if any of the required parameters are | |||
missing. | missing. | |||
:raises: InvalidParameterValue, if any of the parameters have invalid | :raises: InvalidParameterValue, if any of the parameters have invalid | |||
value. | value. | |||
:raises: ImageCreationFailed, if creating ISO image failed. | :raises: ImageCreationFailed, if creating ISO image failed. | |||
""" | """ | |||
if (not kernel_href or not ramdisk_href) and not base_iso: | if (not kernel_href or not ramdisk_href) and not base_iso: | |||
raise exception.InvalidParameterValue(_( | raise exception.InvalidParameterValue(_( | |||
"Unable to find kernel, ramdisk for " | "Unable to find kernel, ramdisk for " | |||
"building ISO, or explicit ISO for %(node)s") % | "building ISO, or explicit ISO for %(node)s") % | |||
{'node': task.node.uuid}) | {'node': task.node.uuid}) | |||
# NOTE(rpittau): if base_iso is defined as http address, we just access | ||||
# it directly. | ||||
if base_iso and CONF.deploy.ramdisk_image_download_source == 'http': | ||||
if base_iso.startswith(('http://', 'https://')): | ||||
return base_iso | ||||
LOG.debug("ramdisk_image_download_source set to http but " | ||||
"boot_iso is not an HTTP URL: %(boot_iso)s", | ||||
{"boot_iso": base_iso}) | ||||
img_handler = ImageHandler(task.node.driver) | img_handler = ImageHandler(task.node.driver) | |||
k_param = img_handler.kernel_params | k_param = img_handler.kernel_params | |||
i_info = task.node.instance_info | i_info = task.node.instance_info | |||
# NOTE(TheJulia): Until we support modifying a base iso, most of | # NOTE(TheJulia): Until we support modifying a base iso, most of | |||
# this logic actually does nothing in the end. But it should! | # this logic actually does nothing in the end. But it should! | |||
if deploy_utils.get_boot_option(task.node) == "ramdisk": | if deploy_utils.get_boot_option(task.node) == "ramdisk": | |||
if not base_iso: | if not base_iso: | |||
kernel_params = "root=/dev/ram0 text " | kernel_params = "root=/dev/ram0 text " | |||
kernel_params += i_info.get("ramdisk_kernel_arguments", "") | kernel_params += i_info.get("ramdisk_kernel_arguments", "") | |||
else: | else: | |||
kernel_params = None | kernel_params = None | |||
else: | else: | |||
kernel_params = i_info.get('kernel_append_params', k_param) | kernel_params = i_info.get('kernel_append_params', k_param) | |||
if params and not base_iso: | if params and not base_iso: | |||
kernel_params = ' '.join( | kernel_params = ' '.join( | |||
(kernel_params, ' '.join( | (kernel_params, ' '.join( | |||
'%s=%s' % kv for kv in params.items()))) | ('%s=%s' % kv) if kv[1] is not None else kv[0] | |||
for kv in params.items()))) | ||||
boot_mode = boot_mode_utils.get_boot_mode(task.node) | boot_mode = boot_mode_utils.get_boot_mode(task.node) | |||
if base_iso: | if base_iso: | |||
# TODO(dtantsur): fix this limitation eventually (see | # TODO(dtantsur): fix this limitation eventually (see | |||
# images.create_boot_iso). | # images.create_boot_iso). | |||
LOG.debug('Using pre-built %(boot_mode)s ISO %(iso)s for node ' | LOG.debug('Using pre-built %(boot_mode)s ISO %(iso)s for node ' | |||
'%(node)s, custom configuration will not be available', | '%(node)s, custom configuration will not be available', | |||
{'boot_mode': boot_mode, 'node': task.node.uuid, | {'boot_mode': boot_mode, 'node': task.node.uuid, | |||
'iso': base_iso}) | 'iso': base_iso}) | |||
End of changes. 3 change blocks. | ||||
2 lines changed or deleted | 12 lines changed or added |