From ceccdb827a885e373386343215e6d4038f756f30 Mon Sep 17 00:00:00 2001 From: Calum Lacroix Date: Fri, 20 Jan 2017 14:11:24 +0000 Subject: [PATCH] vSphere Provider: If we only have one networkInterface, deviceID should (#8276) be 0 to ensure that it selects the first element of the networkInterfaces array. --- builtin/providers/vsphere/resource_vsphere_virtual_machine.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/builtin/providers/vsphere/resource_vsphere_virtual_machine.go b/builtin/providers/vsphere/resource_vsphere_virtual_machine.go index 8b984b575aeb..f48ece2bb9cf 100644 --- a/builtin/providers/vsphere/resource_vsphere_virtual_machine.go +++ b/builtin/providers/vsphere/resource_vsphere_virtual_machine.go @@ -1059,6 +1059,9 @@ func resourceVSphereVirtualMachineRead(d *schema.ResourceData, meta interface{}) } if gatewaySetting != "" { deviceID, err := strconv.Atoi(route.Gateway.Device) + if len(networkInterfaces) == 1 { + deviceID = 0 + } if err != nil { log.Printf("[WARN] error at processing %s of device id %#v: %#v", gatewaySetting, route.Gateway.Device, err) } else {