From f39415bb536db0b0eb70986ccb7437f6befbc87b Mon Sep 17 00:00:00 2001 From: Sumit Agrawal Date: Fri, 18 Sep 2020 02:35:20 +0530 Subject: [PATCH] Import ditributed port group using moid (#1208) * Update ReadMe * Modifying distributed port group import function to import using managed object id instead of path * fixing readme --- vsphere/resource_vsphere_distributed_port_group.go | 4 ++-- website/docs/r/distributed_port_group.html.markdown | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/vsphere/resource_vsphere_distributed_port_group.go b/vsphere/resource_vsphere_distributed_port_group.go index 5f8ae9925..d5b739c5f 100644 --- a/vsphere/resource_vsphere_distributed_port_group.go +++ b/vsphere/resource_vsphere_distributed_port_group.go @@ -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) } diff --git a/website/docs/r/distributed_port_group.html.markdown b/website/docs/r/distributed_port_group.html.markdown index 5b3fd09da..bdd361109 100644 --- a/website/docs/r/distributed_port_group.html.markdown +++ b/website/docs/r/distributed_port_group.html.markdown @@ -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`.