The ironic_lib.disk_utils
Module¶
-
ironic_lib.disk_utils.
convert_image
(source, dest, out_format, run_as_root=False)[source]¶ Convert image to other format.
-
ironic_lib.disk_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.
Parameters: - node_uuid – UUID of the Node.
- device – The device path.
- configdrive – Base64 encoded Gzipped configdrive content or configdrive HTTP URL.
Raises: InstanceDeployFailure if config drive size exceeds maximum limit or if it fails to create config drive.
-
ironic_lib.disk_utils.
destroy_disk_metadata
(dev, node_uuid)[source]¶ Destroy metadata structures on node’s disk.
Ensure that node’s disk magic strings are wiped without zeroing the entire drive. To do this we use the wipefs tool from util-linux.
Parameters: - dev – Path for the device to work on.
- node_uuid – Node’s uuid. Used for logging.
-
ironic_lib.disk_utils.
get_disk_identifier
(dev)[source]¶ Get the disk identifier from the disk being exposed by the ramdisk.
This disk identifier is appended to the pxe config which will then be used by chain.c32 to detect the correct disk to chainload. This is helpful in deployments to nodes with multiple disks.
http://www.syslinux.org/wiki/index.php/Comboot/chain.c32#mbr:
Parameters: dev – Path for the already populated disk device. Returns: The Disk Identifier.
-
ironic_lib.disk_utils.
get_image_mb
(image_path, virtual_size=True)[source]¶ Get size of an image in Megabyte.
-
ironic_lib.disk_utils.
is_iscsi_device
(dev, node_uuid)[source]¶ check whether the device path belongs to an iscsi device.
-
ironic_lib.disk_utils.
list_partitions
(device)[source]¶ Get partitions information from given device.
Parameters: device – The device path. Returns: list of dictionaries (one per partition) with keys: number, start, end, size (in MiB), filesystem, flags
-
ironic_lib.disk_utils.
make_partitions
(dev, root_mb, swap_mb, ephemeral_mb, configdrive_mb, node_uuid, commit=True, boot_option='netboot', boot_mode='bios', disk_label=None)[source]¶ Partition the disk device.
Create partitions for root, swap, ephemeral and configdrive on a disk device.
Parameters: - root_mb – Size of the root partition in mebibytes (MiB).
- swap_mb – Size of the swap partition in mebibytes (MiB). If 0, no partition will be created.
- ephemeral_mb – Size of the ephemeral partition in mebibytes (MiB). If 0, no partition will be created.
- configdrive_mb – Size of the configdrive partition in mebibytes (MiB). If 0, no partition will be created.
- commit – True/False. Default for this setting is True. If False partitions will not be written to disk.
- boot_option – Can be “local” or “netboot”. “netboot” by default.
- boot_mode – Can be “bios” or “uefi”. “bios” by default.
- node_uuid – Node’s uuid. Used for logging.
- 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.
Returns: A dictionary containing the partition type as Key and partition path as Value for the partitions created by this method.
-
ironic_lib.disk_utils.
qemu_img_info
(path)[source]¶ Return an object containing the parsed output from qemu-img info.
-
ironic_lib.disk_utils.
work_on_disk
(dev, root_mb, swap_mb, ephemeral_mb, ephemeral_format, image_path, node_uuid, preserve_ephemeral=False, configdrive=None, boot_option='netboot', boot_mode='bios', tempdir=None, disk_label=None)[source]¶ Create partitions and copy an image to the root partition.
Parameters: - 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.
- 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_option – Can be “local” or “netboot”. “netboot” by default.
- 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.
Returns: 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). NOTE: If key exists but value is None, it means partition doesn’t exist.