Skip to content

Commit

Permalink
add importer
Browse files Browse the repository at this point in the history
  • Loading branch information
Waquid Valiya Peedikakkal committed Sep 6, 2020
1 parent 26e31ba commit 92a8849
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions vsphere/resource_vsphere_host_port_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ func resourceVSphereHostPortGroup() *schema.Resource {
Read: resourceVSphereHostPortGroupRead,
Update: resourceVSphereHostPortGroupUpdate,
Delete: resourceVSphereHostPortGroupDelete,
Importer: &schema.ResourceImporter{
State: resourceVSphereHostPortGroupImport,
},
Schema: s,
}
}
Expand Down Expand Up @@ -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
}

0 comments on commit 92a8849

Please sign in to comment.