Skip to main content

vboxwebber

The purpose of this project is to provide a Python3 client for the VirtualBox remote webservices API. It is standalone in the way that it does not depend on the python libraries distributed with VirtualBox SDK (which to date only supports Python2 via the ancient ZSI library).

The client is generated from an XSL stylesheet and contains vbox API wrapper functions that uses zeep as SOAP-library under the hood for remote access.

The XSL stylesheet is based on the websrv-python.xsl file from the VirtualBox source package, but somewhat improved and modified to use zeep instead of ZSI. Documentation for classes and methods are also generated, hopefully removing the need of sitting with the SDK reference alongside when coding.

Installation

pip install vboxwebber

Usage

Initialize a web session manager by specifying the URL for the VirtualBox web service, and optionally the URL for the wsdl file. For older web services, I didn't manage to get the remote server's wsdl file, so it can be specified as a local file, e.g. "file:///tmp/vboxweb.wsdl".

The service and interface methods should be the same as when using the official SDK, so porting old code should be easy. Classes are generated for enums etc., but it is recommended to combine with the VirtualBox_constants.py from the SDK (which is also generated from the constants-python.xsl stylesheet - encorporating this into the same file is a TODO).

from vboxwebber import *

# Initiate the client
mgr = IWebsessionManager2("http://localhost:18083")

# Logon, get the IVirtualBox object
vbox = mgr.logon("username", "password")

# Print API version
print(vbox.getAPIVersion())

# Find machine
machine = vbox.findMachine("kali2019.4")

# Get the session object
session =  mgr.getSessionObject(vbox)

# Lock the machine to the session
machine.lockMachine(session, SessionType.WriteLock)

# Get the display
display = session.console.display

# Get screen resolution info
width, height, _bpp, _xo, _yo, _status = display.getScreenResolution(0)

# Take a screenshot
screenshot = display.takeScreenShotToArray(0, width, height, "PNG")

# Write data to file
with open("/tmp/screenshot.png", "wb") as f:
    f.write(screenshot)

# Log off, cleaning up resources (implicit, at least for newer vbox versions)
mgr.logoff(vbox)

Generating new API wrappers

The VirtualBox API doesn't change much, but should the need arise, it is easy to generate a new wrapper based on a specific VirtualBox release. Just download the VirtualBox source code package, put the xsl stylesheet in src/VBox/Main/webservice and run:

xsltproc websrv-zeep.xsl ../idl/VirtualBox.xidl > vboxwebber.py

TODO's

  • Conditionalize the generation of documentation?
  • Modify the VirtualBox glue code to include this as a platform?
  • Generate even better documentation with docstring syntax etc.

Help

Improvements are welcome.

Metadata

Release files for vboxwebber 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vboxwebber 0.1.0
File Size Uploaded
vboxwebber-0.1.0.tar.gz 270.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for vboxwebber 0.1.0
File Interpreter ABI Platform
vboxwebber-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 551.7 kB

Release files / vboxwebber-0.1.0.tar.gz

Download URL vboxwebber-0.1.0.tar.gz
Size 270.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f048cf584be0383d0c1a23faf4094d194f81944dc2847e2056781125411fcda8
BLAKE2b-256 checksum
How to use checksums
4a09294ebae14a0d909bdb30667c36d875f870aa8084da160c6b315bbb23a85a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.9

Release files / vboxwebber-0.1.0-py3-none-any.whl

Download URL vboxwebber-0.1.0-py3-none-any.whl
Size 281.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fc36a86b2e05d8302e998ad593ddb28c33802f8b786e550d24b4430698d6a670
BLAKE2b-256 checksum
How to use checksums
18ea1a9d48de9ab485d7a5a468938e0005ff1f1375a0c3a5b76cc109814c9b11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.9

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page