cleaned up ipmi handling
diff --git a/bin/Barreleye.py b/bin/Barreleye.py
index 2d5c800..9b456b8 100644
--- a/bin/Barreleye.py
+++ b/bin/Barreleye.py
@@ -1,6 +1,5 @@
#! /usr/bin/python
-## todos: event logger,
import dbus
import Openbmc
@@ -37,12 +36,7 @@
'monitor_process' : True,
'process_name' : 'control_bmc.exe',
'heartbeat' : 'no',
- 'instances' : [
- {
- 'name' : 'Bmc_0',
- 'user_label': 'Master Bmc',
- }
- ]
+ 'instances' : [ { 'name' : 'Bmc_0' } ]
}
SYSTEM_CONFIG['org.openbmc.managers.Inventory'] = {
@@ -51,13 +45,7 @@
'monitor_process' : True,
'process_name' : 'inventory_manager.py',
'heartbeat' : 'no',
- 'rest_name' : 'frus',
- 'instances' : [
- {
- 'name' : 'Barreleye',
- 'user_label': 'Inventory Manager',
- }
- ]
+ 'instances' : [ { 'name' : 'Barreleye' } ]
}
@@ -67,28 +55,7 @@
'monitor_process' : True,
'process_name' : 'sensor_manager.py',
'heartbeat' : 'no',
- 'rest_name' : 'sensors',
- 'instances' : [
- {
- 'name' : 'Barreleye',
- 'user_label': 'Sensor Manager',
- }
- ]
- }
-
-SYSTEM_CONFIG['org.openbmc.loggers.EventLogger'] = {
- 'system_state' : 'INIT',
- 'start_process' : False,
- 'monitor_process' : True,
- 'process_name' : 'eventlogger.py',
- 'heartbeat' : 'no',
- 'rest_name' : 'events',
- 'instances' : [
- {
- 'name' : 'Barreleye',
- 'user_label': 'Event Logger',
- }
- ]
+ 'instances' : [ { 'name' : 'Barreleye' } ]
}
SYSTEM_CONFIG['org.openbmc.watchdog.Host'] = {
@@ -97,11 +64,9 @@
'monitor_process' : True,
'process_name' : 'host_watchdog.exe',
'heartbeat' : 'no',
- 'rest_name' : 'watchdog',
'instances' : [
{
'name' : 'HostWatchdog_0',
- 'user_label': 'Host Watchdog',
'properties' : {
'org.openbmc.Watchdog' : {
'poll_interval': 3000,
@@ -167,12 +132,7 @@
'monitor_process' : True,
'process_name' : 'button_power.exe',
'heartbeat' : 'no',
- 'instances' : [
- {
- 'name' : 'PowerButton_0',
- 'user_label': 'Main Power Button',
- }
- ]
+ 'instances' : [ { 'name' : 'PowerButton_0' } ]
}
SYSTEM_CONFIG['org.openbmc.sensors.HostStatus'] = {
'system_state' : 'STANDBY',
@@ -180,13 +140,10 @@
'monitor_process' : True,
'process_name' : 'sensor_host_status.exe',
'heartbeat' : "no",
- 'instances' : [
- {
- 'name' : 'HostStatus_0',
- 'user_label': 'Host Status',
+ 'instances' : [ { 'name' : 'HostStatus_0',
'properties' : {
- 'org.openbmc.SensorValue': {
- 'ipmi_id' : 43,
+ 'org.openbmc.SensorIpmi': {
+ 'sensor_id' : 43,
},
}
@@ -199,12 +156,7 @@
'monitor_process' : True,
'process_name' : 'chassis_identify.exe',
'heartbeat' : 'no',
- 'instances' : [
- {
- 'name' : 'ChassisIdentify_0',
- 'user_label': 'Chassis Identify LED',
- }
- ]
+ 'instances' : [ { 'name' : 'ChassisIdentify_0' } ]
}
SYSTEM_CONFIG['org.openbmc.flash.BIOS'] = {
'system_state' : 'STANDBY',
@@ -212,13 +164,7 @@
'monitor_process' : True,
'process_name' : 'flash_bios.exe',
'heartbeat' : 'no',
- 'rest_name' : 'flash',
- 'instances' : [
- {
- 'name' : 'BIOS_0',
- 'user_label': 'BIOS SPI Flash',
- }
- ]
+ 'instances' : [ { 'name' : 'BIOS_0' } ]
}
SYSTEM_CONFIG['org.openbmc.control.Host'] = {
'system_state' : 'STANDBY',
@@ -226,12 +172,7 @@
'monitor_process' : True,
'process_name' : 'control_host.exe',
'heartbeat' : 'no',
- 'instances' : [
- {
- 'name' : 'Host_0',
- 'user_label': 'Host Control',
- }
- ]
+ 'instances' : [ { 'name' : 'Host_0' } ]
}
SYSTEM_CONFIG['org.openbmc.control.Chassis'] = {
'system_state' : 'STANDBY',
@@ -239,13 +180,7 @@
'monitor_process' : True,
'process_name' : 'chassis_control.py',
'heartbeat' : 'no',
- 'rest_name' : 'chassis',
- 'instances' : [
- {
- 'name' : 'Chassis',
- 'user_label': 'Chassis Control',
- }
- ]
+ 'instances' : [ { 'name' : 'Chassis' } ]
}
SYSTEM_CONFIG['org.openbmc.vpd'] = {
@@ -254,13 +189,7 @@
'monitor_process' : False,
'process_name' : 'board_vpd.exe',
'heartbeat' : 'no',
- 'instances' : [
- {
- 'name' : 'MBVPD_0',
- 'user_label': 'VPD',
- },
-
- ]
+ 'instances' : [ { 'name' : 'MBVPD_0' } ]
}
SYSTEM_CONFIG['org.openbmc.sensors.Occ'] = {
@@ -272,7 +201,6 @@
'instances' : [
{
'name' : 'Occ_0',
- 'user_label': 'CPU0',
'properties' : {
'org.openbmc.Occ' : {
'poll_interval' : 3000,
@@ -289,21 +217,7 @@
'monitor_process' : True,
'process_name' : 'fan.exe',
'heartbeat' : 'no',
- 'instances' : [
- {
- 'name' : 'Fan_0',
- 'user_label': 'FAN 0',
- },
- {
- 'name' : 'Fan_1',
- 'user_label': 'FAN 1',
- },
- {
- 'name' : 'Fan_2',
- 'user_label': 'FAN 2',
- },
-
- ]
+ 'instances' : [ {'name' : 'Fan_0' }, {'name' : 'Fan_1'}, {'name' : 'Fan_2'} ]
}
NON_CACHABLE_PROPERTIES = {
diff --git a/bin/Openbmc.py b/bin/Openbmc.py
index a777ae8..625f36c 100644
--- a/bin/Openbmc.py
+++ b/bin/Openbmc.py
@@ -82,21 +82,6 @@
get_objs(bus,bus_name,path+"/"+node.attrib['name'],objects)
-
-#def get_methods(obj):
-# methods = {}
-# introspect_iface = dbus.Interface(obj,"org.freedesktop.DBus.Introspectable")
- # tree = ET.ElementTree(ET.fromstring(introspect_iface.Introspect()))
- # root = tree.getroot()
-# for intf in root.iter('interface'):
- # intf_name = intf.attrib['name']
-# if (intf_name.find(BUS_PREFIX)==0):
-# methods[intf_name] = {}
-# for method in intf.iter('method'):
-# methods[intf_name][method.attrib['name']] = True
-#
-# return methods
-
class DbusProperty:
def __init__(self,name,value):
self.name = str(name)
diff --git a/bin/inventory_manager.py b/bin/inventory_manager.py
index dcc0114..fa689f0 100644
--- a/bin/inventory_manager.py
+++ b/bin/inventory_manager.py
@@ -87,8 +87,13 @@
dbus.service.Object.__init__(self,bus,name)
bus.add_signal_receiver(self.UpdateFruHandler,
+ dbus_interface = "org.openbmc.sensors.IpmiBt",
signal_name = 'UpdateFru')
+ bus.add_signal_receiver(self.SetSensorHandler,
+ dbus_interface = "org.openbmc.sensors.IpmiBt",
+ signal_name = "SetSensor")
+
self.fru_db = {}
self.fru_id_lookup = {}
self.sensor_id_lookup = {}
@@ -103,8 +108,15 @@
def UpdateFruHandler(self,fru_id,data):
- self.updateFru(fru_id,data)
+ self.updateFruFromId(fru_id,data)
+ def SetSensorHandler(self,sensor_id,data):
+ fru_path = self.getFruSensor(sensor_id)
+ if (fru_path != ""):
+ state = { 'state' : data }
+ self.updateFru(fru_path,state)
+
+
@dbus.service.method(DBUS_NAME,
in_signature='y', out_signature='s')
def getFruSensor(self,sensor_id):
diff --git a/bin/ipmi_example.py b/bin/ipmi_example.py
index a0c5a86..1d0061d 100644
--- a/bin/ipmi_example.py
+++ b/bin/ipmi_example.py
@@ -10,6 +10,20 @@
import Openbmc
+DBUS_NAME = 'org.openbmc.sensors.IpmiBt'
+OBJ_NAME = '/org/openbmc/sensors/IpmiBt'
+
+class IpmiBt(dbus.service.Object):
+ def __init__(self,bus,name):
+ dbus.service.Object.__init__(self,bus,name)
+
+ @dbus.service.signal('org.openbmc.sensors.IpmiBt')
+ def SetSensor(self, ipmi_id, value):
+ pass
+
+ @dbus.service.signal('org.openbmc.sensors.IpmiBt')
+ def UpdateFru(self, ipmi_id, data):
+ pass
def getWatchdog():
@@ -30,8 +44,15 @@
for k2 in data[k].keys():
print "\t"+k2+" = "+str(data[k][k2])
+
+
if __name__ == '__main__':
+ dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
+ name = dbus.service.BusName(DBUS_NAME,bus)
+ obj = IpmiBt(bus,OBJ_NAME)
+ mainloop = gobject.MainLoop()
+
cmd = sys.argv[1]
data = None
ipmi_id = dbus.Byte(0)
@@ -47,18 +68,14 @@
intf = getChassisControl()
intf.powerOff()
elif (cmd == "setsensor"):
- intf_sens = Openbmc.getManagerInterface(bus,"Sensors")
- intf_sens.setSensorFromId(ipmi_id,data)
- elif (cmd == "getsensor"):
- intf_sens = Openbmc.getManagerInterface(bus,"Sensors")
- print intf_sens.getSensorFromId(ipmi_id)
+ obj.SetSensor(ipmi_id,dbus.Byte(int(data)))
elif (cmd == "getsensors"):
intf_sens = Openbmc.getManagerInterface(bus,"Sensors")
data = intf_sens.getSensors()
prettyPrint(data)
elif (cmd == "updatefru"):
- intf_fru = Openbmc.getManagerInterface(bus,"Inventory")
- intf_fru.updateFruFromId(ipmi_id,data)
+ d = { 'manufacturer' : data }
+ obj.UpdateFru(ipmi_id,d)
elif (cmd == "getfrus"):
intf_fru = Openbmc.getManagerInterface(bus,"Inventory")
data = intf_fru.getFrus()
diff --git a/bin/sensor_manager.py b/bin/sensor_manager.py
index 4d8eccd..886438a 100644
--- a/bin/sensor_manager.py
+++ b/bin/sensor_manager.py
@@ -36,41 +36,15 @@
signal_name = 'Critical', path_keyword='path')
self.sensor_cache = {}
+ @dbus.service.signal('org.openbmc.EventLog')
+ def EventLog(self, priority, message, rc):
+ pass
@dbus.service.method(DBUS_NAME,
in_signature='', out_signature='a{sa{sv}}')
def getSensors(self):
return self.sensor_cache;
- @dbus.service.method(DBUS_NAME,
- in_signature='y', out_signature='v')
- def getSensorFromId(self,ipmi_id):
- intf_sys = Openbmc.getManagerInterface(bus,"System")
- obj_info = intf_sys.getObjFromIpmi(ipmi_id)
- intf_name = str(obj_info[0])
- obj_name = str(obj_info[1])
- return self.getSensor(obj_name)
-
- @dbus.service.method(DBUS_NAME,
- in_signature='yv', out_signature='')
- def setSensorFromId(self,ipmi_id,value):
- ## first check if fru functional sensor
- intf_inv = Openbmc.getManagerInterface(bus,"Inventory")
- fru_path = intf_inv.getFruSensor(ipmi_id)
- if (fru_path != ""):
- data = { 'state': value }
- intf_inv.updateFru(fru_path,data)
- print "Found Fru Based Sensor: "+fru_path
- return None
-
- intf_sys = Openbmc.getManagerInterface(bus,"System")
- obj_info = intf_sys.getObjFromIpmi(ipmi_id)
-
- obj = bus.get_object(obj_info[0],obj_info[1])
- intf = dbus.Interface(obj,"org.openbmc.SensorValue")
- intf.setValue(value)
- return None
-
@dbus.service.method(DBUS_NAME,
in_signature='s', out_signature='v')
@@ -79,8 +53,7 @@
if (self.sensor_cache.has_key(path) == True):
val = self.sensor_cache[path]['value']
else:
- # TODO: error handling
- print "Unknown sensor at: "+path
+ self.EventLog(1,"Unknown sensor: "+path,1)
return val
## Signal handlers
diff --git a/bin/system_manager.py b/bin/system_manager.py
index b852543..eb9daa4 100644
--- a/bin/system_manager.py
+++ b/bin/system_manager.py
@@ -45,7 +45,6 @@
self.current_state = ""
self.system_states = {}
- self.IPMI_ID_LOOKUP = {}
for bus_name in System.SYSTEM_CONFIG.keys():
sys_state = System.SYSTEM_CONFIG[bus_name]['system_state']
if (self.system_states.has_key(sys_state) == False):
@@ -54,15 +53,22 @@
self.SystemStateHandler("INIT")
print "SystemManager Init Done"
+ @dbus.service.signal('org.openbmc.EventLog')
+ def EventLog(self, priority, message, rc):
+ pass
def SystemStateHandler(self,state_name):
print "Checking previous state started..."
i = 0
- not_started=True
- while(i<10 and not_started):
- not_started = self.check_state_started()
+ started=False
+ while(i<10 and started == False):
+ started = self.check_state_started()
i=i+1
- # add sleep
+ time.sleep(1)
+
+ if (i == 10):
+ self.EventLog(1,"Timeout waiting for state to finish: "+self.current_state,1)
+ return
print "Running System State: "+state_name
if (self.system_states.has_key(state_name)):
@@ -160,28 +166,13 @@
props = instance['properties']
print "Load Properties: "+obj_path
self.property_manager.loadProperties(bus_name,obj_path,props)
- ## create a lookup for ipmi id to object path
- if (props.has_key('org.openbmc.SensorValue')):
- if (props['org.openbmc.SensorValue'].has_key('ipmi_id')):
- ipmi_id = props['org.openbmc.SensorValue']['ipmi_id']
- ## TODO: check for duplicate ipmi id
- self.IPMI_ID_LOOKUP[ipmi_id]=[bus_name,obj_path]
-
## If object has an init method, call it
for init_intf in objects[instance_name]['INIT']:
obj = bus.get_object(bus_name,obj_path)
intf = dbus.Interface(obj,init_intf)
print "Calling init method: " +obj_path+" : "+init_intf
intf.init()
-#
- @dbus.service.method(DBUS_NAME,
- in_signature='y', out_signature='ss')
- def getObjFromIpmi(self,ipmi_id):
- obj_path = ""
- ## TODO: handle lookup failing
- if (self.IPMI_ID_LOOKUP.has_key(ipmi_id) == True):
- obj_info = self.IPMI_ID_LOOKUP[ipmi_id]
- return obj_info
+
@dbus.service.method(DBUS_NAME,
in_signature='s', out_signature='sis')