Merge pull request #876 from tombee/virtualbox-env-vars

Added VIRTUALBOX_MEMORY_SIZE and VIRTUALBOX_DISK_SIZE env vars
This commit is contained in:
Evan Hazlett 2015-03-30 10:54:21 -04:00
commit ee6e6d76e0
3 changed files with 57 additions and 9 deletions

View File

@ -828,6 +828,18 @@ Options:
The VirtualBox driver uses the latest boot2docker image.
Environment variables:
Here comes the list of the supported variables with the corresponding options. If both environment
variable and CLI option are provided the CLI option takes the precedence.
| Environment variable | CLI option |
|-----------------------------------|-----------------------------------|
| `VIRTUALBOX_MEMORY_SIZE` | `--virtualbox-memory` |
| `VIRTUALBOX_CPU_COUNT` | `--virtualbox-cpu-count` |
| `VIRTUALBOX_DISK_SIZE` | `--virtualbox-disk-size` |
| `VIRTUALBOX_BOOT2DOCKER_URL` | `--virtualbox-boot2docker-url` |
#### VMware Fusion
Creates machines locally on [VMware Fusion](http://www.vmware.com/products/fusion). Requires VMware Fusion to be installed.

View File

@ -65,20 +65,22 @@ func init() {
func GetCreateFlags() []cli.Flag {
return []cli.Flag{
cli.IntFlag{
Name: "virtualbox-memory",
Usage: "Size of memory for host in MB",
Value: 1024,
EnvVar: "VIRTUALBOX_MEMORY_SIZE",
Name: "virtualbox-memory",
Usage: "Size of memory for host in MB",
Value: 1024,
},
cli.IntFlag{
EnvVar: "VIRTUALBOX_CPU_COUNT",
Name: "virtualbox-cpu-count",
Usage: "number of CPUs for the machine (-1 to use the number of CPUs available)",
EnvVar: "VIRTUALBOX_CPU_COUNT",
Value: -1,
},
cli.IntFlag{
Name: "virtualbox-disk-size",
Usage: "Size of disk for host in MB",
Value: 20000,
EnvVar: "VIRTUALBOX_DISK_SIZE",
Name: "virtualbox-disk-size",
Usage: "Size of disk for host in MB",
Value: 20000,
},
cli.StringFlag{
EnvVar: "VIRTUALBOX_BOOT2DOCKER_URL",

View File

@ -260,7 +260,7 @@ findCPUCount() {
@test "$DRIVER: check custom machine memory size" {
findMemorySize
[[ ${output} == "${CUSTOM_MEMSIZE}" ]]
[[ ${output} == "$CUSTOM_MEMSIZE" ]]
}
@test "$DRIVER: check custom machine disksize" {
@ -270,7 +270,7 @@ findCPUCount() {
@test "$DRIVER: check custom machine cpucount" {
findCPUCount
[[ ${output} == "${CUSTOM_CPUCOUNT}" ]]
[[ ${output} == "$CUSTOM_CPUCOUNT" ]]
}
@test "$DRIVER: machine should show running after create" {
@ -284,7 +284,41 @@ findCPUCount() {
[ "$status" -eq 0 ]
}
@test "$DRIVER: can create custom machine using disk size, cpu count and memory size via env vars" {
VIRTUALBOX_DISK_SIZE=$CUSTOM_DISKSIZE VIRTUALBOX_CPU_COUNT=$CUSTOM_CPUCOUNT VIRTUALBOX_MEMORY_SIZE=$CUSTOM_MEMSIZE run machine create -d $DRIVER $NAME
[ "$status" -eq 0 ]
}
@test "$DRIVER: check machine's memory size was set correctly by env var" {
findMemorySize
[[ ${output} == "$CUSTOM_MEMSIZE" ]]
}
@test "$DRIVER: check machine's disk size was set correctly by env var" {
findDiskSize
[[ ${output} == *"$CUSTOM_DISKSIZE"* ]]
}
@test "$DRIVER: check custom machine cpucount" {
findCPUCount
[[ ${output} == "$CUSTOM_CPUCOUNT" ]]
}
@test "$DRIVER: machine should show running after create with env" {
run machine ls
[ "$status" -eq 0 ]
[[ ${lines[1]} == *"Running"* ]]
}
@test "$DRIVER: remove after custom env create" {
run machine rm -f $NAME
[ "$status" -eq 0 ]
}
# Cleanup of machine store should always be the last 'test'
@test "$DRIVER: cleanup" {
run rm -rf $MACHINE_STORAGE_PATH
[ "$status" -eq 0 ]
}