ironic.common.images module

Handling of VM disk images.

ironic.common.images.converted_size(path)[source]

Get size of converted raw image.

The size of image converted to raw format can be growing up to the virtual size of the image.

Parameters

path – path to the image file.

Returns

virtual size of the image or 0 if conversion not needed.

ironic.common.images.create_boot_iso(context, output_filename, kernel_href, ramdisk_href, deploy_iso_href=None, esp_image_href=None, root_uuid=None, kernel_params=None, boot_mode=None, configdrive_href=None)[source]

Creates a bootable ISO image for a node.

Given the hrefs for kernel, ramdisk, root partition’s UUID and kernel cmdline arguments, this method fetches the kernel and ramdisk, and builds a bootable ISO image that can be used to boot up the baremetal node.

Parameters
  • context – context

  • output_filename – the absolute path of the output ISO file

  • kernel_href – URL or glance uuid of the kernel to use

  • ramdisk_href – URL or glance uuid of the ramdisk to use

  • deploy_iso_href – URL or glance UUID of the deploy ISO image to extract EFI system partition image. If not specified, the esp_image_href option must be present if UEFI-bootable ISO is desired.

  • esp_image_href – URL or glance UUID of FAT12/16/32-formatted EFI system partition image containing the EFI boot loader (e.g. GRUB2) for each hardware architecture to boot. This image will be written onto the ISO image. If not specified, the deploy_iso_href option is only required for building UEFI-bootable ISO.

  • kernel_params – a string containing whitespace separated values kernel cmdline arguments of the form K=V or K (optional).

  • configdrive_href – URL to ISO9660 or FAT-formatted OpenStack config drive image. This image will be embedded into the built ISO image. Optional.

Boot_mode

the boot mode in which the deploy is to happen.

Raises

ImageCreationFailed, if creating boot ISO failed.

ironic.common.images.create_esp_image_for_uefi(output_file, kernel, ramdisk, deploy_iso=None, esp_image=None, kernel_params=None, configdrive=None)[source]

Creates an ESP image on the specified file.

Copies the provided kernel, ramdisk and EFI system partition image (ESP) to a directory, generates the grub configuration file using kernel parameters and then generates a bootable ISO image for UEFI.

Parameters
  • output_file – the path to the file where the iso image needs to be created.

  • kernel – the kernel to use.

  • ramdisk – the ramdisk to use.

  • deploy_iso – deploy ISO image to extract EFI system partition image from. If not specified, the esp_image option is required.

  • esp_image – FAT12/16/32-formatted EFI system partition image containing the EFI boot loader (e.g. GRUB2) for each hardware architecture to boot. This image will be embedded into the ISO image. If not specified, the deploy_iso option is required.

  • kernel_params – a list of strings(each element being a string like ‘K=V’ or ‘K’ or combination of them like ‘K1=V1,K2,…’) to be added as the kernel cmdline.

  • configdrive – ISO9660 or FAT-formatted OpenStack config drive image. This image will be written onto the built ISO image. Optional.

Raises

ImageCreationFailed, if image creation failed while copying files or while running command to generate iso.

ironic.common.images.create_isolinux_image_for_bios(output_file, kernel, ramdisk, kernel_params=None, configdrive=None)[source]

Creates an isolinux image on the specified file.

Copies the provided kernel, ramdisk to a directory, generates the isolinux configuration file using the kernel parameters provided, and then generates a bootable ISO image.

Parameters
  • output_file – the path to the file where the iso image needs to be created.

  • kernel – the kernel to use.

  • ramdisk – the ramdisk to use.

  • kernel_params – a list of strings(each element being a string like ‘K=V’ or ‘K’ or combination of them like ‘K1=V1,K2,…’) to be added as the kernel cmdline.

  • configdrive – ISO9660 or FAT-formatted OpenStack config drive image. This image will be written onto the built ISO image. Optional.

Raises

ImageCreationFailed, if image creation failed while copying files or while running command to generate iso.

ironic.common.images.create_isolinux_image_for_uefi(output_file, kernel, ramdisk, deploy_iso=None, esp_image=None, kernel_params=None, configdrive=None)

Creates an ESP image on the specified file.

Copies the provided kernel, ramdisk and EFI system partition image (ESP) to a directory, generates the grub configuration file using kernel parameters and then generates a bootable ISO image for UEFI.

Parameters
  • output_file – the path to the file where the iso image needs to be created.

  • kernel – the kernel to use.

  • ramdisk – the ramdisk to use.

  • deploy_iso – deploy ISO image to extract EFI system partition image from. If not specified, the esp_image option is required.

  • esp_image – FAT12/16/32-formatted EFI system partition image containing the EFI boot loader (e.g. GRUB2) for each hardware architecture to boot. This image will be embedded into the ISO image. If not specified, the deploy_iso option is required.

  • kernel_params – a list of strings(each element being a string like ‘K=V’ or ‘K’ or combination of them like ‘K1=V1,K2,…’) to be added as the kernel cmdline.

  • configdrive – ISO9660 or FAT-formatted OpenStack config drive image. This image will be written onto the built ISO image. Optional.

Raises

ImageCreationFailed, if image creation failed while copying files or while running command to generate iso.

ironic.common.images.create_vfat_image(output_file, files_info=None, parameters=None, parameters_file='parameters.txt', fs_size_kib=100)[source]

Creates the fat fs image on the desired file.

This method copies the given files to a root directory (optional), writes the parameters specified to the parameters file within the root directory (optional), and then creates a vfat image of the root directory.

Parameters
  • output_file – The path to the file where the fat fs image needs to be created.

  • files_info

    A dict containing absolute path of file to be copied -> relative path within the vfat image. For example:

    {
    '/absolute/path/to/file' -> 'relative/path/within/root'
    ...
    }
    

  • parameters – A dict containing key-value pairs of parameters.

  • parameters_file – The filename for the parameters file.

  • fs_size_kib – size of the vfat filesystem in KiB.

Raises

ImageCreationFailed, if image creation failed while doing any of filesystem manipulation activities like creating dirs, mounting, creating filesystem, copying files, etc.

ironic.common.images.download_size(context, image_href, image_service=None)[source]
ironic.common.images.fetch(context, image_href, path, force_raw=False)[source]
ironic.common.images.force_raw_get_source_format(image_href, path)[source]
ironic.common.images.force_raw_will_convert(image_href, path_tmp)[source]
ironic.common.images.get_image_properties(context, image_href, properties='all')[source]

Returns the values of several properties of an image

Parameters
  • context – context

  • image_href – href of the image

  • properties – the properties whose values are required. This argument is optional, default value is “all”, so if not specified all properties will be returned.

Returns

a dict of the values of the properties. A property not on the glance metadata will have a value of None.

ironic.common.images.get_temp_url_for_glance_image(context, image_uuid)[source]

Returns the tmp url for a glance image.

Parameters
  • context – context

  • image_uuid – the UUID of the image in glance

Returns

the tmp url for the glance image.

ironic.common.images.image_show(context, image_href, image_service=None)[source]
ironic.common.images.image_to_raw(image_href, path, path_tmp)[source]
ironic.common.images.is_whole_disk_image(ctx, instance_info)[source]

Find out if the image is a partition image or a whole disk image.

Parameters
  • ctx – an admin context

  • instance_info – a node’s instance info dict

Returns

True for whole disk images and False for partition images and None on no image_source or Error.