libvirt_vmcfg
libvirt_vmcfg is a library for generating XML VM specifications for use in libvirt.
It's in an alpha state but pull requests welcome.
Documentation is poor at the moment as I have other priorities. When I have time, I'll create better docs.
Examples
Domain builder
from lxml import etree
from libvirt_vmcfg.dom.profiles.linux_virtio import kvm_default_hardware
from libvirt_vmcfg.dom.elements.devices import BridgedInterface
from libvirt_vmcfg.dom.elements.devices import DiskTargetCDROM, DiskTargetDisk
from libvirt_vmcfg.dom.elements.devices import (DiskSourceBlockPath,
DiskSourceNetHTTP, TargetBus)
from libvirt_vmcfg.dom.elements.devices import (Driver, DriverType,
DriverCache, DriverIO,
DriverOptions)
from libvirt_vmcfg.dom.elements.devices import Disk
from libvirt_vmcfg.dom.util.disk import disk_letter
from libvirt_vmcfg.dom import Domain
dev = disk_letter("vd")
elements = kvm_default_hardware(name="poopty", vcpus=2, memory=64*(1024**2),
boot_dev_order=["hd"])
# Build up the disk
source_disk = DiskSourceBlockPath("/dev/zeta-vg/debian-test-01")
target_disk = DiskTargetDisk(next(dev), bus=TargetBus.VIRTIO)
driver_opts_disk = DriverOptions(driver=Driver.QEMU, type=DriverType.RAW,
cache=DriverCache.NONE, io=DriverIO.NATIVE)
disk = Disk(source_disk, target_disk, driver_opts_disk, False)
# Now the CD
source_http = DiskSourceNetHTTP("http://localhost/install/install.iso")
target_cdrom = DiskTargetCDROM(next(dev), bus=TargetBus.VIRTIO)
driver_opts_cdrom = DriverOptions(driver=Driver.QEMU)
cdrom = Disk(source_http, target_cdrom, driver_opts_cdrom, True)
# Specify the Interface
interface = BridgedInterface("br0")
elements.extend((disk, cdrom, interface))
d = Domain(elements=elements)
print(repr(d))
print(d.emit_xml(pretty_print=True))
Volumes
from libvirt_vmcfg.vol import Volume
GIGABYTE = 1073741824
# Note the default unit for volumes is gigabytes
vol = Volume(name="test", size=3 * GIGABYTE)
print(vol.emit_xml(pretty_print=True))
TODO
A lot. I'll get around to most of these eventually. I hope. I'm sadly quite busy these days.
- More interface types
- More disk types, like LUNs
- More hardware profiles, like for Windows, old Linux, BSD, etc.
- More hardware that isn't virtio
- More hardware, period
- More hardware options, like more timers, etc.
- More hypervisors (Xen, VirtualBox, VMWare Workstation, and ESXi are probably the only other relevant ones)
- Ensure hypervisor portability
- Investigate other architectures, like ppc64le and aarch64, add relevant bits from those
- Ensure portability to said platforms
- Documentation
- Make
volumeinteroperate withdomainwhere relevant - Flesh out
volmodule
Contributions
See the contributing file for more information.
License
CC0, dedicated to the public domain. Do whatever you want with it.
Unfortunately I have to say this, because this comes up a lot in other projects. Let me make it clear: the project "licensing" (insofar a public domain dedication can be considered a license) is not up for debate. I wanted CC0 and it was a deliberate thoughtful choice. I am fully aware of its ramifications and have no intention to reverse my course on the matter. I was not — nor am not — willing or even able to enforce any restrictions on people or companies. Just do what you want with this. Relicensing is allowed; you may do so if you wish. Or don't. I don't care one way or the other.
Say thanks
You can thank me at my Say Thanks.
You can also donate to help keep me afloat during these tough times.
Metadata
Release files for libvirt-vmcfg 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| libvirt_vmcfg-0.0.3.tar.gz | 18.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| libvirt_vmcfg-0.0.3-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 45.8 kB
Release files / libvirt_vmcfg-0.0.3.tar.gz
| Download URL | libvirt_vmcfg-0.0.3.tar.gz |
|---|---|
| Size | 18.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a3052a35f7c7b5eb719d65884e249f2561d099e2fee80fbb6f180f056d816091
|
|
BLAKE2b-256 checksum How to use checksums |
a1a7e2e8cac639a6ff8bec6ece46cad570c62454b4bb8c727e2f9a043b781d9e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1
|
Release files / libvirt_vmcfg-0.0.3-py2.py3-none-any.whl
| Download URL | libvirt_vmcfg-0.0.3-py2.py3-none-any.whl |
|---|---|
| Size | 27.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
c864a014668d8198f165af6362b29fa9205ef0b09dd3698a89bd89e02a1600c4
|
|
BLAKE2b-256 checksum How to use checksums |
02b57fcbc317d85add978c48e94a8015ce7bb200ed60ae607d0ed75c127d3e95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1
|
Security for libvirt-vmcfg 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.