made bus config global and moved to system bus
diff --git a/Makefile b/Makefile
index 156fd8e..9e87539 100644
--- a/Makefile
+++ b/Makefile
@@ -28,6 +28,9 @@
setup:
mkdir obj
+clean:
+ rm -rf obj
+
libopenbmc_intf: openbmc_intf.o
$(CC) -shared -o bin/$@.so obj/openbmc_intf.o $(CFLAGS)
@@ -71,4 +74,4 @@
$(CC) -o bin/$@.exe obj/pcie_slot_present_obj.o obj/gpio.o $(OFLAGS) $(CFLAGS)
-all: setup libopenbmc_intf power_control chassis_identify sensor_ambient button_power sensor_host_status control_host fan host_watchdog control_bmc sensor_occ board_vpd
+all: clean setup libopenbmc_intf power_control chassis_identify sensor_ambient button_power sensor_host_status control_host fan host_watchdog control_bmc sensor_occ board_vpd pcie_slot_present
diff --git a/bin/Openbmc.py b/bin/Openbmc.py
index bb3a879..c81209f 100644
--- a/bin/Openbmc.py
+++ b/bin/Openbmc.py
@@ -4,7 +4,7 @@
BUS_PREFIX = 'org.openbmc'
OBJ_PREFIX = "/org/openbmc"
GPIO_DEV = '/sys/class/gpio'
-
+BUS = "system"
FRU_TYPES = {
'SYSTEM' : 0,
@@ -48,6 +48,14 @@
'bool' : 'dbus.Boolean'
}
+def getDBus():
+ bus = None
+ if (BUS == "session"):
+ bus = dbus.SessionBus()
+ else:
+ bus = dbus.SystemBus()
+ return bus
+
def getManagerInterface(bus,manager):
bus_name = "org.openbmc.managers."+manager
diff --git a/bin/chassis_control.py b/bin/chassis_control.py
index 1956860..2770507 100644
--- a/bin/chassis_control.py
+++ b/bin/chassis_control.py
@@ -6,6 +6,7 @@
import dbus
import dbus.service
import dbus.mainloop.glib
+import Openbmc
DBUS_NAME = 'org.openbmc.control.Chassis'
OBJ_NAME = '/org/openbmc/control/'+sys.argv[1]
@@ -37,9 +38,6 @@
self.reboot = 0
self.last_power_state = 0
- bus = dbus.SessionBus()
-
-
bus.add_signal_receiver(self.power_button_signal_handler,
dbus_interface = "org.openbmc.Button", signal_name = "ButtonPressed",
path="/org/openbmc/buttons/PowerButton_0" )
@@ -150,7 +148,7 @@
if __name__ == '__main__':
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
- bus = dbus.SessionBus()
+ bus = Openbmc.getDBus()
name = dbus.service.BusName(DBUS_NAME, bus)
obj = ChassisControlObject(bus, OBJ_NAME)
mainloop = gobject.MainLoop()
diff --git a/bin/download_manager.py b/bin/download_manager.py
index 842b45e..dbf7c8e 100644
--- a/bin/download_manager.py
+++ b/bin/download_manager.py
@@ -17,7 +17,6 @@
class DownloadManagerObject(dbus.service.Object):
def __init__(self,bus,name):
dbus.service.Object.__init__(self,bus,name)
- bus = dbus.SessionBus()
bus.add_signal_receiver(self.DownloadHandler,
dbus_interface = "org.openbmc.Flash", signal_name = "Download")
@@ -47,8 +46,7 @@
if __name__ == '__main__':
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
-
- bus = dbus.SessionBus()
+ bus = Openbmc.getDBus()
name = dbus.service.BusName(DBUS_NAME, bus)
obj = DownloadManagerObject(bus, OBJ_NAME)
mainloop = gobject.MainLoop()
diff --git a/bin/flash_manager.py b/bin/flash_manager.py
index 980341b..43a1899 100644
--- a/bin/flash_manager.py
+++ b/bin/flash_manager.py
@@ -32,7 +32,6 @@
'interface_name' : 'org.openbmc.Flash'
}
}
- bus = dbus.SessionBus()
bus.add_signal_receiver(self.UpdatedHandler,
dbus_interface = "org.openbmc.Flash", signal_name = "Updated", path_keyword='path')
@@ -79,8 +78,7 @@
if __name__ == '__main__':
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
-
- bus = dbus.SessionBus()
+ bus = Openbmc.getDBus()
name = dbus.service.BusName(DBUS_NAME, bus)
obj = FlashManagerObject(bus, OBJ_NAME)
mainloop = gobject.MainLoop()
diff --git a/bin/inventory_items.py b/bin/inventory_items.py
index 52bca0a..c8aa7fd 100644
--- a/bin/inventory_items.py
+++ b/bin/inventory_items.py
@@ -24,7 +24,12 @@
class Inventory(dbus.service.Object):
def __init__(self,bus,name):
+ global FRU_PATH
dbus.service.Object.__init__(self,bus,name)
+ if not os.path.exists(FRU_PATH):
+ os.makedirs(FRU_PATH)
+
+
self.objects = [ ]
def addItem(self,item):
@@ -110,14 +115,14 @@
for k in data2.keys():
self.item[k] = data2[k]
except Exception as e:
- print "ERROR: " +str(e)
+ print "No cache file found: " +str(e)
finally:
p.close()
if __name__ == '__main__':
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
- bus = dbus.SessionBus()
+ bus = Openbmc.getDBus()
name = dbus.service.BusName(DBUS_NAME,bus)
mainloop = gobject.MainLoop()
obj_parent = Inventory(bus, '/org/openbmc/managers/Inventory')
diff --git a/bin/ipmi_example.py b/bin/ipmi_example.py
index fc9123b..33847e5 100644
--- a/bin/ipmi_example.py
+++ b/bin/ipmi_example.py
@@ -39,7 +39,8 @@
if __name__ == '__main__':
#dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
- bus = dbus.SessionBus()
+ bus = Openbmc.getDBus()
+
#name = dbus.service.BusName(DBUS_NAME,bus)
#mainloop = gobject.MainLoop()
diff --git a/bin/sensor_manager.py b/bin/sensor_manager.py
index 5b48437..9f3ab56 100644
--- a/bin/sensor_manager.py
+++ b/bin/sensor_manager.py
@@ -88,7 +88,7 @@
if __name__ == '__main__':
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
- bus = dbus.SessionBus()
+ bus = Openbmc.getDBus()
name = dbus.service.BusName(DBUS_NAME,bus)
obj = SensorManager(bus,OBJ_NAME)
mainloop = gobject.MainLoop()
diff --git a/bin/system_manager.py b/bin/system_manager.py
index 07de9c0..864688d 100644
--- a/bin/system_manager.py
+++ b/bin/system_manager.py
@@ -208,7 +208,7 @@
if __name__ == '__main__':
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
- bus = dbus.SessionBus()
+ bus = Openbmc.getDBus()
name = dbus.service.BusName(DBUS_NAME,bus)
obj = SystemManager(bus,OBJ_NAME)
mainloop = gobject.MainLoop()
diff --git a/includes/openbmc.h b/includes/openbmc.h
index 576d3a4..07546e2 100644
--- a/includes/openbmc.h
+++ b/includes/openbmc.h
@@ -3,6 +3,9 @@
#include <stdint.h>
+//select which dbus
+#define DBUS_TYPE G_BUS_TYPE_SYSTEM
+
// Macros
#define GET_VARIANT(v) g_variant_get_variant(v)
#define GET_VARIANT_D(v) g_variant_get_double(g_variant_get_variant(v))
@@ -13,8 +16,6 @@
#define NEW_VARIANT_B(v) g_variant_new_variant(g_variant_new_byte(v))
#define VARIANT_COMPARE(x,y) g_variant_compare(GET_VARIANT(x),GET_VARIANT(y))
-
-
#ifdef __arm__
static inline void devmem(void* addr, uint32_t val)
{
diff --git a/objects/board_vpd_obj.c b/objects/board_vpd_obj.c
index f7a87d6..217148b 100644
--- a/objects/board_vpd_obj.c
+++ b/objects/board_vpd_obj.c
@@ -17,7 +17,7 @@
loop = g_main_loop_new (NULL, FALSE);
error = NULL;
- c = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
+ c = g_bus_get_sync (DBUS_TYPE, NULL, &error);
error = NULL;
p = g_dbus_proxy_new_sync (c,
diff --git a/objects/button_power_obj.c b/objects/button_power_obj.c
index b535d50..30078bb 100644
--- a/objects/button_power_obj.c
+++ b/objects/button_power_obj.c
@@ -126,7 +126,7 @@
guint id;
loop = g_main_loop_new (NULL, FALSE);
- id = g_bus_own_name (G_BUS_TYPE_SESSION,
+ id = g_bus_own_name (DBUS_TYPE,
dbus_name,
G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
G_BUS_NAME_OWNER_FLAGS_REPLACE,
diff --git a/objects/chassis_identify_obj.c b/objects/chassis_identify_obj.c
index 4a0ecb8..1206d17 100644
--- a/objects/chassis_identify_obj.c
+++ b/objects/chassis_identify_obj.c
@@ -133,7 +133,7 @@
guint id;
loop = g_main_loop_new (NULL, FALSE);
- id = g_bus_own_name (G_BUS_TYPE_SESSION,
+ id = g_bus_own_name (DBUS_TYPE,
dbus_name,
G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
G_BUS_NAME_OWNER_FLAGS_REPLACE,
diff --git a/objects/control_bmc_obj.c b/objects/control_bmc_obj.c
index 617e4a7..d6f3fbf 100644
--- a/objects/control_bmc_obj.c
+++ b/objects/control_bmc_obj.c
@@ -182,7 +182,7 @@
guint id;
loop = g_main_loop_new (NULL, FALSE);
- id = g_bus_own_name (G_BUS_TYPE_SESSION,
+ id = g_bus_own_name (DBUS_TYPE,
dbus_name,
G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
G_BUS_NAME_OWNER_FLAGS_REPLACE,
diff --git a/objects/control_host_obj.c b/objects/control_host_obj.c
index 857f300..ec62a37 100644
--- a/objects/control_host_obj.c
+++ b/objects/control_host_obj.c
@@ -170,7 +170,7 @@
guint id;
loop = g_main_loop_new (NULL, FALSE);
- id = g_bus_own_name (G_BUS_TYPE_SESSION,
+ id = g_bus_own_name (DBUS_TYPE,
dbus_name,
G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
G_BUS_NAME_OWNER_FLAGS_REPLACE,
diff --git a/objects/fan_generic_obj.c b/objects/fan_generic_obj.c
index 990a5e9..afe3318 100644
--- a/objects/fan_generic_obj.c
+++ b/objects/fan_generic_obj.c
@@ -114,7 +114,7 @@
guint id;
loop = g_main_loop_new (NULL, FALSE);
- id = g_bus_own_name (G_BUS_TYPE_SESSION,
+ id = g_bus_own_name (DBUS_TYPE,
dbus_name,
G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
G_BUS_NAME_OWNER_FLAGS_REPLACE,
diff --git a/objects/flash_bios_obj.c b/objects/flash_bios_obj.c
index cb3f70a..637f44a 100644
--- a/objects/flash_bios_obj.c
+++ b/objects/flash_bios_obj.c
@@ -178,7 +178,7 @@
guint id;
loop = g_main_loop_new (NULL, FALSE);
- id = g_bus_own_name (G_BUS_TYPE_SESSION,
+ id = g_bus_own_name (DBUS_TYPE,
dbus_name,
G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
G_BUS_NAME_OWNER_FLAGS_REPLACE,
diff --git a/objects/host_watchdog_obj.c b/objects/host_watchdog_obj.c
index d038e15..65c5fa4 100644
--- a/objects/host_watchdog_obj.c
+++ b/objects/host_watchdog_obj.c
@@ -131,7 +131,7 @@
guint id;
loop = g_main_loop_new (NULL, FALSE);
- id = g_bus_own_name (G_BUS_TYPE_SESSION,
+ id = g_bus_own_name (DBUS_TYPE,
dbus_name,
G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
G_BUS_NAME_OWNER_FLAGS_REPLACE,
diff --git a/objects/pcie_slot_present_obj.c b/objects/pcie_slot_present_obj.c
index 64b30f5..5b150b5 100644
--- a/objects/pcie_slot_present_obj.c
+++ b/objects/pcie_slot_present_obj.c
@@ -134,7 +134,7 @@
loop = g_main_loop_new (NULL, FALSE);
error = NULL;
- c = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
+ c = g_bus_get_sync (DBUS_TYPE, NULL, &error);
error = NULL;
sys_proxy = g_dbus_proxy_new_sync (c,
diff --git a/objects/power_control_obj.c b/objects/power_control_obj.c
index 6e54787..ec48d87 100644
--- a/objects/power_control_obj.c
+++ b/objects/power_control_obj.c
@@ -262,7 +262,7 @@
guint id;
loop = g_main_loop_new (NULL, FALSE);
- id = g_bus_own_name (G_BUS_TYPE_SESSION,
+ id = g_bus_own_name (DBUS_TYPE,
dbus_name,
G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
G_BUS_NAME_OWNER_FLAGS_REPLACE,
diff --git a/objects/sensor_host_status_obj.c b/objects/sensor_host_status_obj.c
index 825117a..d631200 100644
--- a/objects/sensor_host_status_obj.c
+++ b/objects/sensor_host_status_obj.c
@@ -163,7 +163,7 @@
guint id;
loop = g_main_loop_new (NULL, FALSE);
- id = g_bus_own_name (G_BUS_TYPE_SESSION,
+ id = g_bus_own_name (DBUS_TYPE,
dbus_name,
G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
G_BUS_NAME_OWNER_FLAGS_REPLACE,
diff --git a/objects/sensor_occ_obj.c b/objects/sensor_occ_obj.c
index 91935f2..669579f 100644
--- a/objects/sensor_occ_obj.c
+++ b/objects/sensor_occ_obj.c
@@ -165,7 +165,7 @@
loop = g_main_loop_new (NULL, FALSE);
cmd.loop = loop;
- id = g_bus_own_name (G_BUS_TYPE_SESSION,
+ id = g_bus_own_name (DBUS_TYPE,
dbus_name,
G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
G_BUS_NAME_OWNER_FLAGS_REPLACE,
diff --git a/objects/sensor_temperature_ambient_obj.c b/objects/sensor_temperature_ambient_obj.c
index a70fb62..eb8fe8c 100644
--- a/objects/sensor_temperature_ambient_obj.c
+++ b/objects/sensor_temperature_ambient_obj.c
@@ -169,7 +169,7 @@
guint id;
loop = g_main_loop_new (NULL, FALSE);
- id = g_bus_own_name (G_BUS_TYPE_SESSION,
+ id = g_bus_own_name (DBUS_TYPE,
dbus_name,
G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
G_BUS_NAME_OWNER_FLAGS_REPLACE,