osbuild
Provides utilities for creating, importing and using Image Builder made images for virtual machines, and a context manager to use them as VMs.
The classes and methods are derived from lib.virt, but instead of installing VMs via Guest.install(), they are created from images via Guest.create().
import osbuild
osbuild.Host.setup() g = osbuild.Guest()
# optional blueprint = osbuild.Blueprint() blueprint.add_something( … )
g.create(blueprint=blueprint)
- with g.booted():
g.ssh( … ) g.ssh( … )
Snapshotting is currently not supported/tested with this approach.
Module Contents
- class osbuild.ComposerRepos
These are so-called “system” repositories recognized by osbuild-composer, not Blueprint customizations.
Note that these are not equivalent to ‘composer-cli sources’ - the docs make it seem like so, but osbuild developers confirmed that only the .json repos are used for the build process.
- ETC_REPOS
- USR_REPOS
- repos = []
- add_host_repos()
- assemble()
- to_composer()
- class osbuild.Compose
-
- RUNNING_STATUSES = ['WAITING', 'RUNNING']
- FINISHED_STATUSES = ['FINISHED', 'FAILED']
- classmethod build(blueprint_name)
- class osbuild.Blueprint(template=TEMPLATE)
- NAME = 'contest_blueprint'
- TEMPLATE
- assembled = Multiline-String
Show Value
"""Uninferable """
- add_user(name, *, password=None, groups=None, ssh_pubkey=None)
- add_package(name)
- add_package_group(name)
- add_partition(mountpoint, minsize)
- set_openscap_datastream(ds_file)
- to_tmpfile()
- to_composer()
- class osbuild.Guest(*args, **kwargs)
Bases:
lib.virt.Guest
- osbuild_log
- wipe()
- abstract install(**kwargs)
- create_basic(*, blueprint=None, **kwargs)
Create a guest disk image via osbuild, and import it as a new guest domain into libvirt.
If ‘blueprint’ is given as a ‘class Blueprint’ instance, it is used for further customizations instead of a fresh Blueprint instance.
- create(*, blueprint=None, rpmpack=None, **kwargs)
Create a guest disk image via osbuild, suitable for scanning via openscap.
If custom ‘rpmpack’ is specified (RpmPack instance), it is used instead of a self-made instance.
- osbuild.composer_cli(*args, log=True, check=True, **kwargs)
- osbuild.composer_cli_out(*args, **kwargs)
- osbuild.translate_oscap_blueprint(lines, datastream)
Parse (and tweak) a blueprint generated via ‘oscap xccdf generate fix’.