diff --git a/stages/org.osbuild.ovf b/stages/org.osbuild.ovf index 06256bbd..25942533 100755 --- a/stages/org.osbuild.ovf +++ b/stages/org.osbuild.ovf @@ -1,20 +1,22 @@ #!/usr/bin/python3 import json import os +import random import subprocess import sys +import uuid import osbuild.api from osbuild.util import checksum OVF_TEMPLATE = """ - + Virtual disk information - + The list of logical networks @@ -84,11 +86,56 @@ OVF_TEMPLATE = """ + + Complete VirtualBox machine configuration in VirtualBox format + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + """ +def vbox_mac_address(): + # https://github.com/mirror/vbox/blob/b9657cd5351cf17432b664009cc25bb480dc64c1/src/VBox/Main/src-server/HostImpl.cpp#L3267 + # VirtualBox-6.1.12 src/VBox/NetworkServices/Dhcpd/Config.cpp line 276 + mac_address = "080027" + for _ in range(0, 3): + mac_address += "".join(random.sample("0123456789abcdef", 2)) + return mac_address + + def virtual_size(vmdk): cmd = ["qemu-img", "info", "--output=json", vmdk] res = subprocess.run( @@ -107,6 +154,10 @@ def write_template(vmdk): ovf_data = OVF_TEMPLATE.format( vmdk_size=os.stat(vmdk).st_size, vmdk_capacity=virtual_size(vmdk), + vbox_machine_uuid=str(uuid.uuid4()), + vbox_disk_uuid=str(uuid.uuid4()), + vbox_os_type="ArchLinux_64", + vbox_mac_address=vbox_mac_address(), image_name=basename, )