Allow virtualbox DNSProxy override

Signed-off-by: Jean-Laurent de Morlhon <jeanlaurent@morlhon.net>
This commit is contained in:
Jean-Laurent de Morlhon 2015-12-01 15:57:02 +01:00
parent cf85b11344
commit b7b767aafe
4 changed files with 31 additions and 1 deletions

View File

@ -32,6 +32,7 @@ Options:
- `--virtualbox-hostonly-nictype`: Host Only Network Adapter Type. Possible values are are '82540EM' (Intel PRO/1000), 'Am79C973' (PCnet-FAST III) and 'virtio-net' Paravirtualized network adapter. - `--virtualbox-hostonly-nictype`: Host Only Network Adapter Type. Possible values are are '82540EM' (Intel PRO/1000), 'Am79C973' (PCnet-FAST III) and 'virtio-net' Paravirtualized network adapter.
- `--virtualbox-hostonly-nicpromisc`: Host Only Network Adapter Promiscuous Mode. Possible options are deny , allow-vms, allow-all - `--virtualbox-hostonly-nicpromisc`: Host Only Network Adapter Promiscuous Mode. Possible options are deny , allow-vms, allow-all
- `--virtualbox-no-share`: Disable the mount of your home directory - `--virtualbox-no-share`: Disable the mount of your home directory
- `--virtualbox-dns-proxy`: Proxy all DNS requests to the host (Boolean value, default to false)
The `--virtualbox-boot2docker-url` flag takes a few different forms. By The `--virtualbox-boot2docker-url` flag takes a few different forms. By
default, if no value is specified for this flag, Machine will check locally for default, if no value is specified for this flag, Machine will check locally for
@ -72,3 +73,4 @@ Environment variables and default values:
| `--virtualbox-hostonly-nictype` | `VIRTUALBOX_HOSTONLY_NIC_TYPE` | `82540EM` | | `--virtualbox-hostonly-nictype` | `VIRTUALBOX_HOSTONLY_NIC_TYPE` | `82540EM` |
| `--virtualbox-hostonly-nicpromisc` | `VIRTUALBOX_HOSTONLY_NIC_PROMISC` | `deny` | | `--virtualbox-hostonly-nicpromisc` | `VIRTUALBOX_HOSTONLY_NIC_PROMISC` | `deny` |
| `--virtualbox-no-share` | `VIRTUALBOX_NO_SHARE` | `false` | | `--virtualbox-no-share` | `VIRTUALBOX_NO_SHARE` | `false` |
| `--virtualbox-dns-proxy` | `VIRTUALBOX_DNS_PROXY | `false` |

View File

@ -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-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-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-disk-size "20000" Size of disk for host in MB [$VIRTUALBOX_DISK_SIZE]
--virtualbox-dns-proxy Proxy all DNS requests to the host [$VIRTUALBOX_DNS_PROXY]
--virtualbox-hostonly-cidr "192.168.99.1/24" Specify the Host Only CIDR [$VIRTUALBOX_HOSTONLY_CIDR] --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-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] --virtualbox-hostonly-nictype "82540EM" Specify the Host Only Network Adapter Type [$VIRTUALBOX_HOSTONLY_NIC_TYPE]

View File

@ -56,6 +56,7 @@ type Driver struct {
HostOnlyNicType string HostOnlyNicType string
HostOnlyPromiscMode string HostOnlyPromiscMode string
NoShare bool NoShare bool
DNSProxy bool
} }
// NewDriver creates a new VirtualBox driver with default settings. // NewDriver creates a new VirtualBox driver with default settings.
@ -132,6 +133,11 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
Usage: "Disable the mount of your home directory", Usage: "Disable the mount of your home directory",
EnvVar: "VIRTUALBOX_NO_SHARE", EnvVar: "VIRTUALBOX_NO_SHARE",
}, },
mcnflag.BoolFlag{
Name: "virtualbox-dns-proxy",
Usage: "Proxy all DNS requests to the host",
EnvVar: "VIRTUALBOX_DNS_PROXY",
},
} }
} }
@ -177,6 +183,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
d.HostOnlyNicType = flags.String("virtualbox-hostonly-nictype") d.HostOnlyNicType = flags.String("virtualbox-hostonly-nictype")
d.HostOnlyPromiscMode = flags.String("virtualbox-hostonly-nicpromisc") d.HostOnlyPromiscMode = flags.String("virtualbox-hostonly-nicpromisc")
d.NoShare = flags.Bool("virtualbox-no-share") d.NoShare = flags.Bool("virtualbox-no-share")
d.DNSProxy = flags.Bool("virtualbox-dns-proxy")
return nil return nil
} }
@ -302,6 +309,11 @@ func (d *Driver) Create() error {
cpus = 32 cpus = 32
} }
dnsProxy := "off"
if d.DNSProxy {
dnsProxy = "on"
}
if err := d.vbm("modifyvm", d.MachineName, if err := d.vbm("modifyvm", d.MachineName,
"--firmware", "bios", "--firmware", "bios",
"--bioslogofadein", "off", "--bioslogofadein", "off",
@ -315,7 +327,7 @@ func (d *Driver) Create() error {
"--ioapic", "on", "--ioapic", "on",
"--rtcuseutc", "on", "--rtcuseutc", "on",
"--natdnshostresolver1", "off", "--natdnshostresolver1", "off",
"--natdnsproxy1", "off", "--natdnsproxy1", dnsProxy,
"--cpuhotplug", "off", "--cpuhotplug", "off",
"--pae", "on", "--pae", "on",
"--hpet", "on", "--hpet", "on",

View File

@ -0,0 +1,15 @@
#!/usr/bin/env bats
load ${BASE_TEST_DIR}/helpers.bash
only_if_env DRIVER virtualbox
@test "$DRIVER: Create a vm with a dns proxy set" {
run machine create -d $DRIVER --virtualbox-dns-proxy=true $NAME
[[ ${status} -eq 0 ]]
}
@test "$DRIVER: Check DNSProxy flag is properly set during machine creation" {
run bash -c "cat ${MACHINE_STORAGE_PATH}/machines/$NAME/$NAME/Logs/VBox.log | grep DNSProxy | grep '(1)'"
[[ ${status} -eq 0 ]]
}