MCPcopy Index your code
hub / github.com/apache/cloudstack-go / GetGuestOsMappingByID

Method GetGuestOsMappingByID

cloudstack/GuestOSService.go:760–790  ·  view source on GitHub ↗

This is a courtesy helper function, which in some cases may not work as expected!

(id string, opts ...OptionFunc)

Source from the content-addressed store, hash-verified

758
759// This is a courtesy helper function, which in some cases may not work as expected!
760func (s *GuestOSService) GetGuestOsMappingByID(id string, opts ...OptionFunc) (*GuestOsMapping, int, error) {
761 p := &ListGuestOsMappingParams{}
762 p.p = make(map[string]interface{})
763
764 p.p["id"] = id
765
766 for _, fn := range append(s.cs.options, opts...) {
767 if err := fn(s.cs, p); err != nil {
768 return nil, -1, err
769 }
770 }
771
772 l, err := s.ListGuestOsMapping(p)
773 if err != nil {
774 if strings.Contains(err.Error(), fmt.Sprintf(
775 "Invalid parameter id value=%s due to incorrect long value format, "+
776 "or entity does not exist", id)) {
777 return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l)
778 }
779 return nil, -1, err
780 }
781
782 if l.Count == 0 {
783 return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
784 }
785
786 if l.Count == 1 {
787 return l.GuestOsMapping[0], l.Count, nil
788 }
789 return nil, l.Count, fmt.Errorf("There is more then one result for GuestOsMapping UUID: %s!", id)
790}
791
792// Lists all available OS mappings for given hypervisor
793func (s *GuestOSService) ListGuestOsMapping(p *ListGuestOsMappingParams) (*ListGuestOsMappingResponse, error) {

Callers

nothing calls this directly

Calls 2

ListGuestOsMappingMethod · 0.95
ErrorMethod · 0.45

Tested by

no test coverage detected