Files
virtualbox/dev/vbox_api.py
2023-11-09 13:08:06 +01:00

25 lines
739 B
Python

from pyvbox import VirtualBox
# Verbindung zur VirtualBox-Instanz herstellen
vbox = VirtualBox()
# Erstellen Sie eine neue virtuelle Maschine
vm = vbox.create_machine("MyVM", "Linux", "Ubuntu_64", [])
# Konfigurieren Sie die virtuelle Maschine
vm.memory_size = 1024 # 1 GB RAM
vm.os_type_id = "Ubuntu_64"
# Erstellen Sie einen neuen Festplattencontroller und eine Festplatte
controller = vm.add_storage_controller("SATA")
vm.attach_device(controller, 0, 0, "hdd", "None", "MyDisk.vdi")
# Erstellen Sie eine Netzwerkkarte
network_adapter = vm.get_network_adapter(0)
network_adapter.attachment_type = "Bridged"
# Speichern Sie die virtuelle Maschine
vbox.register_machine(vm)
print("Virtuelle Maschine erstellt: {}".format(vm.name))