// AttachedDevices returns a list of attached devices to the supplied controller
AttachedDevices returns a list of attached devices to the supplied controller
// AttachedDevices returns a list of attached devices to the supplied controller
func (s *SCSIController) AttachedDevices() (map[int]string, error) {
	qParams := []wmi.Query{
		&wmi.OrQuery{
			wmi.QueryFields{
				Key:   "ResourceSubType",
				Value: PhysDiskResSubType,
				Type:  wmi.Equals},
		},
		&wmi.OrQuery{
			wmi.QueryFields{
				Key:   "ResourceSubType",
				Value: DiskResSubtype,
				Type:  wmi.Equals},
		},
		&wmi.OrQuery{
			wmi.QueryFields{
				Key:   "ResourceSubType",
				Value: DVDResSubType,
				Type:  wmi.Equals},
		},
		&wmi.AndQuery{
			wmi.QueryFields{
				Key:   "Parent",
				Value: strings.Replace(s.path, `\`, `\\`, -1),
				Type:  wmi.Equals},
		},
	}
	result, err := s.mgr.con.Gwmi(ResourceAllocSettingDataClass, []string{}, qParams)
	if err != nil {
		return nil, errors.Wrap(err, "Gwmi")
	}
	ret := map[int]string{}
	resultElements, err := result.Elements()
	if err != nil {
		return nil, errors.Wrap(err, "Elements")
	}
	for _, val := range resultElements {
		addrProp, err := val.GetProperty("AddressOnParent")
		if err != nil {
			return nil, errors.Wrap(err, "AddressOnParent")
		}
		if addrProp.Value() == nil {
			continue
		}
		addr, err := strconv.Atoi(addrProp.Value().(string))
		if err != nil {
			continue
		}
		pth, err := val.Path()
		if err != nil {
			return nil, errors.Wrap(err, "Path_")
		}
		ret[addr] = pth
	}
	return ret, nil
}
func ( s * SCSIController ) AttachedDevices ( ) ( map [ int ] string , error ) { qParams := [ ] wmi . Query { & wmi . OrQuery { wmi . QueryFields { Key : " " , Value : PhysDiskResSubType , Type : wmi . Equals } , } , & wmi . OrQuery { wmi . QueryFields { Key : " " , Value : DiskResSubtype , Type : wmi . Equals } , } , & wmi . OrQuery { wmi . QueryFields { Key : " " , Value : DVDResSubType , Type : wmi . Equals } , } , & wmi . AndQuery { wmi . QueryFields { Key : " " , Value : strings . Replace ( s . path , `\` , `\\` , - 1 ) , Type : wmi . Equals } , } , } result , err := s . mgr . con . Gwmi ( ResourceAllocSettingDataClass , [ ] string { } , qParams ) if err != nil { return nil , errors . Wrap ( err , " " ) } ret := map [ int ] string { } resultElements , err := result . Elements ( ) if err != nil { return nil , errors . Wrap ( err , " " ) } for _ , val := range resultElements { addrProp , err := val . GetProperty ( " " ) if err != nil { return nil , errors . Wrap ( err , " " ) } if addrProp . Value ( ) == nil { continue } addr , err := strconv . Atoi ( addrProp . Value ( ) . ( string ) ) if err != nil { continue } pth , err := val . Path ( ) if err != nil { return nil , errors . Wrap ( err , " " ) } ret [ addr ] = pth } return ret , nil }
AttachedDevices returns a list of attached devices to the supplied controller
AttachedDevices returns a list of attached devices to the supplied controller