Skip to content

Commit

Permalink
Import ditributed port group using moid (#1208)
Browse files Browse the repository at this point in the history
* Update ReadMe

* Modifying distributed port group import function to import using managed object id instead of path

* fixing readme
  • Loading branch information
sumitAgrawal007 authored Sep 17, 2020
1 parent 068810c commit f39415b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions vsphere/resource_vsphere_distributed_port_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ func resourceVSphereDistributedPortGroupImport(d *schema.ResourceData, meta inte
if err := viapi.ValidateVirtualCenter(client); err != nil {
return nil, err
}
p := d.Id()
pg, err := dvportgroup.FromPath(client, p, nil)
moId := d.Id()
pg, err := dvportgroup.FromMOID(client, moId)
if err != nil {
return nil, fmt.Errorf("error locating portgroup: %s", err)
}
Expand Down
9 changes: 4 additions & 5 deletions website/docs/r/distributed_port_group.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,13 @@ ID][docs-about-morefs] to another resource, be sure to use the `id` field.

## Importing

An existing port group can be [imported][docs-import] into this resource via
the path to the port group, via the following command:
An existing port group can be [imported][docs-import] into this resource using
the managed object id of the port group, via the following command:

[docs-import]: https://www.terraform.io/docs/import/index.html

```
terraform import vsphere_distributed_port_group.pg /dc1/network/pg
terraform import vsphere_distributed_port_group.pg dvportgroup-67
```

The above would import the port group named `pg` that is located in the `dc1`
datacenter.
The above would import the port group named `pg` with managed object id `dvportgroup-67`.

0 comments on commit f39415b

Please sign in to comment.