func FromPath(client *govmomi.Client, name string, dc *object.Datacenter) (*object.DistributedVirtualPortgroup, error) {
	finder := find.NewFinder(client.Client, false)
	if dc != nil {
		finder.SetDatacenter(dc)
	}

	ctx, cancel := context.WithTimeout(context.Background(), provider.DefaultAPITimeout)
	defer cancel()
	net, err := finder.Network(ctx, name)
	if err != nil {
		return nil, err
	}
	if net.Reference().Type != "DistributedVirtualPortgroup" {
		return nil, fmt.Errorf("network at path %q is not a portgroup (type %s)", name, net.Reference().Type)
	}
	return FromMOID(client, net.Reference().Value)
}
func FromPath(client *govmomi.Client, name string, dc *object.Datacenter) (*object.DistributedVirtualPortgroup, error) {
	finder := find.NewFinder(client.Client, false)
	if dc != nil {
		finder.SetDatacenter(dc)
	}

	ctx, cancel := context.WithTimeout(context.Background(), provider.DefaultAPITimeout)
	defer cancel()
	net, err := finder.Network(ctx, name)
	if err != nil {
		return nil, err
	}
	if net.Reference().Type != "DistributedVirtualPortgroup" {
		return nil, fmt.Errorf("network at path %q is not a portgroup (type %s)", name, net.Reference().Type)
	}
	return FromMOID(client, net.Reference().Value)
}
func FromPath ( client * govmomi . Client , name string , dc * object . Datacenter ) ( * object . DistributedVirtualPortgroup , error ) { finder := find . NewFinder ( client . Client , false ) if dc != nil { finder . SetDatacenter ( dc ) } ctx , cancel := context . WithTimeout ( context . Background ( ) , provider . DefaultAPITimeout ) defer cancel ( ) net , err := finder . Network ( ctx , name ) if err != nil { return nil , err } if net . Reference ( ) . Type != " " { return nil , fmt . Errorf ( " " , name , net . Reference ( ) . Type ) } return FromMOID ( client , net . Reference ( ) . Value ) }
// FromPath gets a portgroup object from its path.
FromPath gets a portgroup object from its path .