[PATCH skeleton] Add UUID support

OpenBMC Patches patches at stwcx.xyz
Wed Oct 21 14:23:43 AEDT 2015


From: Adriana Kobylak <anoo at us.ibm.com>

---
 bin/chassis_control.py | 9 ++++++++-
 bin/ipmi_example.py    | 4 ++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/bin/chassis_control.py b/bin/chassis_control.py
index 6283aca..289c6ad 100755
--- a/bin/chassis_control.py
+++ b/bin/chassis_control.py
@@ -1,6 +1,7 @@
 #!/usr/bin/env python
 
 import sys
+import uuid
 #from gi.repository import GObject
 import gobject
 import dbus
@@ -39,6 +40,9 @@ class ChassisControlObject(dbus.service.Object):
 		self.reboot = 0	
 		self.last_power_state = 0
 
+		#uuid
+		self.id = 0
+
 		bus.add_signal_receiver(self.power_button_signal_handler, 
 					dbus_interface = "org.openbmc.Button", signal_name = "ButtonPressed", 
 					path="/org/openbmc/buttons/PowerButton_0" )
@@ -55,7 +59,10 @@ class ChassisControlObject(dbus.service.Object):
 	@dbus.service.method(DBUS_NAME,
 		in_signature='', out_signature='s')
 	def getID(self):
-		return id
+		if (self.id==0):
+			#calculate uuuid
+			self.id = uuid.uuid1()
+		return str(self.id)
 
 	@dbus.service.method(DBUS_NAME,
 		in_signature='', out_signature='')
diff --git a/bin/ipmi_example.py b/bin/ipmi_example.py
index 589c0ca..ba13b60 100755
--- a/bin/ipmi_example.py
+++ b/bin/ipmi_example.py
@@ -58,6 +58,10 @@ if __name__ == '__main__':
 	elif (cmd == "poweroff"):
 		intf = getChassisControl()
 		intf.powerOff()
+	elif (cmd == "getid"):
+		intf = getChassisControl()
+		id = intf.getID()
+		print id
 	elif (cmd == "setsensor"):
 		intf_sys = Openbmc.getManagerInterface(bus,"System")
 		obj_info = intf_sys.getObjectFromByteId("SENSOR",chr(int(ipmi_id)))
-- 
2.6.0




More information about the openbmc mailing list