Skip to content
This repository has been archived by the owner on Sep 26, 2021. It is now read-only.

Commit

Permalink
Add the --virtualbox-host-dns-resolver flag
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Friedl <joe@joefriedl.net>
  • Loading branch information
grampajoe committed Nov 28, 2015
1 parent 5aff328 commit f8a3149
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/drivers/virtualbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Options:
- `--virtualbox-memory`: Size of memory for the host in MB.
- `--virtualbox-cpu-count`: Number of CPUs to use to create the VM. Defaults to single CPU.
- `--virtualbox-disk-size`: Size of disk for the host in MB.
- `--virtualbox-host-dns-resolver`: Use the host DNS resolver.
- `--virtualbox-boot2docker-url`: The URL of the boot2docker image. Defaults to the latest available version.
- `--virtualbox-import-boot2docker-vm`: The name of a Boot2Docker VM to import.
- `--virtualbox-hostonly-cidr`: The CIDR of the host only adapter.
Expand Down Expand Up @@ -66,6 +67,7 @@ Environment variables and default values:
| `--virtualbox-memory` | `VIRTUALBOX_MEMORY_SIZE` | `1024` |
| `--virtualbox-cpu-count` | `VIRTUALBOX_CPU_COUNT` | `1` |
| `--virtualbox-disk-size` | `VIRTUALBOX_DISK_SIZE` | `20000` |
| `--virtualbox-host-dns-resolver` | `VIRTUALBOX_HOST_DNS_RESOLVER` | `false` |
| `--virtualbox-boot2docker-url` | `VIRTUALBOX_BOOT2DOCKER_URL` | _Latest boot2docker url_ |
| `--virtualbox-import-boot2docker-vm` | `VIRTUALBOX_BOOT2DOCKER_IMPORT_VM` | `boot2docker-vm` |
| `--virtualbox-hostonly-cidr` | `VIRTUALBOX_HOSTONLY_CIDR` | `192.168.99.1/24` |
Expand Down
1 change: 1 addition & 0 deletions docs/reference/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ invoking the `create` help text.
--virtualbox-boot2docker-url The URL of the boot2docker image. Defaults to the latest available version [$VIRTUALBOX_BOOT2DOCKER_URL]
--virtualbox-cpu-count "1" number of CPUs for the machine (-1 to use the number of CPUs available) [$VIRTUALBOX_CPU_COUNT]
--virtualbox-disk-size "20000" Size of disk for host in MB [$VIRTUALBOX_DISK_SIZE]
--virtualbox-host-dns-resolver Use the host DNS resolver [$VIRTUALBOX_HOST_DNS_RESOLVER]
--virtualbox-hostonly-cidr "192.168.99.1/24" Specify the Host Only CIDR [$VIRTUALBOX_HOSTONLY_CIDR]
--virtualbox-hostonly-nicpromisc "deny" Specify the Host Only Network Adapter Promiscuous Mode [$VIRTUALBOX_HOSTONLY_NIC_PROMISC]
--virtualbox-hostonly-nictype "82540EM" Specify the Host Only Network Adapter Type [$VIRTUALBOX_HOSTONLY_NIC_TYPE]
Expand Down
14 changes: 13 additions & 1 deletion drivers/virtualbox/virtualbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type Driver struct {
DiskSize int
Boot2DockerURL string
Boot2DockerImportVM string
HostDNSResolver bool
HostOnlyCIDR string
HostOnlyNicType string
HostOnlyPromiscMode string
Expand Down Expand Up @@ -109,6 +110,11 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
Value: defaultBoot2DockerImportVM,
EnvVar: "VIRTUALBOX_BOOT2DOCKER_IMPORT_VM",
},
mcnflag.BoolFlag{
Name: "virtualbox-host-dns-resolver",
Usage: "Use the host DNS resolver",
EnvVar: "VIRTUALBOX_HOST_DNS_RESOLVER",
},
mcnflag.StringFlag{
Name: "virtualbox-hostonly-cidr",
Usage: "Specify the Host Only CIDR",
Expand Down Expand Up @@ -173,6 +179,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
d.SwarmDiscovery = flags.String("swarm-discovery")
d.SSHUser = "docker"
d.Boot2DockerImportVM = flags.String("virtualbox-import-boot2docker-vm")
d.HostDNSResolver = flags.Bool("virtualbox-host-dns-resolver")
d.HostOnlyCIDR = flags.String("virtualbox-hostonly-cidr")
d.HostOnlyNicType = flags.String("virtualbox-hostonly-nictype")
d.HostOnlyPromiscMode = flags.String("virtualbox-hostonly-nicpromisc")
Expand Down Expand Up @@ -302,6 +309,11 @@ func (d *Driver) Create() error {
cpus = 32
}

hostDNSResolver := "off"
if d.HostDNSResolver {
hostDNSResolver = "on"
}

if err := d.vbm("modifyvm", d.MachineName,
"--firmware", "bios",
"--bioslogofadein", "off",
Expand All @@ -314,7 +326,7 @@ func (d *Driver) Create() error {
"--acpi", "on",
"--ioapic", "on",
"--rtcuseutc", "on",
"--natdnshostresolver1", "off",
"--natdnshostresolver1", hostDNSResolver,
"--natdnsproxy1", "off",
"--cpuhotplug", "off",
"--pae", "on",
Expand Down
16 changes: 16 additions & 0 deletions test/integration/virtualbox/host-dns.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bats

load ${BASE_TEST_DIR}/helpers.bash

only_if_env DRIVER virtualbox

@test "$DRIVER: create with host dns resolver flag" {
run machine create -d $DRIVER --virtualbox-host-dns-resolver $NAME
[ "$status" -eq 0 ]
}

@test "$DRIVER: machine should show running after create" {
run machine ls
[ "$status" -eq 0 ]
[[ ${lines[1]} == *"Running"* ]]
}

0 comments on commit f8a3149

Please sign in to comment.