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
- 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
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
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
- 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:
metadata.json
: A json file that contains the name of the provider and arbitrary additional data (that vagrant doesn’t care about).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 invagrantconfig.embebbed_vagrantfile
)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:
-
post initializing method that has to specify the vagrant provider name in
provider
and the box name inimage_format
. Note: new providers also needs to be specified in the schema and the box name needs to be registered tokiwi.defaults.Defaults.get_disk_format_types()
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 inmetadata.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 parametercustom_settings
and included in theVagrantfile
.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}
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
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
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
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
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
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
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
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
- static new(name: str, xml_state: XMLState, root_dir: str, target_dir: str) DiskFormatBase [source]