kiwi.storage.subformat Package

Submodules

kiwi.storage.subformat.base Module

class kiwi.storage.subformat.base.DiskFormatBase(xml_state: XMLState, root_dir: str, target_dir: str, custom_args: dict | None = None)[source]

Bases: object

Base class to create disk formats from a raw disk image

Parameters:
  • xml_state (object) – Instance of XMLState

  • root_dir (string) – root directory path name

  • arch (string) – Defaults.get_platform_name

  • target_dir (string) – target directory path name

  • custom_args (dict) – custom format options dictionary

create_image_format() None[source]

Create disk format

Implementation in specialized disk format class required

static get_qemu_option_list(custom_args: dict) list[source]

Create list of qemu options from custom_args dict

Parameters:

custom_args (dict) – arguments

Returns:

qemu option list

Return type:

list

get_target_file_path_for_format(format_name: str) str[source]

Create target file path name for specified format

Parameters:

format_name (string) – disk format name

Returns:

file path name

Return type:

str

has_raw_disk() bool[source]

Check if the base raw disk image exists

Returns:

True or False

Return type:

bool

post_init(custom_args: dict) None[source]

Post initialization method

Implementation in specialized disk format class if required

Parameters:

custom_args (dict) – unused

resize_raw_disk(size_bytes, append=False)[source]

Resize raw disk image to specified size. If the request would actually shrink the disk an exception is raised. If the disk got changed the method returns True, if the new size is the same as the current size nothing gets resized and the method returns False

Parameters:

size (int) – size in bytes

Returns:

True or False

Return type:

bool

store_to_result(result: Result)[source]

Store result file of the format conversion into the provided result instance.

By default only the converted image file will be stored as compressed file. Subformats which creates additional metadata files or want to use other result flags needs to overwrite this method

Parameters:

result (object) – Instance of Result

kiwi.storage.subformat.gce Module

class kiwi.storage.subformat.gce.DiskFormatGce(xml_state: XMLState, root_dir: str, target_dir: str, custom_args: dict | None = None)[source]

Bases: DiskFormatBase

Create GCE - Google Compute Engine image format

create_image_format() None[source]

Create GCE disk format and manifest

get_target_file_path_for_format(format_name)[source]

Google requires the image name to follow their naming convetion. Therefore it’s required to provide a suitable name by overriding the base class method

Parameters:

format_name (string) – gce

Returns:

file path name

Return type:

str

post_init(custom_args: dict) None[source]

GCE disk format post initialization method

Store disk tag from custom args

Parameters:

custom_args (dict) –

custom gce argument dictionary

{'--tag': 'billing_code'}

store_to_result(result: Result) None[source]

Store result file of the gce format conversion into the provided result instance. In this case compression is unwanted because the gce tarball is already created as a compressed archive

Parameters:

result (object) – Instance of Result

kiwi.storage.subformat.ova Module

class kiwi.storage.subformat.ova.DiskFormatOva(xml_state: XMLState, root_dir: str, target_dir: str, custom_args: dict | None = None)[source]

Bases: DiskFormatBase

Create ova disk format, based on vmdk

create_image_format() None[source]

Create ova disk format using ovftool from https://www.vmware.com/support/developer/ovf

post_init(custom_args: dict) None[source]

vmdk disk format post initialization method

Store qemu options as list from custom args dict

Parameters:

custom_args (dict) – custom qemu arguments dictionary

store_to_result(result: Result) None[source]

Store the resulting ova file into the provided result instance.

Parameters:

result (object) – Instance of Result

kiwi.storage.subformat.qcow2 Module

class kiwi.storage.subformat.qcow2.DiskFormatQcow2(xml_state: XMLState, root_dir: str, target_dir: str, custom_args: dict | None = None)[source]

Bases: DiskFormatBase

Create qcow2 disk format

create_image_format() None[source]

Create qcow2 disk format

post_init(custom_args: dict) None[source]

qcow2 disk format post initialization method

Store qemu options as list from custom args dict

Parameters:

custom_args (dict) – custom qemu arguments dictionary

store_to_result(result: Result) None[source]

Store result file of the format conversion into the provided result instance.

In case of a qcow2 format we store the result uncompressed Since the format conversion only takes the real bytes into account such that the sparseness of the raw disk will not result in the output format and can be taken one by one

