images – Image metadata¶
This module provides classes for manipulating images.json files. images.json files provide details about images included in composes.
- Example::
import productmd.compose compose = productmd.compose.Compose(“/path/to/compose”)
# Print the entire dict that maps all variants, arches, and images for this # compose: print(compose.images.images)
# Find all the qcow2 images in this compose: qcow2s = set()
- for variant in compose.images.images:
- for arch in compose.images.images[variant]:
- for images in compose.images.images[variant].values():
- if image.type == ‘qcow2’:
- qcow2s.add(image)
print(qcow2s)
# … prints the set of qcow2 images in all our variants: [<Image:Server-RT/x86_64/images/rhel-kvm-rt-image-7.6-220.x86_64.qcow2:qcow2:x86_64>,
<Image:Server/x86_64/images/rhel-guest-image-7.6-210.x86_64.qcow2:qcow2:x86_64>, <Image:Server/ppc64le/images/rhel-guest-image-7.6-210.ppc64le.qcow2:qcow2:ppc64le>]
-
productmd.images.
SUPPORTED_IMAGE_FORMATS
= ['iso', 'liveimg.squashfs', 'qcow', 'qcow2', 'raw', 'raw.xz', 'rhevm.ova', 'tar.gz', 'tar.xz', 'vagrant-hyperv.box', 'vagrant-libvirt.box', 'vagrant-virtualbox.box', 'vagrant-vmware-fusion.box', 'vdi', 'vhd', 'vmdk', 'vsphere.ova']¶ supported image formats, they match with file suffix
-
productmd.images.
UNIQUE_IMAGE_ATTRIBUTES
= ['subvariant', 'type', 'format', 'arch', 'disc_number', 'unified', 'additional_variants']¶ combination of attributes which uniquely identifies an image across composes
-
class
productmd.images.
UniqueImage
(subvariant, type, format, arch, disc_number, unified, additional_variants)¶ a namedtuple with unique attributes, use
identify_image
to create an instance-
additional_variants
¶ Alias for field number 6
-
arch
¶ Alias for field number 3
-
disc_number
¶ Alias for field number 4
-
format
¶ Alias for field number 2
-
subvariant
¶ Alias for field number 0
-
type
¶ Alias for field number 1
-
unified
¶ Alias for field number 5
-
Classes¶
-
class
productmd.images.
Images
¶ -
add
(variant, arch, image)¶ Assign an
Image
object to variant and arch.Parameters: - variant (str) – compose variant UID
- arch (str) – compose architecture
- image (
Image
) – image
-
dump
(f)¶ Dump data to a file.
Parameters: f (file or str) – file-like object or path to file
-
dumps
()¶ Dump data to a string.
Return type: str
-
load
(f)¶ Load data from a file.
Parameters: f (file or str) – file-like object or path to file
-
loads
(s)¶ Load data from a string.
Parameters: s (str) – input data
-
validate
()¶ Validate attributes by running all self._validate_*() methods.
Raises: - TypeError – if an attribute has invalid type
- ValueError – if an attribute contains invalid value
-
-
class
productmd.images.
Image
(parent)¶ -
path
= None¶ (str) – relative path to an image, for example: “Server/x86_64/iso/boot.iso”
-
mtime
= None¶ (int) – image mtime
-
size
= None¶ (int) – image size
-
volume_id
= None¶ (str) –
-
type
= None¶ (str) –
-
format
= None¶ (str) – Release name, for example: “Fedora”, “Red Hat Enterprise Linux”
-
arch
= None¶ (str) – image architecture, for example: “x86_64”, “src”
-
disc_number
= None¶ (int) – Release name, for example: “Fedora”, “Red Hat Enterprise Linux”
-
disc_count
= None¶ (int) – Release name, for example: “Fedora”, “Red Hat Enterprise Linux”
-
checksums
= None¶ (str) – Release name, for example: “Fedora”, “Red Hat Enterprise Linux”
-
implant_md5
= None¶ (str or None) – value of implanted md5
-
bootable
= None¶ (bool=False) –
-
subvariant
= None¶ (str) – image contents, may be same as variant or e.g. ‘KDE’, ‘LXDE’
-
unified
= None¶ (bool=False) – indicates if the ISO contains content from multiple variants
-
additional_variants
= None¶ ([str]) – indicates which variants are present on the ISO
-
dump
(f)¶ Dump data to a file.
Parameters: f (file or str) – file-like object or path to file
-
dumps
()¶ Dump data to a string.
Return type: str
-
load
(f)¶ Load data from a file.
Parameters: f (file or str) – file-like object or path to file
-
loads
(s)¶ Load data from a string.
Parameters: s (str) – input data
-
validate
()¶ Validate attributes by running all self._validate_*() methods.
Raises: - TypeError – if an attribute has invalid type
- ValueError – if an attribute contains invalid value
-