blob: 24c36f4e50537b51e943b0ff42809bababfca333 [file] [log] [blame]
Norman James362a80f2015-09-14 14:04:39 -05001#!/usr/bin/env python
2
3import sys
4import subprocess
Norman James6f8d0422015-09-14 18:48:00 -05005#from gi.repository import GObject
6import gobject
Norman James362a80f2015-09-14 14:04:39 -05007import dbus
8import dbus.service
9import dbus.mainloop.glib
10import PropertyManager
11
12if (len(sys.argv) < 2):
13 print "Usage: ipmi_manager.py [system name]"
14 exit(1)
15
16System = __import__(sys.argv[1])
17import Openbmc
18
19DBUS_NAME = 'org.openbmc.managers.Ipmi'
20OBJ_NAME = '/org/openbmc/managers/Ipmi'
21
22
23class IpmiManager(dbus.service.Object):
24 def __init__(self,bus,name):
25 dbus.service.Object.__init__(self,bus,name)
26
27 ## IPMI commands
28 @dbus.service.method(DBUS_NAME,
29 in_signature='yv', out_signature='')
30 def setSensor(self,sensor_id,value):
31 intf_sens = Openbmc.getManagerInterface(bus,"Sensors")
32 intf_sens.setSensorFromId(sensor_id,value)
33
34 @dbus.service.method(DBUS_NAME,
35 in_signature='y', out_signature='v')
36 def getSensor(self,sensor_id):
37 intf_sens = Openbmc.getManagerInterface(bus,"Sensors")
38 return intf_sens.getSensorFromId(sensor_id)
39
40 @dbus.service.method(DBUS_NAME,
41 in_signature='ia{sv}', out_signature='')
42 def updateFru(self,fru_id,data):
43 intf_fru = Openbmc.getManagerInterface(bus,"Frus")
44 intf_fru.updateFru(fru_id,data)
45
46 @dbus.service.method(DBUS_NAME,
47 in_signature='', out_signature='s')
48 def getFrus(self):
49 intf_fru = Openbmc.getManagerInterface(bus,"Frus")
50 return intf_fru.getFrus()
51
52
53 @dbus.service.method(DBUS_NAME,
54 in_signature='', out_signature='')
55 def pokeHostWatchdog(self):
56 ## TODO don't do hardcoding
57 obj = bus.get_object('org.openbmc.watchdog.Host',
58 '/org/openbmc/watchdog/HostWatchdog_0')
59 intf = dbus.Interface(obj, 'org.openbmc.Watchdog' )
60 intf.poke()
61 return None
62
63 @dbus.service.method(DBUS_NAME,
64 in_signature='', out_signature='')
65 def startHostWatchdog(self):
66 ## TODO don't do hardcoding
67 obj = bus.get_object('org.openbmc.watchdog.Host',
68 '/org/openbmc/watchdog/HostWatchdog_0')
69 intf = dbus.Interface(obj, 'org.openbmc.Watchdog' )
70 intf.start()
71 return None
72
73 @dbus.service.method(DBUS_NAME,
74 in_signature='', out_signature='')
75 def powerOn(self):
76 ## TODO don't do hardcoding
77 obj = bus.get_object('org.openbmc.control.Chassis',
78 '/org/openbmc/control/Chassis')
79 intf = dbus.Interface(obj, 'org.openbmc.control.Chassis' )
80 intf.powerOn()
81 return None
82
83 @dbus.service.method(DBUS_NAME,
84 in_signature='', out_signature='')
85 def powerOff(self):
86 ## TODO don't do hardcoding
87 obj = bus.get_object('org.openbmc.control.Chassis',
88 '/org/openbmc/control/Chassis')
89 intf = dbus.Interface(obj, 'org.openbmc.control.Chassis' )
90 intf.powerOff()
91 return None
92
93
94
95
96if __name__ == '__main__':
97 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
98 bus = dbus.SessionBus()
99 name = dbus.service.BusName(DBUS_NAME,bus)
100 obj = IpmiManager(bus,OBJ_NAME)
Norman James6f8d0422015-09-14 18:48:00 -0500101 mainloop = gobject.MainLoop()
Norman James362a80f2015-09-14 14:04:39 -0500102
103 print "Running IpmiManager"
104 mainloop.run()
105