Skip to content

Commit

Permalink
Merge pull request #109 from DMTF/Fix108-Match-CLI-Fix
Browse files Browse the repository at this point in the history
Corrected matching logic to return the matched resource if found
  • Loading branch information
mraineri authored Aug 16, 2023
2 parents faa99dc + 97ead5b commit b8ba0bc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions redfishtoollib/redfishtoolTransport.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ def getPathBy(self,rft, r, coll, prop=None):

elif(rft.gotMatchOptn):
baseUrl=r.url
matchedPath=None
matchedPath,matchedRc,matchedR,matchedJ,matchedD=None,1,None,False,None
matches=0
for i in range (0,numOfLinks):
if( '@odata.id' not in coll['Members'][i] ):
Expand All @@ -1019,13 +1019,13 @@ def getPathBy(self,rft, r, coll, prop=None):
rc,r,j,d=rft.rftSendRecvRequest(rft.AUTHENTICATED_API, 'GET', baseUrl, relPath=path)
if(rc==0): # if matchProp found
if( d[rft.matchProp] == rft.matchValue ):
matchedPath=path
matchedPath,matchedRc,matchedR,matchedJ,matchedD=path,rc,r,j,d
matches +=1
if( matches > 1 ):
rft.printErr("Error: getPathBy --Id or --Match option: failed: found multiple matches.")
return(None,1,None,False,None)
if(rft.firstOptn):
return(matchedPath,rc,r,j,d)
return(matchedPath,matchedRc,matchedR,matchedJ,matchedD)
else:
rft.printVerbose(4,"Transport:getPathBy:Match: failed match: matchProp={}, matchValue={}, readValue={}".format(rft.matchProp,rft.matchValue,d[rft.matchProp]))
pass
Expand All @@ -1035,7 +1035,7 @@ def getPathBy(self,rft, r, coll, prop=None):
#after looping over all members in the array,
#if here, if we got a match, return the path. If not, then no match was found. return none
if( matches > 0 ):
return(matchedPath,rc,r,j,d)
return(matchedPath,matchedRc,matchedR,matchedJ,matchedD)
else:
rft.printErr("Error: getPathBy --Id or --Match option: no match found in collection")
return(None,1,None,False,None)
Expand Down

0 comments on commit b8ba0bc

Please sign in to comment.