kiwi.storage.subformat Package¶
Submodules¶
kiwi.storage.subformat.base
Module¶
-
class
kiwi.storage.subformat.base.
DiskFormatBase
(xml_state: kiwi.xml_state.XMLState, root_dir: str, target_dir: str, custom_args: Optional[dict] = None)[source]¶ Bases:
object
Base class to create disk formats from a raw disk image
- Parameters
-
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
-
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
-
has_raw_disk
() → bool[source]¶ Check if the base raw disk image exists
- Returns
True or False
- Return type
-
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
-
store_to_result
(result: kiwi.system.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: kiwi.xml_state.XMLState, root_dir: str, target_dir: str, custom_args: Optional[dict] = None)[source]¶ Bases:
kiwi.storage.subformat.base.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
-
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: kiwi.system.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: kiwi.xml_state.XMLState, root_dir: str, target_dir: str, custom_args: Optional[dict] = None)[source]¶ Bases:
kiwi.storage.subformat.base.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: kiwi.system.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: kiwi.xml_state.XMLState, root_dir: str, target_dir: str, custom_args: Optional[dict] = None)[source]¶ Bases:
kiwi.storage.subformat.base.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: kiwi.system.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: kiwi.xml_state.XMLState, root_dir: str, target_dir: str, custom_args: Optional[dict] = 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:
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
-
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
-
post_init
(custom_args: Dict[str, kiwi.xml_parse.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: kiwi.system.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
kiwi.storage.subformat.vagrant_libvirt
Module¶
-
class
kiwi.storage.subformat.vagrant_libvirt.
DiskFormatVagrantLibVirt
(xml_state: kiwi.xml_state.XMLState, root_dir: str, target_dir: str, custom_args: Optional[dict] = None)[source]¶ Bases:
kiwi.storage.subformat.vagrant_base.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
-
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
-
kiwi.storage.subformat.vagrant_virtualbox
Module¶
-
class
kiwi.storage.subformat.vagrant_virtualbox.
DiskFormatVagrantVirtualBox
(xml_state: kiwi.xml_state.XMLState, root_dir: str, target_dir: str, custom_args: Optional[dict] = None)[source]¶ Bases:
kiwi.storage.subformat.vagrant_base.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
.
-
kiwi.storage.subformat.vdi
Module¶
-
class
kiwi.storage.subformat.vdi.
DiskFormatVdi
(xml_state: kiwi.xml_state.XMLState, root_dir: str, target_dir: str, custom_args: Optional[dict] = None)[source]¶ Bases:
kiwi.storage.subformat.base.DiskFormatBase
Create vdi disk format
kiwi.storage.subformat.vhd
Module¶
-
class
kiwi.storage.subformat.vhd.
DiskFormatVhd
(xml_state: kiwi.xml_state.XMLState, root_dir: str, target_dir: str, custom_args: Optional[dict] = None)[source]¶ Bases:
kiwi.storage.subformat.base.DiskFormatBase
Create vhd disk format
kiwi.storage.subformat.vhdfixed
Module¶
-
class
kiwi.storage.subformat.vhdfixed.
DiskFormatVhdFixed
(xml_state: kiwi.xml_state.XMLState, root_dir: str, target_dir: str, custom_args: Optional[dict] = None)[source]¶ Bases:
kiwi.storage.subformat.base.DiskFormatBase
Create vhd image format in fixed subformat
-
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: kiwi.system.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: kiwi.xml_state.XMLState, root_dir: str, target_dir: str, custom_args: Optional[dict] = None)[source]¶ Bases:
kiwi.storage.subformat.base.DiskFormatBase
Create vhdx image format in dynamic subformat
kiwi.storage.subformat.vmdk
Module¶
-
class
kiwi.storage.subformat.vmdk.
DiskFormatVmdk
(xml_state: kiwi.xml_state.XMLState, root_dir: str, target_dir: str, custom_args: Optional[dict] = None)[source]¶ Bases:
kiwi.storage.subformat.base.DiskFormatBase
Create vmdk disk format
-
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: kiwi.system.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
-