ironic.common.images module

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, root_uuid=None, kernel_params=None, boot_mode=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 used
  • root_uuid – uuid of the root filesystem (optional)
  • kernel_params – a string containing whitespace separated values kernel cmdline arguments of the form K=V or K (optional).
Boot_mode:

the boot mode in which the deploy is to happen.

Raises:

ImageCreationFailed, if creating boot ISO failed.

ironic.common.images.create_isolinux_image_for_bios(output_file, kernel, ramdisk, kernel_params=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.
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, deploy_iso, kernel, ramdisk, kernel_params=None)[source]

Creates an isolinux image on the specified file.

Copies the provided kernel, ramdisk, efiboot.img to a directory, creates the path for grub config file, generates the isolinux configuration file using the kernel parameters provided, 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.
  • deploy_iso – deploy iso used to initiate the deploy.
  • 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.
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.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.

Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.