made bus config global and moved to system bus
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()