ironic_python_agent.partition_utils module

Logic related to handling partitions.

Imported from ironic-lib’s disk_utils as of the following commit:

ironic_python_agent.partition_utils.create_config_drive_partition(node_uuid, device, configdrive)[source]

Create a partition for config drive

Checks if the device is GPT or MBR partitioned and creates config drive partition accordingly.

  • node_uuid – UUID of the Node.

  • device – The device path.

  • configdrive – Base64 encoded Gzipped configdrive content or configdrive HTTP URL.


InstanceDeployFailure if config drive size exceeds maximum limit or if it fails to create config drive.

ironic_python_agent.partition_utils.get_configdrive(configdrive, node_uuid, tempdir=None)[source]

Get the information about size and location of the configdrive.

  • configdrive – Base64 encoded Gzipped configdrive content or configdrive HTTP URL.

  • node_uuid – Node’s uuid. Used for logging.

  • tempdir – temporary directory for the temporary configdrive file


InstanceDeployFailure if it can’t download or decode the config drive.


A tuple with the size in MiB and path to the uncompressed configdrive file.

ironic_python_agent.partition_utils.get_labelled_partition(device_path, label, node_uuid)[source]

Check and return if partition with given label exists

  • device_path – The device path.

  • label – Partition label

  • node_uuid – UUID of the Node. Used for logging.


InstanceDeployFailure, if any disk partitioning related commands fail.


block device file for partition if it exists; otherwise it returns None.

ironic_python_agent.partition_utils.get_partition(device, uuid)[source]

Find the partition of a given device.

ironic_python_agent.partition_utils.work_on_disk(dev, root_mb, swap_mb, ephemeral_mb, ephemeral_format, image_path, node_uuid, preserve_ephemeral=False, configdrive=None, boot_mode='bios', tempdir=None, disk_label=None, cpu_arch='', conv_flags=None)[source]

Create partitions and copy an image to the root partition.

  • dev – Path for the device to work on.

  • root_mb – Size of the root partition in megabytes.

  • swap_mb – Size of the swap partition in megabytes.

  • ephemeral_mb – Size of the ephemeral partition in megabytes. If 0, no ephemeral partition will be created.

  • ephemeral_format – The type of file system to format the ephemeral partition.

  • image_path – Path for the instance’s disk image. If None, the root partition is prepared but not populated.

  • node_uuid – node’s uuid. Used for logging.

  • preserve_ephemeral – If True, no filesystem is written to the ephemeral block device, preserving whatever content it had (if the partition table has not changed).

  • configdrive – Optional. Base64 encoded Gzipped configdrive content or configdrive HTTP URL.

  • boot_mode – Can be “bios” or “uefi”. “bios” by default.

  • tempdir – A temporary directory

  • disk_label – The disk label to be used when creating the partition table. Valid values are: “msdos”, “gpt” or None; If None Ironic will figure it out according to the boot_mode parameter.

  • cpu_arch – Architecture of the node the disk device belongs to. When using the default value of None, no architecture specific steps will be taken. This default should be used for x86_64. When set to ppc64*, architecture specific steps are taken for booting a partition image locally.

  • conv_flags – Flags that need to be sent to the dd command, to control the conversion of the original file when copying to the host. It can contain several options separated by commas.


a dictionary containing the following keys: ‘root uuid’: UUID of root partition ‘efi system partition uuid’: UUID of the uefi system partition (if boot mode is uefi). partitions: mapping of partition types to their device paths. NOTE: If key exists but value is None, it means partition doesn’t exist.