func hostPortGroupFromName(client *govmomi.Client, ns *object.HostNetworkSystem, name string) (*types.HostPortGroup, error) {
	var mns mo.HostNetworkSystem
	pc := client.PropertyCollector()
	ctx, cancel := context.WithTimeout(context.Background(), defaultAPITimeout)
	defer cancel()
	if err := pc.RetrieveOne(ctx, ns.Reference(), []string{"networkInfo.portgroup"}, &mns); err != nil {
		return nil, fmt.Errorf("error fetching host network properties: %s", err)
	}

	for _, pg := range mns.NetworkInfo.Portgroup {
		if pg.Spec.Name == name {
			return &pg, nil
		}
	}

	return nil, fmt.Errorf("could not find port group %s", name)
}
func hostPortGroupFromName(client *govmomi.Client, ns *object.HostNetworkSystem, name string) (*types.HostPortGroup, error) {
	var mns mo.HostNetworkSystem
	pc := client.PropertyCollector()
	ctx, cancel := context.WithTimeout(context.Background(), defaultAPITimeout)
	defer cancel()
	if err := pc.RetrieveOne(ctx, ns.Reference(), []string{"networkInfo.portgroup"}, &mns); err != nil {
		return nil, fmt.Errorf("error fetching host network properties: %s", err)
	}

	for _, pg := range mns.NetworkInfo.Portgroup {
		if pg.Spec.Name == name {
			return &pg, nil
		}
	}

	return nil, fmt.Errorf("could not find port group %s", name)
}
func hostPortGroupFromName ( client * govmomi . Client , ns * object . HostNetworkSystem , name string ) ( * types . HostPortGroup , error ) { var mns mo . HostNetworkSystem pc := client . PropertyCollector ( ) ctx , cancel := context . WithTimeout ( context . Background ( ) , defaultAPITimeout ) defer cancel ( ) if err := pc . RetrieveOne ( ctx , ns . Reference ( ) , [ ] string { " " } , & mns ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } for _ , pg := range mns . NetworkInfo . Portgroup { if pg . Spec . Name == name { return & pg , nil } } return nil , fmt . Errorf ( " " , name ) }
// hostPortGroupFromName locates a port group on the supplied HostNetworkSystem
// by name.
hostPortGroupFromName locates a port group on the supplied HostNetworkSystem by name .