josenk / terraform-provider-esxi

Terraform-provider-esxi plugin
GNU General Public License v3.0
540 stars 154 forks source link

Error: No network mapping specified. OVF networks: bridged. Target networks: #73

Closed gudipudipradeep closed 4 years ago

gudipudipradeep commented 4 years ago

` Code: network_interfaces { virtual_network = "${var.virtual_network}" # Required for each network interface, Specify the Virtual Network name. } Plan Command

` Apply command showing following issue Getting issue with Error: There was an ovftool Error: Opening VMX source: /mnt/SPS-Linux-Nodexx/SPS-Linux-Nodexx/SPS-Linux-Nodexx.vmx Opening VI target: vi://UserName@hypervisor.test.fileraft.com:443/ Error: No network mapping specified. OVF networks: bridged. Target networks: ML Subnet .61 VM Network Completed with errors

 pid-25682-guest_functions.go:24: [guestGetVMID] result:
2019-09-27T13:24:15.279-0700 [DEBUG] plugin.terraform-provider-esxi_v1.5.0: pid-25682-guest-create.go:249: **[guestCREATE] ovf_cmd: ovftool --acceptAllEulas --noSSLVerify --X:useMacNaming=false -dm=thin --name='check-Linux-Master' --overwrite -ds='data2'  '/mnt/SPS-Linux-Nodexx/SPS-Linux-Nodexx/SPS-Linux-Nodexx.vmx' 'vi://UserName:Password@hypervisor.test.fileraft.com/'**
2019-09-27T13:24:16.069-0700 [DEBUG] plugin.terraform-provider-esxi_v1.5.0: pid-25682-guest-create.go:253: [guestCREATE] ovftool output: "Opening VMX source: /mnt/SPS-Linux-Nodexx/SPS-Linux-Nodexx/SPS-Linux-Nodexx.vmx\nOpening VI target: vi://UserName@hypervisor.test.fileraft.com:443/\nError: No network mapping specified. OVF networks:   bridged. Target networks:   ML Subnet .61  VM Network\nCompleted with errors\n"
2019-09-27T13:24:16.069-0700 [DEBUG] plugin.terraform-provider-esxi_v1.5.0: pid-25682-guest-create.go:256: Failed, There was an ovftool Error: Opening VMX source: /mnt/SPS-Linux-Nodexx/SPS-Linux-Nodexx/SPS-Linux-Nodexx.vmx
2019-09-27T13:24:16.069-0700 [DEBUG] plugin.terraform-provider-esxi_v1.5.0: Opening VI target: vi://UserName@hypervisor.test.fileraft.com:443/
2019-09-27T13:24:16.069-0700 [DEBUG] plugin.terraform-provider-esxi_v1.5.0: Error: No network mapping specified. OVF networks:   bridged. Target networks:   ML Subnet .61  VM Network
2019-09-27T13:24:16.069-0700 [DEBUG] plugin.terraform-provider-esxi_v1.5.0: Completed with errors

` I think network switch is missing --network="ML Subnet .61" from command line. Please can you help on this issue.

gudipudipradeep commented 4 years ago

` SPS-Linux-Nodexx.vmx .vmx is missing from following source code i think and virtual_networks[0][0] might be a problem

if (strings.HasSuffix(src_path, ".ova") || strings.HasSuffix(src_path, ".ovf")) && virtual_networks[0][0] != "" { net_param = " --network='" + virtual_networks[0][0] + "'" } ` is this condition is really required (strings.HasSuffix(src_path, ".ova") || strings.HasSuffix(src_path, ".ovf")) i think this alone fine virtual_networks[0][0] != ""

josenk commented 4 years ago

If you take a look at the ovftool manual, the --network option is for ova/ovf only...

Also, you might be able to do mapping using vmx files, but it gets complex when the number of network interfaces on the source doesn't match the requirement on the destination. For example, how would you handle 4 network interfaces configured in the source VMX file, but you want to use only one nic on the destination? There is no way to map many to none, or none to many....

I found the best way to use local VMX source files is to strip out all the "network" configuration from the vmx file. The plugin will happily add whatever is needed. I'll update the README to better clarify local source VMX files should not have any networks configured.

josenk commented 4 years ago

I updated the "Known Issues" section...