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)
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>]
Classes
- class productmd.images.Images
- add(variant, arch, image)
Assign an
Imageobject 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
(str) – relative path to an image, for example: “Server/x86_64/iso/boot.iso”
- mtime
(int) – image mtime
- size
(int) – image size
- volume_id
(str) –
- type
(str) –
- format
(str) – Release name, for example: “Fedora”, “Red Hat Enterprise Linux”
- arch
(str) – image architecture, for example: “x86_64”, “src”
- disc_number
(int) – Release name, for example: “Fedora”, “Red Hat Enterprise Linux”
- disc_count
(int) – Release name, for example: “Fedora”, “Red Hat Enterprise Linux”
- checksums
(str) – Release name, for example: “Fedora”, “Red Hat Enterprise Linux”
- implant_md5
(str or None) – value of implanted md5
- bootable
(bool=False) –
- subvariant
(str) – image contents, may be same as variant or e.g. ‘KDE’, ‘LXDE’
- unified
(bool=False) – indicates if the ISO contains content from multiple variants
- additional_variants
([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