Skip to main content

Plugin for ploy to provision virtual machines using VirtualBox.

Project description

Overview

The ploy_virtualbox plugin provides integration of VirtualBox with ploy.

Installation

ploy_virtualbox is best installed with easy_install, pip or with zc.recipe.egg in a buildout.

Master

The default master for ploy_virtualbox is virtualbox and has the following options:

headless

Whether to start instances in headless mode by default. If not set, the system default is used.

use-acpi-powerbutton

Whether to use acpi power off by default when stopping instances. If not set, the system default is used.

basefolder

The basefolder for VirtualBox data. If not set, the VirtualBox default is used. This varies depending on the OS that ploy is running in. When not provided as absolute path, then it’s relative to ploy.conf.

instance

Name of instance to use to execute VirtualBox commands instead of the default local machine.

Example:

[vb-master:virtualbox]
headless = true

Instances

headless

Whether to start this instance in headless mode. If not set, the setting of the master is used.

use-acpi-powerbutton

Whether to use acpi power off for this instance when stopping. If not set, the setting of the master is used.

basefolder

The basefolder for this instances VirtualBox data. If not set, the setting of the master is used. When not provided as absolute path, then it’s relative to ploy.conf.

no-terminate

If set to yes, the instance can’t be terminated via ploy until the setting is changed to no or removed entirely.

Any option starting with vm- is stripped of the vm- prefix and passed on to VBoxManage. Almost all of these options are passed as is. The following options are handled differently or have some convenience added:

storage

One storage definition per line. See VBoxManage storageattach documentation for details.

If you don’t specify the type, then hdd is used by default.

You don’t have to specify the port, if not set the line number starting at zero is used.

If you don’t set --storagectl then sata is used as default and if that controller doesn’t exist it’s created automatically.

If medium references a local file that path will be passed directly to VBoxManage storageattach.

If it takes the form vb-disk:NAME which refers to a Disk section called NAME that will be used instead.

If it takes the form of an URL, the filename of that URL is assumed to be located at ~/.ploy/downloads/ (this default can be overridden in the [global] section of the configuration file with an entry download_dir). If the file does not exist it will be downloaded.

When using the URL notation it is strongly encouraged to also provide a checksum using the --medium_sha1 key (currently only SHA1 is supported).

Example for using a local ISO image as DVD drive:

storage =
    --type dvddrive --medium ~/downloads/archives/mfsbsd-se-9.2-RELEASE-amd64.iso
    --medium vb-disk:boot

Example for referencing an external URL:

storage =
    --type dvddrive --medium https://mfsbsd.vx.sk/files/iso/12/amd64/mfsbsd-se-12.0-RELEASE-amd64.iso --medium_sha1 2fbf2be5a79cc8081d918475400581bd54bb30ae
    --medium vb-disk:boot
hostonlyadapter

If there is a matching Host only interface section, then that is evaluated.

Disk sections

These section allow you to describe how disks should be created.

You can set the size, variant and format options as described in the VBoxManage createhd documentation.

The filename option allows you to set a filename for the disk, the extension is automatically added based on the format option. If you use a relative path, then it’s base is the basefolder setting of the instance.

When the delete option is set to false, the disk is not deleted when the instance using it is terminated. The default is to delete the disk upon instance termination.

Example:

[vb-disk:boot]
size = 102400

Host only interface sections

If you want to use host only network interfaces, then this allows you to make sure your settings are as expected and the interface exists. For now only the ip option is supported. See VBoxManage hostonlyif documentation for details.

Example:

[vb-hostonlyif:vboxnet0]
ip = 192.168.56.1

DHCP

If a vb-dhcpserver section with the same name exists, then it is checked and if needed configured as well. See VBoxManage hostonlyif documentation for details.

Example:

[vb-dhcpserver:vboxnet0]
ip = 192.168.56.2
netmask = 255.255.255.0
lowerip = 192.168.56.100
upperip = 192.168.56.254

The combination of vb-hostonlyif with vb-dhcpserver allows to configure a hostonly network with a deterministic IP address. In the above example you could configure an instance with a static IP address of 192.168.56.99 which would be addressable from the host. The important part is to chose an address that is within the DHCP server network but outside its DHCP pool, which is defined by lowerip and upperip respecitively.

SSH

Depending on the setup we can’t get the IP address or host name automatically.

Unfortunately VirtualBox doesn’t provide a way to see which instance got which IP address from it’s own DHCP servers for example.

If you know which host name or ip address your instance will have, then set the host or ip option as explained above in the hostonly section.

As a workaround you can also setup a NAT port forwarding like this:

