Skip to content

Commit 53da0c9

Browse files
committed
Add network connection type option
1 parent a410e76 commit 53da0c9

File tree

3 files changed

+23
-13
lines changed

3 files changed

+23
-13
lines changed

pkg/drivers/vmware/config/config.go

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ import (
2626
)
2727

2828
const (
29-
defaultSSHUser = "docker"
30-
defaultSSHPass = "tcuser"
31-
defaultDiskSize = 20000
32-
defaultCPU = 1
33-
defaultMemory = 1024
34-
defaultWaitIP = 30000
29+
defaultSSHUser = "docker"
30+
defaultSSHPass = "tcuser"
31+
defaultDiskSize = 20000
32+
defaultCPU = 1
33+
defaultMemory = 1024
34+
defaultWaitIP = 30000
35+
defaultNetworkType = "nat"
3536
)
3637

3738
// Config specifies the configuration of driver VMware
@@ -49,17 +50,19 @@ type Config struct {
4950
ConfigDriveURL string
5051
NoShare bool
5152

52-
WaitIP int
53+
WaitIP int
54+
NetworkType string
5355
}
5456

5557
// NewConfig creates a new Config
5658
func NewConfig(hostname, storePath string) *Config {
5759
return &Config{
58-
CPU: defaultCPU,
59-
Memory: defaultMemory,
60-
DiskSize: defaultDiskSize,
61-
SSHPassword: defaultSSHPass,
62-
WaitIP: defaultWaitIP,
60+
CPU: defaultCPU,
61+
Memory: defaultMemory,
62+
DiskSize: defaultDiskSize,
63+
SSHPassword: defaultSSHPass,
64+
WaitIP: defaultWaitIP,
65+
NetworkType: defaultNetworkType,
6366
BaseDriver: &drivers.BaseDriver{
6467
SSHUser: defaultSSHUser,
6568
MachineName: hostname,
@@ -125,5 +128,11 @@ func (c *Config) GetCreateFlags() []mcnflag.Flag {
125128
Usage: "time to wait for vmrun to get an ip (in milliseconds)",
126129
Value: defaultWaitIP,
127130
},
131+
mcnflag.StringFlag{
132+
EnvVar: "VMWARE_NETWORK_TYPE",
133+
Name: "vmware-network-type",
134+
Usage: "Network connection type to use (e.g. 'nat', 'bridged', 'hostonly')",
135+
Value: defaultNetworkType,
136+
},
128137
}
129138
}

pkg/drivers/vmware/driver.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
9090
d.SSHPort = 22
9191
d.NoShare = flags.Bool("vmware-no-share")
9292
d.WaitIP = flags.Int("vmware-wait-ip")
93+
d.NetworkType = flags.String("vmware-network-type")
9394

9495
// We support a maximum of 16 cpu to be consistent with Virtual Hardware 10
9596
// specs.

pkg/drivers/vmware/vmx.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const vmx = `
2525
config.version = "8"
2626
displayName = "{{.MachineName}}"
2727
ethernet0.present = "TRUE"
28-
ethernet0.connectionType = "nat"
28+
ethernet0.connectionType = "{{.NetworkType}}"
2929
ethernet0.virtualDev = "vmxnet3"
3030
ethernet0.wakeOnPcktRcv = "FALSE"
3131
ethernet0.addressType = "generated"

0 commit comments

Comments
 (0)