added support for configuring nictype and nicpromise mode in virtualbox

Signed-off-by: Palanivelrajan Balasubramanian <praveen12bnitt@gmail.com>
This commit is contained in:
Palanivelrajan Balasubramanian 2015-08-19 16:36:49 -04:00
parent 9661bf89e1
commit 5f362aca6b
2 changed files with 33 additions and 10 deletions

View File

@ -29,6 +29,8 @@ Options:
- `--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.
- `--virtualbox-hostonly-nictype`: Host Only Network Adapter Type. Possible values are are '82540EM' (Intel PRO/1000) and 'Am79C973' (PCnet-FAST III)
- `--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
The `--virtualbox-boot2docker-url` flag takes a few different forms. By
@ -59,12 +61,14 @@ upper bound of `192.168.24.254`.
Environment variables and default values:
| CLI option | Environment variable | Default |
|--------------------------------------|------------------------------|--------------------------|
| `--virtualbox-memory` | `VIRTUALBOX_MEMORY_SIZE` | `1024` |
| `--virtualbox-cpu-count` | `VIRTUALBOX_CPU_COUNT` | `1` |
| `--virtualbox-disk-size` | `VIRTUALBOX_DISK_SIZE` | `20000` |
| `--virtualbox-boot2docker-url` | `VIRTUALBOX_BOOT2DOCKER_URL` | *Latest boot2docker url* |
| `--virtualbox-import-boot2docker-vm` | - | `boot2docker-vm` |
| `--virtualbox-hostonly-cidr` | `VIRTUALBOX_HOSTONLY_CIDR` | `192.168.99.1/24` |
| `--virtualbox-no-share` | - | `false` |
| CLI option | Environment variable | Default |
|--------------------------------------|-----------------------------------|--------------------------|
| `--virtualbox-memory` | `VIRTUALBOX_MEMORY_SIZE` | `1024` |
| `--virtualbox-cpu-count` | `VIRTUALBOX_CPU_COUNT` | `1` |
| `--virtualbox-disk-size` | `VIRTUALBOX_DISK_SIZE` | `20000` |
| `--virtualbox-boot2docker-url` | `VIRTUALBOX_BOOT2DOCKER_URL` | *Latest boot2docker url* |
| `--virtualbox-import-boot2docker-vm` | - | `boot2docker-vm` |
| `--virtualbox-hostonly-cidr` | `VIRTUALBOX_HOSTONLY_CIDR` | `192.168.99.1/24` |
| `--virtualbox-hostonly-nictype` | `VIRTUALBOX_HOSTONLY_NIC_TYPE` | `82540EM` |
| `--virtualbox-hostonly-nicpromisc` | `VIRTUALBOX_HOSTONLY_NIC_PROMISC` | `deny` |
| `--virtualbox-no-share` | - | `false` |

View File

@ -29,6 +29,8 @@ import (
const (
isoFilename = "boot2docker.iso"
defaultHostOnlyCIDR = "192.168.99.1/24"
defaultNictype = "82540EM"
defaultNicpromisc = "deny"
)
var (
@ -43,6 +45,8 @@ type Driver struct {
Boot2DockerURL string
Boot2DockerImportVM string
HostOnlyCIDR string
HostOnlyNicType string
HostOnlyPromiscMode string
NoShare bool
}
@ -92,6 +96,18 @@ func GetCreateFlags() []cli.Flag {
Value: defaultHostOnlyCIDR,
EnvVar: "VIRTUALBOX_HOSTONLY_CIDR",
},
cli.StringFlag{
Name: "virtualbox-hostonly-nictype",
Usage: "Specify the Host Only Network Adapter Type",
Value: defaultNictype,
EnvVar: "VIRTUALBOX_HOSTONLY_NIC_TYPE",
},
cli.StringFlag{
Name: "virtualbox-hostonly-nicpromisc",
Usage: "Specify the Host Only Network Adapter Promiscuous Mode",
Value: defaultNicpromisc,
EnvVar: "VIRTUALBOX_HOSTONLY_NIC_PROMISC",
},
cli.BoolFlag{
Name: "virtualbox-no-share",
Usage: "Disable the mount of your home directory",
@ -142,6 +158,8 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
d.SSHUser = "docker"
d.Boot2DockerImportVM = flags.String("virtualbox-import-boot2docker-vm")
d.HostOnlyCIDR = flags.String("virtualbox-hostonly-cidr")
d.HostOnlyNicType = flags.String("virtualbox-hostonly-nictype")
d.HostOnlyPromiscMode = flags.String("virtualbox-hostonly-nicpromisc")
d.NoShare = flags.Bool("virtualbox-no-share")
return nil
@ -624,7 +642,8 @@ func (d *Driver) setupHostOnlyNetwork(machineName string) error {
if err := vbm("modifyvm", machineName,
"--nic2", "hostonly",
"--nictype2", "82540EM",
"--nictype2", d.HostOnlyNicType,
"--nicpromisc2", d.HostOnlyPromiscMode,
"--hostonlyadapter2", hostOnlyNetwork.Name,
"--cableconnected2", "on"); err != nil {
return err