Skip to main content

An interactive command line interface for VirtualBox.

Project description

VBox Operator

v0.0.4

An interactive command line interface for VirtualBox.

Supported Features:

  1. Commands and VM name auto-completion.
  2. Start, stop, and pause VMs.
  3. Restore snapshots.
  4. Copy files and directories to guest VMs.

Usage

asciicast

Installation

> python3 -m pip install vbox-operator
> vbox-operator

Library Usage

Example: Listing running VMs and getting the status of each one.

from vbox_operator.operations import *

vm_list = list_vms() # returns a dict of lists
for vm in vm_list["running"]:
    vm_name = vm["name"]
    print(f'Running: {vm_name}')
    vm_state = state_vm(vm["uuid"])
    print(f'  > {vm_state}')

Below is a list of all implemented methods, I did my best to make the naming as self explanatory as possible:

# returns dict of lists: 
# {"all": [], "running": []}
# while each list is a list of dicts: {"name": "VM NAME", "uuid": "VM UUID}
list_vms()

### For all methods below which take param "vm",
# you may pass the VM name or UUID as a VM identifier.
# However, it is best to provide the VM UUID, as it may prevent some issues.
start_vm_headless(vm)
start_vm(vm)
state_vm(vm)
# Pull power plug on the VM
poweroff_vm(vm)
# Send ACPI shutdown signal to VM (power button)
acpipower_vm(vm)
# restart VM
reset_vm(vm)
pause_vm(vm)

# Returns a list of dicts: [{"name": "SNAPSHOT NAME", "uuid": "SNAPSHOT UUID},]
list_snapshots(vm)

# param snapshot is expected to be a snapshot identifier,
# it is best to pass the snapshot UUID instead of the VM name.
restore_vm(vm, snapshot)

### The methods below expect the username and password of the guest VM,
# and the direction of the operations is Host to Guest.
mkdir_vm(username, password, vm, directory)
copyfile_vm(username, password, vm, src_file, dst)
copydir_vm(username, password, vm, src_dir, dst)

Support

This tool was developed and tested on ubuntu 18.04 with the following installed:

  1. VirtualBox v6.1.x
  2. Python >= 3.6

I ran a quick test on MacOS and it worked.

By theory, it should work on Windows as well if VirtualBox's vboxmanage binary is available in your PATH.

Note that for certain features like copying files and dirs, the guest VM must have guest additions installed.

Current Limitations

The command line interface does not support VM and snapshot names which contain spaces, however, you can use the VM UUID or snapshot UUID instead.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vbox-operator-0.0.4.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vbox_operator-0.0.4-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file vbox-operator-0.0.4.tar.gz.

File metadata

  • Download URL: vbox-operator-0.0.4.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.9

File hashes

Hashes for vbox-operator-0.0.4.tar.gz
Algorithm Hash digest
SHA256 aa2c9c3385c0f2d62618a51648c915a6351f78cc3e42eec69360059961031673
MD5 092480073f732402cc3a3f6b6fa5aa34
BLAKE2b-256 c2dfb98d39d13576bc70ec243d432c6e3d5d4c6682988a8dc4d8bf3a312da39b

See more details on using hashes here.

File details

Details for the file vbox_operator-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: vbox_operator-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.9

File hashes

Hashes for vbox_operator-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ae36418ffe23e831d6a0be0c7f11aa207b432edce3c43e2438e6919136962da4
MD5 62529eb12e8c454899679f7bf6c740f0
BLAKE2b-256 ef9910f45c2a46284925e41680586a44ac3a56195570810c10ea47ab1d818d77

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page