blob: 8e4566e96ee48823cc0d99521b654d64f49e1ae8 [file] [log] [blame]
Norman James90baede2015-09-02 20:32:49 -05001#!/usr/bin/env python
2
3import sys
4import subprocess
5import gobject
6import dbus
7import dbus.service
8import dbus.mainloop.glib
9import xml.etree.ElementTree as ET
10
11if (len(sys.argv) < 2):
12 print "Usage: ipmi_bt.py [system name]"
13 exit(1)
14
15System = __import__(sys.argv[1])
16import Openbmc
17
18DBUS_NAME = 'org.openbmc.control.IpmiBt'
19OBJ_NAME = '/org/openbmc/control/IpmiBt'
20
21class IpmiBt(dbus.service.Object):
22 def __init__(self,bus,name):
23 dbus.service.Object.__init__(self,bus,name)
24
25 @dbus.service.signal(DBUS_NAME)
26 def UpdateFru(self, iid, message):
27 pass
28
29 @dbus.service.signal(DBUS_NAME)
30 def UpdateSensor(self, iid, message):
31 pass
32
33 @dbus.service.method(DBUS_NAME)
34 def emitUpdateFru(self,ipmi_id,mfg):
35 data = {
36 'manufacturer' : mfg
37 }
38 self.UpdateFru(ipmi_id,data)
39 return 'Signal emitted'
40
41 @dbus.service.method(DBUS_NAME)
42 def emitUpdateSensor(self,ipmi_id,data):
43 self.UpdateSensor(ipmi_id,int(data))
44 print "update sensor emitted"
45 return 'Signal emitted'
46
47 def getSensor(self,ipmi_id):
48 obj = bus.get_object('org.openbmc.managers.IpmiTranslator',
49 '/org/openbmc/managers/IpmiTranslator/Barreleye')
50 intf = dbus.Interface(obj, 'org.openbmc.managers.IpmiTranslator' )
51 return intf.getSensor(ipmi_id)
52
53
54if __name__ == '__main__':
55
56 cmd = sys.argv[2]
57 ipmi_id = int(sys.argv[3])
58 if (len(sys.argv)>4):
59 data = sys.argv[4]
60
61 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
62 bus = dbus.SessionBus()
63 name = dbus.service.BusName(DBUS_NAME,bus)
64 obj = IpmiBt(bus,OBJ_NAME)
65 mainloop = gobject.MainLoop()
66
67 if (cmd == 'updatefru'):
68 obj.emitUpdateFru(ipmi_id,data)
69 elif (cmd == 'setsensor'):
70 obj.emitUpdateSensor(ipmi_id,data)
71 elif (cmd == 'getsensor'):
72 print obj.getSensor(ipmi_id)
73
74
75 #mainloop.run()
76