Skip to content

Commit 44483f9

Browse files
committed
Enhance get power/thermal data function.
For different type of servers, we may get more than 1 chassis items. E.g. In wolfpass server, there are many subitems in Chassis item. If we use Chassis Power command, it will report error and request client to specify one subitem by -I, and retry one by one to find the item which includes power data. In this patch, it utilizes existed prop parameter and can report the subitem which includes power during it go through all chassis subitems, so that client can get power sensor data by one Chassis Power command directly. I have done below test and pass. Chassis Power Chassis -I Baseboard Power Chassis Thermal Chassis -I Baseboard Thermal Signed-off-by: zhipengl <[email protected]>
1 parent 1b45092 commit 44483f9

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

redfishtool/Chassis.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def get(self,sc,op,rft, cmdTop=False, prop=None):
231231
collUrl=r.url
232232

233233
# search collection to find path to system
234-
sysPath,rc,r,j,d=rft.getPathBy(rft, r, d)
234+
sysPath,rc,r,j,d=rft.getPathBy(rft, r, d, prop)
235235
if( rc !=0 ): #if a path was not found, its an error
236236
return(rc,r,j,d)
237237

@@ -422,12 +422,12 @@ def setIndicatorLed(self, sc, op, rft, cmdTop=False, prop=None):
422422

423423
def getPower(self,sc,op, rft, cmdTop=False, prop=None):
424424
rft.printVerbose(4,"{}:{}: in operation".format(rft.subcommand,sc.operation))
425+
resName="Power"
425426

426427
# get the Chassis resource first
427-
rc,r,j,d=op.get(sc,op, rft)
428+
rc,r,j,d=op.get(sc, op, rft, cmdTop, resName)
428429
if( rc != 0): return(rc,r,False,None)
429430

430-
resName="Power"
431431
# get the link to the Power resource under Chassis
432432
if ((resName in d) and ("@odata.id" in d[resName])):
433433
resLink=d[resName]["@odata.id"]
@@ -447,12 +447,11 @@ def getPower(self,sc,op, rft, cmdTop=False, prop=None):
447447

448448
def getThermal(self,sc,op,rft,cmdTop=False, prop=None):
449449
rft.printVerbose(4,"{}:{}: in operation".format(rft.subcommand,sc.operation))
450-
450+
resName="Thermal"
451451
# get the Chassis resource first
452-
rc,r,j,d=op.get(sc,op, rft)
452+
rc,r,j,d=op.get(sc, op, rft, cmdTop, resName)
453453
if( rc != 0): return(rc,r,False,None)
454454

455-
resName="Thermal"
456455
# get the link to the Thermal resource under Chassis
457456
if ((resName in d) and ("@odata.id" in d[resName])):
458457
resLink=d[resName]["@odata.id"]

redfishtool/redfishtoolTransport.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ def printStatusErr4xx(self, status_code,*argv,noprog=False, prepend="",**kwargs)
857857

858858

859859

860-
def getPathBy(self,rft, r, coll):
860+
def getPathBy(self,rft, r, coll, prop=None):
861861
if('Members' not in coll):
862862
rft.printErr("Error: getPathBy: no members array in collection")
863863
return(None,1,None,False,None)
@@ -883,10 +883,15 @@ def getPathBy(self,rft, r, coll):
883883

884884
elif(rft.oneOptn):
885885
if(numOfLinks > 1):
886-
rc, r, j, d = rft.listCollection(rft, r, coll, prop=None)
886+
rc, r, j, d = rft.listCollection(rft, r, coll, prop)
887887
id_list = []
888+
888889
if not rc and 'Members' in d:
889-
id_list = [m['Id'] for m in d['Members'] if 'Id' in m]
890+
if prop is not None:
891+
if d['Members'] and '@odata.id' in d['Members'][0]:
892+
return(d['Members'][0]['@odata.id'],0,None,False,None)
893+
else:
894+
id_list = [m['Id'] for m in d['Members'] if 'Id' in m]
890895
rft.printErr("Error: No target specified, but multiple {} IDs found: {}"
891896
.format(rft.subcommand, repr(id_list)))
892897
rft.printErr("Re-issue command with '-I <Id>' to select target.")
@@ -1034,7 +1039,8 @@ def listCollection(self, rft, r, coll, prop=None):
10341039
if( prop is not None ):
10351040
listMember[prop]=propVal
10361041
# add the member to the listd
1037-
members.append(listMember)
1042+
if (prop is None) or (propVal is not None):
1043+
members.append(listMember)
10381044

10391045
#create base list dictionary
10401046
collPath=urlparse(baseUrl).path

0 commit comments

Comments
 (0)