From 1c4bbb2f850893a50bfa50715330e61057b2e3f0 Mon Sep 17 00:00:00 2001 From: braniz Date: Sat, 21 Oct 2023 08:04:49 +0200 Subject: [PATCH] . --- vbox_api.py | 24 ++++++++++++++++++++++++ vbox_create.py | 27 +++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 vbox_api.py create mode 100644 vbox_create.py diff --git a/vbox_api.py b/vbox_api.py new file mode 100644 index 0000000..1c7e2c9 --- /dev/null +++ b/vbox_api.py @@ -0,0 +1,24 @@ +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)) diff --git a/vbox_create.py b/vbox_create.py new file mode 100644 index 0000000..28f1f9d --- /dev/null +++ b/vbox_create.py @@ -0,0 +1,27 @@ +from virtualbox import Library, VirtualBox + +# Initialisiere die VirtualBox-Library +Library.py_locate() + +# Öffne die VirtualBox-Anwendung +vbox = VirtualBox() + +# Erstelle eine neue virtuelle Maschine +vm = vbox.create_machine("MyVM", "Linux", "Ubuntu_64", []) + +# Konfiguriere die virtuelle Maschine +vm.memory_size = 1024 # 1 GB RAM +vm.os_type_id = "Ubuntu_64" + +# Erstelle einen neuen Festplattencontroller und eine Festplatte +controller = vm.add_storage_controller("SATA") +vm.attach_device(controller, 0, 0, "hdd", "None", "MyDisk.vdi") + +# Erstelle eine Netzwerkkarte +network_adapter = vm.get_network_adapter(0) +network_adapter.attachment_type = "Bridged" + +# Speichere die virtuelle Maschine +vbox.register_machine(vm) + +print("Virtuelle Maschine erstellt: {}".format(vm.name))