From 4d4d66617b76516bbadc6c0824f2eab6e0b489d5 Mon Sep 17 00:00:00 2001 From: Matthew Fiederlein Date: Thu, 13 Jun 2019 16:38:56 -0400 Subject: [PATCH 1/2] Allow blank networkID --- .../virtual_machine_network_interface_subresource.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/vsphere/internal/virtualdevice/virtual_machine_network_interface_subresource.go b/vsphere/internal/virtualdevice/virtual_machine_network_interface_subresource.go index ba968f136..95735ec3e 100644 --- a/vsphere/internal/virtualdevice/virtual_machine_network_interface_subresource.go +++ b/vsphere/internal/virtualdevice/virtual_machine_network_interface_subresource.go @@ -6,6 +6,7 @@ import ( "log" "reflect" "sort" + "strings" "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/validation" @@ -686,9 +687,14 @@ func (r *NetworkInterfaceSubresource) Read(l object.VirtualDeviceList) error { case *types.VirtualEthernetCardDistributedVirtualPortBackingInfo: pg, err := dvportgroup.FromKey(r.client, backing.Port.SwitchUuid, backing.Port.PortgroupKey) if err != nil { - return err + if strings.Contains(err.Error(), "The object or item referred to could not be found"){ + netID = "" + } else { + return err + } + } else { + netID = pg.Reference().Value } - netID = pg.Reference().Value default: return fmt.Errorf("unknown network interface backing %T", card.Backing) } From e7cf05187381b32a038218ca45d6a4d24ca169ea Mon Sep 17 00:00:00 2001 From: Matthew Fiederlein Date: Thu, 13 Jun 2019 17:27:32 -0400 Subject: [PATCH 2/2] Allow blank networkID --- .../virtual_machine_network_interface_subresource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vsphere/internal/virtualdevice/virtual_machine_network_interface_subresource.go b/vsphere/internal/virtualdevice/virtual_machine_network_interface_subresource.go index 95735ec3e..4698c4c3a 100644 --- a/vsphere/internal/virtualdevice/virtual_machine_network_interface_subresource.go +++ b/vsphere/internal/virtualdevice/virtual_machine_network_interface_subresource.go @@ -687,7 +687,7 @@ func (r *NetworkInterfaceSubresource) Read(l object.VirtualDeviceList) error { case *types.VirtualEthernetCardDistributedVirtualPortBackingInfo: pg, err := dvportgroup.FromKey(r.client, backing.Port.SwitchUuid, backing.Port.PortgroupKey) if err != nil { - if strings.Contains(err.Error(), "The object or item referred to could not be found"){ + if strings.Contains(err.Error(), "The object or item referred to could not be found") { netID = "" } else { return err