vbox.pl

As VBoxManage and VBoxHeadless commands and their options are not necessarily easy and/or fast to type, I wrote a Perl script to automatize usual operations, in a similar way than the GUI does.
Supported features are :

  • VM startup and shutdown.
  • Mount / Unmount of ISO files.
  • Creation / rollback / deletion of snapshots.
  • Creation / complete deletion of virtual machines.
  • By default, enable VNC acces on virtual machines.

The following parameters must be ajusted before using of the script :

#Script parameters
my $VM_PATH="./";         # Default path for VMs.
my $ISO_PATH="./";        # Default path of iso files.
my $NET_IF="lo0";         # Name of host adapter shared / hostonly interface.
my $DEFAULT_MEM=1024;     # Default memory for new VM (MB).
my $MIN_MEM=256;          # Minimum mermory for new VM (MB).
my $MAX_MEM=2048;         # Maximum memory for new VM (MB).
my $DEFAULT_DISK=20480;   # Default disk size for new VM (MB).
my $MIN_DISK=4096;        # Minimum disk size for new VM (MB).
my $MAX_DISK=40960;       # Maximum disk size for new VM (MB).

Created guests are quite simple : one HDD, one drive for the ISO file, one NAT network interface and another on the same network as the guest (as done by default by the GUI).

The script can be downloaded here (12 ko, Perl), and details about the various parameters used in the script are available in this article.