[PATCH skeleton 2/4] obmcutil: Use freedesktop ObjectManager

OpenBMC Patches openbmc-patches at stwcx.xyz
Wed Jun 22 13:01:07 AEST 2016


From: Brad Bishop <bradleyb at fuzziesquirrel.com>

The org.openbmc.Object.Enumerate interface is deprecated in favor
of the freedesktop ObjectManager.

Signed-off-by: Brad Bishop <bradleyb at fuzziesquirrel.com>
---
 pytools/obmcutil | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/pytools/obmcutil b/pytools/obmcutil
index 02c2c2c..6db589e 100644
--- a/pytools/obmcutil
+++ b/pytools/obmcutil
@@ -18,7 +18,17 @@ def fix_byte(it,key,parent):
                 parent[key] = int(it)  
     else:                              
         pass                           
-                     
+
+
+def merge_interfaces(objs):
+    for op in objs:
+        merged = {}
+        for interface, properties in objs[op].items():
+            merged.update(properties)
+
+        del objs[op]
+        objs[op] = merged
+
 
 def printDict(name,data):
     	if (isinstance(data, dict)):   
@@ -114,14 +124,16 @@ dbus_objects = {
 	'getinventory' : {
 		'bus_name' : 'org.openbmc.Inventory',
 		'object_name' : '/org/openbmc/inventory',
-		'interface_name' : 'org.openbmc.Object.Enumerate',
-		'method' : 'enumerate'
+		'interface_name' : 'org.freedesktop.DBus.ObjectManager',
+		'method' : 'GetManagedObjects',
+		'transform' : merge_interfaces
 	},
 	'getsensors' : {
 		'bus_name' : 'org.openbmc.Sensors',
 		'object_name' : '/org/openbmc/sensors',
-		'interface_name' : 'org.openbmc.Object.Enumerate',
-		'method' : 'enumerate'
+		'interface_name' : 'org.freedesktop.DBus.ObjectManager',
+		'method' : 'GetManagedObjects',
+		'transform' : merge_interfaces
 	},
 	'host' : {
 		'bus_name' : 'org.openbmc.control.Host',
@@ -179,6 +191,8 @@ if (method_name != ""):
 		data = methd(*sys.argv)
 		fix_byte(data,None,None)	
 		pydata = json.loads(json.dumps(data))
+		if 'transform' in objinfo:
+			objinfo['transform'](pydata)
 		printDict("",pydata)
 	except Exception as e:
 		print e
-- 
2.9.0




More information about the openbmc mailing list