From 92a8849307f6d3c94ff4fb98bc77b807b7138a38 Mon Sep 17 00:00:00 2001 From: Waquid Valiya Peedikakkal Date: Mon, 10 Aug 2020 11:20:49 +0100 Subject: [PATCH] add importer --- vsphere/resource_vsphere_host_port_group.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/vsphere/resource_vsphere_host_port_group.go b/vsphere/resource_vsphere_host_port_group.go index 3231cc4d5..5090fb148 100644 --- a/vsphere/resource_vsphere_host_port_group.go +++ b/vsphere/resource_vsphere_host_port_group.go @@ -48,6 +48,9 @@ func resourceVSphereHostPortGroup() *schema.Resource { Read: resourceVSphereHostPortGroupRead, Update: resourceVSphereHostPortGroupUpdate, Delete: resourceVSphereHostPortGroupDelete, + Importer: &schema.ResourceImporter{ + State: resourceVSphereHostPortGroupImport, + }, Schema: s, } } @@ -147,3 +150,19 @@ func resourceVSphereHostPortGroupDelete(d *schema.ResourceData, meta interface{} return nil } + +func resourceVSphereHostPortGroupImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { + hsID, name, err := portGroupIDsFromResourceID(d) + + err = d.Set("host_system_id", hsID) + if err != nil { + return []*schema.ResourceData{}, err + } + + err = d.Set("name", name) + if err != nil { + return []*schema.ResourceData{}, err + } + + return []*schema.ResourceData{d}, nil +}