[vbox-dev] How to start a VM from Python/COM ?
Alexey Eromenko
al4321 at gmail.com
Sun Jan 30 11:51:58 PST 2011
TRY 3:
This code I copied from "2.3.2 Common Python bindings layer" SDK PDF,
and modified a bit.
==============================================================
#!/usr/bin/python
# -*- coding: utf-8 -*-
# This code assumes vboxapi.py from VirtualBox distribution
# being in PYTHONPATH, or installed system-wide
from vboxapi import VirtualBoxManager
# This code initializes VirtualBox manager with default style
# and parameters
virtualBoxManager = VirtualBoxManager(None, None)
vbox = virtualBoxManager.vbox
mgr = virtualBoxManager.mgr
print "Version is",vbox.version
def machById(id):
mach = None
for m in virtualBoxManager.getArray(vbox, ’machines’):
if m.name == id or mach.id == id:
mach = m
break
return mach
----
Host: Mandriva Linux 2010, x64, python-2.6.4 (distro standard), VBox 4.0.2
Execution of this code fails:
[root at localhost sample]# ./vbox_adevel04.py
File "./vbox_adevel04.py", line 18
for m in virtualBoxManager.getArray(vbox, ’machines’):
SyntaxError: invalid syntax
----
python dislikes the ’machines’ parameter.
---
-Alexey Eromenko "Technologov"
More information about the vbox-dev
mailing list