vsphere/internal/helper/envbrowse/environment_browser_helper.go
func (b *EnvironmentBrowser) OSFamily(ctx context.Context, guest string) (string, error) {
	var eb mo.EnvironmentBrowser

	err := b.Properties(ctx, b.Reference(), nil, &eb)
	if err != nil {
		return "", err
	}

	req := types.QueryConfigOption{
		This: b.Reference(),
	}
	res, err := methods.QueryConfigOption(ctx, b.Client(), &req)
	if err != nil {
		return "", err
	}
	if res.Returnval == nil {
		return "", errors.New("no config options were found for the supplied criteria")
	}
	for _, osd := range res.Returnval.GuestOSDescriptor {
		if osd.Id == guest {
			family := osd.Family
			log.Printf("[DEBUG] OSFamily: family for %q is %q", guest, family)
			return family, nil
		}
	}
	return "", fmt.Errorf("could not find guest ID %q", guest)
}
func (b *EnvironmentBrowser) OSFamily(ctx context.Context, guest string) (string, error) {
	var eb mo.EnvironmentBrowser

	err := b.Properties(ctx, b.Reference(), nil, &eb)
	if err != nil {
		return "", err
	}

	req := types.QueryConfigOption{
		This: b.Reference(),
	}
	res, err := methods.QueryConfigOption(ctx, b.Client(), &req)
	if err != nil {
		return "", err
	}
	if res.Returnval == nil {
		return "", errors.New("no config options were found for the supplied criteria")
	}
	for _, osd := range res.Returnval.GuestOSDescriptor {
		if osd.Id == guest {
			family := osd.Family
			log.Printf("[DEBUG] OSFamily: family for %q is %q", guest, family)
			return family, nil
		}
	}
	return "", fmt.Errorf("could not find guest ID %q", guest)
}
func ( b * EnvironmentBrowser ) OSFamily ( ctx context . Context , guest string ) ( string , error ) { var eb mo . EnvironmentBrowser err := b . Properties ( ctx , b . Reference ( ) , nil , & eb ) if err != nil { return " " , err } req := types . QueryConfigOption { This : b . Reference ( ) , } res , err := methods . QueryConfigOption ( ctx , b . Client ( ) , & req ) if err != nil { return " " , err } if res . Returnval == nil { return " " , errors . New ( " " ) } for _ , osd := range res . Returnval . GuestOSDescriptor { if osd . Id == guest { family := osd . Family log . Printf ( " " , guest , family ) return family , nil } } return " " , fmt . Errorf ( " " , guest ) }
// OSFamily fetches the operating system family for the supplied guest ID.
OSFamily fetches the operating system family for the supplied guest ID .