mirror of https://github.com/docker/docs.git
Merge pull request #3124 from StefanScherer/set-nictype1
Add flag --virtualbox-nictype to set NIC type of eth0
This commit is contained in:
commit
282fdebeaf
|
@ -55,6 +55,7 @@ type Driver struct {
|
||||||
CPU int
|
CPU int
|
||||||
Memory int
|
Memory int
|
||||||
DiskSize int
|
DiskSize int
|
||||||
|
NatNicType string
|
||||||
Boot2DockerURL string
|
Boot2DockerURL string
|
||||||
Boot2DockerImportVM string
|
Boot2DockerImportVM string
|
||||||
HostDNSResolver bool
|
HostDNSResolver bool
|
||||||
|
@ -81,6 +82,7 @@ func NewDriver(hostName, storePath string) *Driver {
|
||||||
Memory: defaultMemory,
|
Memory: defaultMemory,
|
||||||
CPU: defaultCPU,
|
CPU: defaultCPU,
|
||||||
DiskSize: defaultDiskSize,
|
DiskSize: defaultDiskSize,
|
||||||
|
NatNicType: defaultHostOnlyNictype,
|
||||||
HostOnlyCIDR: defaultHostOnlyCIDR,
|
HostOnlyCIDR: defaultHostOnlyCIDR,
|
||||||
HostOnlyNicType: defaultHostOnlyNictype,
|
HostOnlyNicType: defaultHostOnlyNictype,
|
||||||
HostOnlyPromiscMode: defaultHostOnlyPromiscMode,
|
HostOnlyPromiscMode: defaultHostOnlyPromiscMode,
|
||||||
|
@ -132,6 +134,12 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
|
||||||
Usage: "Use the host DNS resolver",
|
Usage: "Use the host DNS resolver",
|
||||||
EnvVar: "VIRTUALBOX_HOST_DNS_RESOLVER",
|
EnvVar: "VIRTUALBOX_HOST_DNS_RESOLVER",
|
||||||
},
|
},
|
||||||
|
mcnflag.StringFlag{
|
||||||
|
Name: "virtualbox-nat-nictype",
|
||||||
|
Usage: "Specify the Network Adapter Type",
|
||||||
|
Value: defaultHostOnlyNictype,
|
||||||
|
EnvVar: "VIRTUALBOX_NAT_NICTYPE",
|
||||||
|
},
|
||||||
mcnflag.StringFlag{
|
mcnflag.StringFlag{
|
||||||
Name: "virtualbox-hostonly-cidr",
|
Name: "virtualbox-hostonly-cidr",
|
||||||
Usage: "Specify the Host Only CIDR",
|
Usage: "Specify the Host Only CIDR",
|
||||||
|
@ -208,6 +216,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
|
||||||
d.SSHUser = "docker"
|
d.SSHUser = "docker"
|
||||||
d.Boot2DockerImportVM = flags.String("virtualbox-import-boot2docker-vm")
|
d.Boot2DockerImportVM = flags.String("virtualbox-import-boot2docker-vm")
|
||||||
d.HostDNSResolver = flags.Bool("virtualbox-host-dns-resolver")
|
d.HostDNSResolver = flags.Bool("virtualbox-host-dns-resolver")
|
||||||
|
d.NatNicType = flags.String("virtualbox-nat-nictype")
|
||||||
d.HostOnlyCIDR = flags.String("virtualbox-hostonly-cidr")
|
d.HostOnlyCIDR = flags.String("virtualbox-hostonly-cidr")
|
||||||
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")
|
||||||
|
@ -380,7 +389,7 @@ func (d *Driver) CreateVM() error {
|
||||||
|
|
||||||
if err := d.vbm("modifyvm", d.MachineName,
|
if err := d.vbm("modifyvm", d.MachineName,
|
||||||
"--nic1", "nat",
|
"--nic1", "nat",
|
||||||
"--nictype1", "82540EM",
|
"--nictype1", d.NatNicType,
|
||||||
"--cableconnected1", "on"); err != nil {
|
"--cableconnected1", "on"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -470,6 +470,37 @@ func TestCreateVM(t *testing.T) {
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCreateVMWithSpecificNatNicType(t *testing.T) {
|
||||||
|
shareName, shareDir := getShareDriveAndName()
|
||||||
|
|
||||||
|
modifyVMcommand := "vbm modifyvm default --firmware bios --bioslogofadein off --bioslogofadeout off --bioslogodisplaytime 0 --biosbootmenu disabled --ostype Linux26_64 --cpus 1 --memory 1024 --acpi on --ioapic on --rtcuseutc on --natdnshostresolver1 off --natdnsproxy1 on --cpuhotplug off --pae on --hpet on --hwvirtex on --nestedpaging on --largepages on --vtxvpid on --accelerate3d off --boot1 dvd"
|
||||||
|
if runtime.GOOS == "windows" && runtime.GOARCH == "386" {
|
||||||
|
modifyVMcommand += " --longmode on"
|
||||||
|
}
|
||||||
|
|
||||||
|
driver := NewDriver("default", "path")
|
||||||
|
driver.NatNicType = "Am79C973"
|
||||||
|
mockCalls(t, driver, []Call{
|
||||||
|
{"CopyIsoToMachineDir path default http://b2d.org", "", nil},
|
||||||
|
{"Generate path/machines/default/id_rsa", "", nil},
|
||||||
|
{"Create 20000 path/machines/default/id_rsa.pub path/machines/default/disk.vmdk", "", nil},
|
||||||
|
{"vbm createvm --basefolder path/machines/default --name default --register", "", nil},
|
||||||
|
{modifyVMcommand, "", nil},
|
||||||
|
{"vbm modifyvm default --nic1 nat --nictype1 Am79C973 --cableconnected1 on", "", nil},
|
||||||
|
{"vbm storagectl default --name SATA --add sata --hostiocache on", "", nil},
|
||||||
|
{"vbm storageattach default --storagectl SATA --port 0 --device 0 --type dvddrive --medium path/machines/default/boot2docker.iso", "", nil},
|
||||||
|
{"vbm storageattach default --storagectl SATA --port 1 --device 0 --type hdd --medium path/machines/default/disk.vmdk", "", nil},
|
||||||
|
{"vbm guestproperty set default /VirtualBox/GuestAdd/SharedFolders/MountPrefix /", "", nil},
|
||||||
|
{"vbm guestproperty set default /VirtualBox/GuestAdd/SharedFolders/MountDir /", "", nil},
|
||||||
|
{"vbm sharedfolder add default --name " + shareName + " --hostpath " + shareDir + " --automount", "", nil},
|
||||||
|
{"vbm setextradata default VBoxInternal2/SharedFoldersEnableSymlinksCreate/" + shareName + " 1", "", nil},
|
||||||
|
})
|
||||||
|
|
||||||
|
err := driver.CreateVM()
|
||||||
|
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
func TestStart(t *testing.T) {
|
func TestStart(t *testing.T) {
|
||||||
driver := NewDriver("default", "path")
|
driver := NewDriver("default", "path")
|
||||||
mockCalls(t, driver, []Call{
|
mockCalls(t, driver, []Call{
|
||||||
|
|
Loading…
Reference in New Issue