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

Alexey Eromenko al4321 at gmail.com
Mon Jun 4 23:37:02 GMT 2012


On Tue, Jun 5, 2012 at 2:23 AM, Armin Buescher <armbues at gmail.com> wrote:
> 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! :)
>

Please take a look at the GNS3 code, in python. www.gns3.net

-- 
-Alexey Eromenko "Technologov"




More information about the vbox-dev mailing list