kiwi.storage.subformat Package

Submodules

kiwi.storage.subformat.base Module

class kiwi.storage.subformat.base.DiskFormatBase(xml_state, root_dir, target_dir, custom_args=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) – platform.machine

  • target_dir (string) – target directory path name

  • custom_args (dict) – custom format options dictionary

create_image_format()[source]

Create disk format

Implementation in specialized disk format class required

get_qemu_option_list(custom_args)[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)[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()[source]

Check if the base raw disk image exists

Returns

True or False

Return type

bool

post_init(custom_args)[source]

Post initialization method

Implementation in specialized disk format class if required

Parameters

custom_args (list) – 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)[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, root_dir, target_dir, custom_args=None)[source]

Bases: kiwi.storage.subformat.base.DiskFormatBase

Create GCE - Google Compute Engine image format

create_image_format()[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)[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)[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, root_dir, target_dir, custom_args=None)[source]

Bases: kiwi.storage.subformat.base.DiskFormatBase

Create ova disk format, based on vmdk

create_image_format()[source]

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

post_init(custom_args)[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)[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, root_dir, target_dir, custom_args=None)[source]

Bases: kiwi.storage.subformat.base.DiskFormatBase

Create qcow2 disk format

create_image_format()[source]

Create qcow2 disk format

post_init(custom_args)[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)[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, root_dir, target_dir, custom_args=None)[source]

Bases: kiwi.storage.subformat.base.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.

  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)[source]

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

Parameters

temp_image_dir (str) – path to a temporary directory inside which the image should be built

Returns

A list of files that were created by this function and that should be included in the vagrant box

Return type

list

create_image_format()[source]

Create a vagrant box for any provider. This includes:

  • creation of box metadata.json

  • creation of box Vagrantfile

  • creation of result format tarball from the files created above

get_additional_metadata()[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()[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)[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)[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()[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, root_dir, target_dir, custom_args=None)[source]

Bases: kiwi.storage.subformat.vagrant_base.DiskFormatVagrantBase

Create a vagrant box for the libvirt provider

create_box_img(temp_image_dir)[source]

Creates the qcow2 disk image box for libvirt vagrant provider

get_additional_metadata()[source]

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

get_additional_vagrant_config_settings()[source]

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

vagrant_post_init()[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, root_dir, target_dir, custom_args=None)[source]

Bases: kiwi.storage.subformat.vagrant_base.DiskFormatVagrantBase

Create a vagrant box for the virtualbox provider

create_box_img(temp_image_dir)[source]

Create the virtual machine image for the Virtualbox vagrant provider.

This function creates the vmdk disk image and the ovf file. The latter is created via the class kiwi.storage.subformat.template.virtualbox_ovf.VirtualboxOvfTemplate.

get_additional_vagrant_config_settings()[source]

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

vagrant_post_init()[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, root_dir, target_dir, custom_args=None)[source]

Bases: kiwi.storage.subformat.base.DiskFormatBase

Create vdi disk format

create_image_format()[source]

Create vdi disk format

post_init(custom_args)[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, root_dir, target_dir, custom_args=None)[source]

Bases: kiwi.storage.subformat.base.DiskFormatBase

Create vhd disk format

create_image_format()[source]

Create vhd disk format

post_init(custom_args)[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, root_dir, target_dir, custom_args=None)[source]

Bases: kiwi.storage.subformat.base.DiskFormatBase

Create vhd image format in fixed subformat

create_image_format()[source]

Create vhd fixed disk format

post_init(custom_args)[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)[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, root_dir, target_dir, custom_args=None)[source]

Bases: kiwi.storage.subformat.base.DiskFormatBase

Create vhdx image format in dynamic subformat

create_image_format()[source]

Create vhdx dynamic disk format

post_init(custom_args)[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, root_dir, target_dir, custom_args=None)[source]

Bases: kiwi.storage.subformat.base.DiskFormatBase

Create vmdk disk format

create_image_format()[source]

Create vmdk disk format and machine settings file

post_init(custom_args)[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)[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