Parameters:

result (object) – Instance of Result

kiwi.storage.subformat.vagrant_base Module

class kiwi.storage.subformat.vagrant_base.DiskFormatVagrantBase(xml_state: XMLState, root_dir: str, target_dir: str, custom_args: dict | None = None)[source]

Bases: DiskFormatBase

Base class for creating vagrant boxes.

The documentation of the vagrant box format can be found here: https://www.vagrantup.com/docs/boxes/format.html In a nutshell, a vagrant box is a tar, tar.gz or zip archive of the following:

  1. metadata.json: A json file that contains the name of the provider and arbitrary additional data (that vagrant doesn’t care about).

  2. Vagrantfile: A Vagrantfile which defines the boxes’ MAC address. It can be also used to define other settings of the box, e.g. the method via which the /vagrant/ directory is shared. This file is either automatically generated by KIWI or we use a file that has been provided by the user (depends on the setting in vagrantconfig.embebbed_vagrantfile)

  3. The actual virtual disk image: this is provider specific and vagrant simply forwards it to your virtual machine provider.

Required methods/variables that child classes must implement:

Optional methods:

create_box_img(temp_image_dir: str) List[str][source]

Provider specific image creation step: this function creates the actual box image. It must be implemented by a child class.

create_image_format() None[source]

Create a vagrant box for any provider. This includes:

  • creation of box metadata.json

  • creation of box Vagrantfile (either from scratch or by using the user provided Vagrantfile)

  • creation of result format tarball from the files created above

get_additional_metadata() Dict[source]

Provide create_image_format() with additional metadata that will be included in metadata.json.

The default implementation returns an empty dictionary.

Returns:

A dictionary that is serializable to JSON

Return type:

dict

get_additional_vagrant_config_settings() str[source]

Supply additional configuration settings for vagrant to be included in the resulting box.

This function can be used by child classes to customize the behavior for different providers: the supplied configuration settings get forwarded to VagrantConfigTemplate.get_template() as the parameter custom_settings and included in the Vagrantfile.

The default implementation returns nothing.

Returns:

additional vagrant settings

Return type:

str

post_init(custom_args: Dict[str, vagrantconfig])[source]

vagrant disk format post initialization method

store vagrantconfig information provided via custom_args

Parameters:

custom_args (dict) –

Contains instance of xml_parse::vagrantconfig

{'vagrantconfig': object}

store_to_result(result: Result) None[source]

Store result file of the vagrant format conversion into the provided result instance. In this case compression is unwanted because the box is already created as a compressed tarball

Parameters:

result (object) – Instance of Result

vagrant_post_init() None[source]

Vagrant provider specific post initialization method

Setup vagrant provider and box name. This information must be set by the specialized provider class implementation to make the this base class methods effective

kiwi.storage.subformat.vagrant_libvirt Module

class kiwi.storage.subformat.vagrant_libvirt.DiskFormatVagrantLibVirt(xml_state: XMLState, root_dir: str, target_dir: str, custom_args: dict | None = None)[source]

Bases: DiskFormatVagrantBase

Create a vagrant box for the libvirt provider

create_box_img(temp_image_dir: str) List[str][source]

Creates the qcow2 disk image box for libvirt vagrant provider

Parameters:

temp_image_dir (str) – Path to the temporary directory used to build the box image

Returns:

A list of files relevant for the libvirt box to be included in the vagrant box

Return type:

list

get_additional_metadata() Dict[source]

Provide box metadata needed to create the box in vagrant

Returns:

Returns a dictionary containing the virtual image format and the size of the image.

Return type:

dict

get_additional_vagrant_config_settings() str[source]

Returns settings for the libvirt provider telling vagrant to use kvm.

Returns:

ruby code to be evaluated as string

Return type:

str

vagrant_post_init() None[source]

Vagrant provider specific post initialization method

Setup vagrant provider and box name. This information must be set by the specialized provider class implementation to make the this base class methods effective

kiwi.storage.subformat.vagrant_virtualbox Module

class kiwi.storage.subformat.vagrant_virtualbox.DiskFormatVagrantVirtualBox(xml_state: XMLState, root_dir: str, target_dir: str, custom_args: dict | None = None)[source]

Bases: DiskFormatVagrantBase

Create a vagrant box for the virtualbox provider

