[PATCH skeleton] skeleton: Add new API SystemManager::getFRUObject()

OpenBMC Patches openbmc-patches at stwcx.xyz
Mon Apr 11 19:10:53 AEST 2016


From: Yi Li <adamliyi at msn.com>

ipmi-fru-parser uses getObjectFromId('FRU_STR', fru_area_name) to
ask for the dbus object path of the 'fru_area_name'. The returned
value is also used to check the 'present' status of FRU. Sometimes
the 'fru_area_name' does not defined in Skeleton's ID_LOOKUP table.
system_manager will report a "ERROR: lookup not found" error message.

This patch added an API similiar with getObjectFromId().
It does not report error when the 'fru_area_name' is not defined.
It can be used by ipmi-fru-parser to replace getObjectFromId().

Also the orignal "ERROR" message is changed to "WARNING".

Signed-off-by: Yi Li <adamliyi at msn.com>
---
 bin/system_manager.py | 40 +++++++++++++++++++++++++++-------------
 1 file changed, 27 insertions(+), 13 deletions(-)

diff --git a/bin/system_manager.py b/bin/system_manager.py
index 004d978..c19075f 100755
--- a/bin/system_manager.py
+++ b/bin/system_manager.py
@@ -115,30 +115,44 @@ class SystemManager(Openbmc.DbusProperties,Openbmc.DbusObjectManager):
 		return self.Get(DBUS_NAME,"current_state")
 
 	def doObjectLookup(self,category,key):
-		bus_name = ""
-		obj_path = ""
 		intf_name = INTF_ITEM
-		try:
-			obj_path = System.ID_LOOKUP[category][key]
-			bus_name = self.bus_name_lookup[obj_path]
-			parts = obj_path.split('/')
-			if (parts[3] == 'sensors'):
-				intf_name = INTF_SENSOR
-		except Exception as e:
-			print "ERROR SystemManager: "+str(e)+" not found in lookup"
-
+		obj_path = System.ID_LOOKUP[category][key]
+		bus_name = self.bus_name_lookup[obj_path]
+		parts = obj_path.split('/')
+		if (parts[3] == 'sensors'):
+			intf_name = INTF_SENSOR
 		return [bus_name,obj_path,intf_name]
 
 	@dbus.service.method(DBUS_NAME,
 		in_signature='ss', out_signature='(sss)')
 	def getObjectFromId(self,category,key):
-		return self.doObjectLookup(category,key)
+		try:
+			return self.doObjectLookup(category,key)
+		except Exception as e:
+			print "WARNING SystemManager:"+\
+				"Object not found for:[%s][%s]" %(category,key)
+			return ["", "", ""]
 
 	@dbus.service.method(DBUS_NAME,
 		in_signature='sy', out_signature='(sss)')
 	def getObjectFromByteId(self,category,key):
 		byte = int(key)
-		return self.doObjectLookup(category,byte)
+		try:
+			return self.doObjectLookup(category,byte)
+		except Exception as e:
+			print "WARNING SystemManager:"+\
+				"Object not found for:[%s][%s]" %(category,key)
+			return ["", "", ""]
+
+	# this method is used by ipmi-fru-parser to get the path of a fru_area
+	# do not report 'not found' message since it is expected
+	@dbus.service.method(DBUS_NAME,
+		in_signature='s', out_signature='(sss)')
+	def getFRUObject(self,key):
+		try:
+			return self.doObjectLookup("FRU_STR",key)
+		except Exception as e:
+			return ["", "", ""]
 	
 	def start_process(self,name):
 		if (System.APPS[name]['start_process'] == True):
-- 
2.7.1




More information about the openbmc mailing list