41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
"""Thin CLI wrapper so folks can run the test-OVA builder without having
|
|
the package installed in their active env. Prefer `ova2vzdump create-test-ova`
|
|
when possible."""
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).parent.parent / "src"))
|
|
|
|
from ova2vzdump.test_ova import create_test_ova # noqa: E402
|
|
|
|
|
|
def main() -> None:
|
|
ap = argparse.ArgumentParser(description=__doc__)
|
|
ap.add_argument("output", type=Path)
|
|
ap.add_argument("--name", default="test-vm")
|
|
ap.add_argument("--size-mib", type=int, default=64)
|
|
ap.add_argument("--bootable", action="store_true",
|
|
help="Package pre-cached bootable Alpine image")
|
|
ap.add_argument("--force", action="store_true",
|
|
help="Overwrite existing output file")
|
|
args = ap.parse_args()
|
|
|
|
r = create_test_ova(
|
|
output=args.output, vm_name=args.name, size_mib=args.size_mib,
|
|
bootable=args.bootable, force=args.force,
|
|
)
|
|
if r.reused:
|
|
print(f"reused existing {r.path} ({r.bytes} bytes) "
|
|
"(pass --force to rebuild)")
|
|
else:
|
|
kind = "bootable Alpine" if r.bootable else "empty stub"
|
|
print(f"wrote {r.path} ({r.bytes} bytes, {kind})")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|