create_box_img(temp_image_dir: str) List[str][source]

Create the vmdk image for the Virtualbox vagrant provider.

This function creates the vmdk disk image and the ovf file. The latter is created via the class VirtualboxOvfTemplate.

Parameters:

temp_image_dir (str) – Path to the temporary directory used to build the box image

Returns:

A list of files relevant for the virtualbox box to be included in the vagrant box

Return type:

list

get_additional_vagrant_config_settings() str[source]

Configure the default shared folder to use rsync when guest additions are not present inside the box.

Returns:

ruby code to be evaluated as string

Return type:

str

vagrant_post_init() None[source]

Vagrant provider specific post initialization method

Setup vagrant provider and box name. This information must be set by the specialized provider class implementation to make the this base class methods effective

kiwi.storage.subformat.vdi Module

class kiwi.storage.subformat.vdi.DiskFormatVdi(xml_state: XMLState, root_dir: str, target_dir: str, custom_args: dict | None = None)[source]

Bases: DiskFormatBase

Create vdi disk format

create_image_format() None[source]

Create vdi disk format

post_init(custom_args: Dict) None[source]

vdi disk format post initialization method

Store qemu options as list from custom args dict

Parameters:

custom_args (dict) – custom qemu arguments dictionary

kiwi.storage.subformat.vhd Module

class kiwi.storage.subformat.vhd.DiskFormatVhd(xml_state: XMLState, root_dir: str, target_dir: str, custom_args: dict | None = None)[source]

Bases: DiskFormatBase

Create vhd disk format

create_image_format() None[source]

Create vhd disk format

post_init(custom_args: Dict) None[source]

vhd disk format post initialization method

Store qemu options as list from custom args dict

Parameters:

custom_args (dict) – custom qemu arguments dictionary

kiwi.storage.subformat.vhdfixed Module

class kiwi.storage.subformat.vhdfixed.DiskFormatVhdFixed(xml_state: XMLState, root_dir: str, target_dir: str, custom_args: dict | None = None)[source]

Bases: DiskFormatBase

Create vhd image format in fixed subformat

create_image_format() None[source]

Create vhd fixed disk format

post_init(custom_args: Dict) None[source]

vhd disk format post initialization method

Store qemu options as list from custom args dict Extract disk tag from custom args

Parameters:

custom_args (dict) –

custom vhdfixed and qemu argument dictionary

{'--tag': 'billing_code', '--qemu-opt': 'value'}

store_to_result(result: Result) None[source]

Store result file of the vhdfixed format conversion into the provided result instance. In this case compressing the result is preferred as vhdfixed is not a compressed or dynamic format.

Parameters:

result (object) – Instance of Result

kiwi.storage.subformat.vhdx Module

class kiwi.storage.subformat.vhdx.DiskFormatVhdx(xml_state: XMLState, root_dir: str, target_dir: str, custom_args: dict | None = None)[source]

Bases: DiskFormatBase

Create vhdx image format in dynamic subformat

create_image_format() None[source]

Create vhdx dynamic disk format

post_init(custom_args: Dict) None[source]

vhdx disk format post initialization method

Store qemu options as list from custom args dict

Parameters:

custom_args (dict) – custom qemu arguments dictionary

kiwi.storage.subformat.vmdk Module

class kiwi.storage.subformat.vmdk.DiskFormatVmdk(xml_state: XMLState, root_dir: str, target_dir: str, custom_args: dict | None = None)[source]

Bases: DiskFormatBase

Create vmdk disk format

create_image_format() None[source]

Create vmdk disk format and machine settings file

post_init(custom_args: Dict) None[source]

vmdk disk format post initialization method

Store qemu options as list from custom args dict

Parameters:

custom_args (dict) – custom qemu arguments dictionary

store_to_result(result: Result) None[source]

Store result files of the vmdk format conversion into the provided result instance. This includes the vmdk image file and the VMware settings file

Parameters:

result (object) – Instance of Result

Module Contents

class kiwi.storage.subformat.DiskFormat[source]

Bases: object

DiskFormat factory

Parameters:
  • name (string) – Format name

  • xml_state (object) – Instance of XMLState

  • root_dir (string) – root directory path name

  • target_dir (string) – target directory path name

abstract static new(name: str, xml_state: XMLState, root_dir: str, target_dir: str)[source]