Skip to content

Commit b8ba0bc

Browse files
authored
Merge pull request #109 from DMTF/Fix108-Match-CLI-Fix
Corrected matching logic to return the matched resource if found
2 parents faa99dc + 97ead5b commit b8ba0bc

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

redfishtoollib/redfishtoolTransport.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,7 @@ def getPathBy(self,rft, r, coll, prop=None):
10081008

10091009
elif(rft.gotMatchOptn):
10101010
baseUrl=r.url
1011-
matchedPath=None
1011+
matchedPath,matchedRc,matchedR,matchedJ,matchedD=None,1,None,False,None
10121012
matches=0
10131013
for i in range (0,numOfLinks):
10141014
if( '@odata.id' not in coll['Members'][i] ):
@@ -1019,13 +1019,13 @@ def getPathBy(self,rft, r, coll, prop=None):
10191019
rc,r,j,d=rft.rftSendRecvRequest(rft.AUTHENTICATED_API, 'GET', baseUrl, relPath=path)
10201020
if(rc==0): # if matchProp found
10211021
if( d[rft.matchProp] == rft.matchValue ):
1022-
matchedPath=path
1022+
matchedPath,matchedRc,matchedR,matchedJ,matchedD=path,rc,r,j,d
10231023
matches +=1
10241024
if( matches > 1 ):
10251025
rft.printErr("Error: getPathBy --Id or --Match option: failed: found multiple matches.")
10261026
return(None,1,None,False,None)
10271027
if(rft.firstOptn):
1028-
return(matchedPath,rc,r,j,d)
1028+
return(matchedPath,matchedRc,matchedR,matchedJ,matchedD)
10291029
else:
10301030
rft.printVerbose(4,"Transport:getPathBy:Match: failed match: matchProp={}, matchValue={}, readValue={}".format(rft.matchProp,rft.matchValue,d[rft.matchProp]))
10311031
pass
@@ -1035,7 +1035,7 @@ def getPathBy(self,rft, r, coll, prop=None):
10351035
#after looping over all members in the array,
10361036
#if here, if we got a match, return the path. If not, then no match was found. return none
10371037
if( matches > 0 ):
1038-
return(matchedPath,rc,r,j,d)
1038+
return(matchedPath,matchedRc,matchedR,matchedJ,matchedD)
10391039
else:
10401040
rft.printErr("Error: getPathBy --Id or --Match option: no match found in collection")
10411041
return(None,1,None,False,None)

0 commit comments

Comments
 (0)