[vbox-dev] Python API unable to change NIC properties

Armin Buescher armbues at gmail.com
Mon Jun 4 23:23:49 GMT 2012


Hey all!

I'm using the VirtualBox COM API to start/stop/control a bunch of VMs 
using a Python script.
A functionality I don't get to work is change the properties of a 
network interface programmatically while the VM is running.

The same functionality works using the commandline tool 'vboxmanage 
controlvm':
 > vboxmanage controlvm VMNAME setlinkstate1 off

In Python this code doesn't have any effect on the running machine:
    mgr = vboxapi.VirtualBoxManager(None, None)
    session = mgr.getSessionObject(vm.vbox)
    VBOX_INFO = VirtualBoxReflectionInfo(False)
    vm.machine.lockMachine(session, vboxapi.VBOX_INFO.LockType_Shared)
    adapter = session.machine.getNetworkAdapter(1)
    adapter.cableConnected = False
    session.unlockMachine()

Does this have something to do with the way the session I lock the 
session? I tried vboxshell.py with the same outcome.

Thanks in advance! :)

Armin




More information about the vbox-dev mailing list