My project will install a VM on a client computer. The VM will need to use a Host-Only network adapter on slot 1, so, there are 2 cases: 1) there is no such adapter and the project installer will create one, 2) There is an existing one to use. After resolving that, the installer will add that adapter in the second slot. I have tried using the Python API
vm.get_network_adapter(1).host_only_interface = "name of adapter"
but, "The machine is not mutable ..." is the error. I have assumed that meant I did not have a write lock for the machine, so, I tried creating a session and locking the VM, but, no luck. Is that the way to proceed, or, is there a different way?
how to modify the VM
-
- Volunteer
- Posts: 2561
- Joined: 30. May 2007, 18:05
- Primary OS: Fedora other
- VBox Version: PUEL
- Guest OSses: XP, Win7, Win10, Linux, OS/2
Re: how to modify the VM
Did you try this while the VM was off / shut down? Many changes cannot be done when the VM is active.
-
- Posts: 7
- Joined: 18. Feb 2016, 17:53
Re: how to modify the VM
The machine member of the session object is mutable, e.g.,
vbmanager = virtualbox.Manager()
vbox = vbmanager.get_virtualbox()
session = vbmanager.get_session()
host = vbox.host
vm = vbox.find_machine('vm name'')
rc = vm.lock_machine(session,virtualbox.library.LockType.write)
then, session.machine can be modified.
vbmanager = virtualbox.Manager()
vbox = vbmanager.get_virtualbox()
session = vbmanager.get_session()
host = vbox.host
vm = vbox.find_machine('vm name'')
rc = vm.lock_machine(session,virtualbox.library.LockType.write)
then, session.machine can be modified.