Skip to content

Commit

Permalink
add network_name option to vmware builder to make it match the networ…
Browse files Browse the repository at this point in the history
…k option on the vsphere builder, so vmware users needn't update vmx data just for the network name (hashicorp#9718)
  • Loading branch information
SwampDragons authored Aug 6, 2020
1 parent 09852b8 commit 25f2ec4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions builder/vmware/common/hw_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ type HWConfig struct {
// machine](https://kb.vmware.com/s/article/1001805) for desktop VMware
// clients. For ESXi, refer to the proper ESXi documentation.
NetworkAdapterType string `mapstructure:"network_adapter_type" required:"false"`
// The custom name of the network. Sets the vmx value "ethernet0.networkName"
NetworkName string `mapstructure:"network_name" required:"false"`
// Specify whether to enable VMware's virtual soundcard device when
// building the VM. Defaults to false.
Sound bool `mapstructure:"sound" required:"false"`
Expand Down
2 changes: 2 additions & 0 deletions builder/vmware/iso/config.hcl2spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions builder/vmware/iso/step_create_vmx.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type vmxTemplateData struct {
Network_Type string
Network_Device string
Network_Adapter string
Network_Name string

Sound_Present string
Usb_Present string
Expand Down Expand Up @@ -252,6 +253,9 @@ func (s *stepCreateVMX) Run(ctx context.Context, state multistep.StateBag) multi

/// Check the network type that the user specified
network := config.HWConfig.Network
if config.HWConfig.NetworkName != "" {
templateData.Network_Name = config.HWConfig.NetworkName
}
driver := state.Get("driver").(vmwcommon.Driver).GetVmwareDriver()

// check to see if the driver implements a network mapper for mapping
Expand Down Expand Up @@ -542,6 +546,7 @@ ethernet0.pciSlotNumber = "33"
ethernet0.present = "TRUE"
ethernet0.virtualDev = "{{ .Network_Adapter }}"
ethernet0.wakeOnPcktRcv = "FALSE"
{{if .Network_Name }}ethernet0.networkName = "{{ .Network_Name }}"{{end}}
// Hard disks
scsi0.present = "{{ .SCSI_Present }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
machine](https://kb.vmware.com/s/article/1001805) for desktop VMware
clients. For ESXi, refer to the proper ESXi documentation.

- `network_name` (string) - The custom name of the network. Sets the vmx value "ethernet0.networkName"

- `sound` (bool) - Specify whether to enable VMware's virtual soundcard device when
building the VM. Defaults to false.

Expand Down

0 comments on commit 25f2ec4

Please sign in to comment.