vm-nic2 = nat
vm-natpf2 = ssh,tcp,,47022,,22

For this case ploy_virtualbox knows how to get the port and uses it for SSH access via localhost.

If you install the VirtualBox guest additions in your instance, then the status command can show you the current IP address of the instance.

Example config

[vb-master:virtualbox]
# use-acpi-powerbutton = false

[vb-disk:boot]
size = 102400

[vb-hostonlyif:vboxnet0]
ip = 192.168.56.1

[vb-dhcpserver:vboxnet0]
ip = 192.168.56.2
netmask = 255.255.255.0
lowerip = 192.168.56.100
upperip = 192.168.56.254

[vb-instance:foo]
# headless = true
vm-ostype = FreeBSD_64
vm-memory = 512
vm-accelerate3d = off
vm-acpi = on
vm-rtcuseutc = on
vm-boot1 = disk
vm-boot2 = dvd
vm-nic1 = hostonly
vm-hostonlyadapter1 = vboxnet0
vm-nic2 = nat
vm-natpf2 = ssh,tcp,,47022,,22
storage =
    --type dvddrive --medium ~/downloads/archives/mfsbsd-se-9.2-RELEASE-amd64.iso
    --medium vb-disk:boot

Changelog

2.0.0 - 2022-08-17

  • Dropped support for Python 3.6. [fschulze]

  • Added support for Python 3.10. [fschulze]

2.0.0b3 - 2021-07-17

  • Fix dhcpserver setup for newer VirtualBox versions. [fschulze]

2.0.0b2 - 2019-06-09

  • Fix tests for Python 3.x after ploy 2.0.0b3 release. [fschulze]

  • Drop support for Python 3.4. [fschulze]

2.0.0b1 - 2018-02-07

  • Support for ploy 2.0.0. [fschulze]

1.2.0 - 2015-09-03

  • Add delete option to disks. If set to false, the disk is kept in place upon instance termination and not deleted as per default. [fschulze]

  • Ask user whether to continue or not when checksum of downloaded iso image doesn’t match. [tomster]

1.1.0 - 2015-01-20

  • Log info when starting an instance. [fschulze]

  • Handle instances in aborted state. [fschulze]

  • Print error output of commands on failures. [fschulze]

  • Use new helper in ploy 1.0.2 to setup proxycommand. [fschulze]

  • Added possibility to specify a remote instance to use for a virtualbox master. [fschulze]

  • Added ability to reference disk images via external URL for virtualbox instances storage. [tomster]

1.0.0 - 2014-07-19

  • Added documentation. [fschulze]

  • Renamed vb-master to virtualbox, so the uids of instances are nicer. [fschulze]

  • Enable DHCP server when creating or modifying it. [fschulze]

1.0b4 - 2014-07-15

  • Verify and if possible create host only interfaces and dhcpservers. [fschulze]

  • Add support for instances that have manually been put into saved state. [fschulze]

1.0b3 - 2014-07-08

  • Packaging and test fixes. [fschulze]

1.0b2 - 2014-07-04

  • Python 3 compatibility. [fschulze]

  • Renamed mr.awsome to ploy and mr.awsome.virtualbox to ploy_virtualbox. [fschulze]

1.0b1 - 2014-06-16

  • Initial release [fschulze]

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

ploy_virtualbox-2.0.0.tar.gz (35.3 kB view details)

Uploaded Source

Built Distribution

ploy_virtualbox-2.0.0-py2.py3-none-any.whl (32.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file ploy_virtualbox-2.0.0.tar.gz.

File metadata

  • Download URL: ploy_virtualbox-2.0.0.tar.gz
  • Upload date:
  • Size: 35.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: devpi-server/6.1.0 (py3.8.6; darwin)

File hashes

Hashes for ploy_virtualbox-2.0.0.tar.gz
Algorithm Hash digest
SHA256 20d5f74b4c9691fb952b94a23b1fe4909610686f5c564a1055576ab194fd18e3
MD5 f4f4cbf6ff064c98c884223e886f9009
BLAKE2b-256 00a31bb8da054b60d233c5378be93b586b8aa325cd91c6265324b7205277a4c8

See more details on using hashes here.

File details

Details for the file ploy_virtualbox-2.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for ploy_virtualbox-2.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e071d2d65ba4996dea62c02408df6838120f422bdc57bb1c85c5309e673af0cb
MD5 9baf71fafcd0bd6a3e5f2d8fb33f01f6
BLAKE2b-256 079044fe914b09a8f9b899c3e66c4064ff787cfcd2451fedb8bdce6e614881f9

See more details on using hashes here.

Supported by

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