blob: d3e79cd1cbf0ea00c7af8647992ad076b940f645 [file] [log] [blame]
Norman James90baede2015-09-02 20:32:49 -05001#!/usr/bin/env python
2
3import sys
4import subprocess
Norman James90baede2015-09-02 20:32:49 -05005import dbus
Norman James5d78b4d2015-09-05 13:34:34 -05006from gi.repository import GObject
Norman James90baede2015-09-02 20:32:49 -05007import dbus.service
8import dbus.mainloop.glib
Norman James90baede2015-09-02 20:32:49 -05009
10if (len(sys.argv) < 2):
11 print "Usage: ipmi_bt.py [system name]"
12 exit(1)
13
14System = __import__(sys.argv[1])
15import Openbmc
16
17DBUS_NAME = 'org.openbmc.control.IpmiBt'
18OBJ_NAME = '/org/openbmc/control/IpmiBt'
19
20class IpmiBt(dbus.service.Object):
21 def __init__(self,bus,name):
22 dbus.service.Object.__init__(self,bus,name)
23
24 @dbus.service.signal(DBUS_NAME)
25 def UpdateFru(self, iid, message):
26 pass
27
28 @dbus.service.signal(DBUS_NAME)
29 def UpdateSensor(self, iid, message):
30 pass
31
32 @dbus.service.method(DBUS_NAME)
33 def emitUpdateFru(self,ipmi_id,mfg):
34 data = {
35 'manufacturer' : mfg
36 }
37 self.UpdateFru(ipmi_id,data)
38 return 'Signal emitted'
39
40 @dbus.service.method(DBUS_NAME)
41 def emitUpdateSensor(self,ipmi_id,data):
Norman James9e6acf92015-09-08 07:00:04 -050042 self.UpdateSensor(ipmi_id,dbus.Byte(int(data)))
Norman James90baede2015-09-02 20:32:49 -050043 print "update sensor emitted"
44 return 'Signal emitted'
45
46 def getSensor(self,ipmi_id):
47 obj = bus.get_object('org.openbmc.managers.IpmiTranslator',
48 '/org/openbmc/managers/IpmiTranslator/Barreleye')
49 intf = dbus.Interface(obj, 'org.openbmc.managers.IpmiTranslator' )
50 return intf.getSensor(ipmi_id)
51
Norman James9e6acf92015-09-08 07:00:04 -050052 def pokeHostWatchdog(self):
53 obj = bus.get_object('org.openbmc.managers.IpmiTranslator',
54 '/org/openbmc/managers/IpmiTranslator/Barreleye')
55 intf = dbus.Interface(obj, 'org.openbmc.managers.IpmiTranslator' )
56 intf.pokeHostWatchdog()
57
58 def startHostWatchdog(self):
59 obj = bus.get_object('org.openbmc.managers.IpmiTranslator',
60 '/org/openbmc/managers/IpmiTranslator/Barreleye')
61 intf = dbus.Interface(obj, 'org.openbmc.managers.IpmiTranslator' )
62 intf.startHostWatchdog()
63
64
65
66
Norman James90baede2015-09-02 20:32:49 -050067
68if __name__ == '__main__':
Norman James9e6acf92015-09-08 07:00:04 -050069
70 cmd = ""
71 data = None
72 ipmi_id = 0
73 if (len(sys.argv) > 2):
74 cmd = sys.argv[2]
75 if (len(sys.argv) > 3):
76 ipmi_id = int(sys.argv[3])
Norman James90baede2015-09-02 20:32:49 -050077 if (len(sys.argv)>4):
78 data = sys.argv[4]
79
80 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
81 bus = dbus.SessionBus()
82 name = dbus.service.BusName(DBUS_NAME,bus)
83 obj = IpmiBt(bus,OBJ_NAME)
Norman James5d78b4d2015-09-05 13:34:34 -050084 mainloop = GObject.MainLoop()
Norman James90baede2015-09-02 20:32:49 -050085
86 if (cmd == 'updatefru'):
87 obj.emitUpdateFru(ipmi_id,data)
88 elif (cmd == 'setsensor'):
89 obj.emitUpdateSensor(ipmi_id,data)
90 elif (cmd == 'getsensor'):
91 print obj.getSensor(ipmi_id)
Norman James9e6acf92015-09-08 07:00:04 -050092 elif (cmd == 'pokewatchdog'):
93 print obj.pokeHostWatchdog()
94 elif (cmd == 'startwatchdog'):
95 print obj.startHostWatchdog()
96 else:
97 print "ERROR: Invalid command"
98 print "Valid commands: updatefru, setsensor, getsensor, startwatchdog, pokewatchdog"
Norman James90baede2015-09-02 20:32:49 -050099
100 #mainloop.run()
101