diff options
Diffstat (limited to 'pysystemmgr/system_manager.py')
-rw-r--r-- | pysystemmgr/system_manager.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/pysystemmgr/system_manager.py b/pysystemmgr/system_manager.py index 8bcb239..6af8727 100644 --- a/pysystemmgr/system_manager.py +++ b/pysystemmgr/system_manager.py @@ -12,6 +12,8 @@ import obmc.dbuslib.propertycacher as PropertyCacher from obmc.dbuslib.bindings import DbusProperties, DbusObjectManager, get_dbus import obmc.enums import obmc_system_config as System +import obmc.dbuslib.introspection +import obmc.utils.misc DBUS_NAME = 'org.openbmc.managers.System' OBJ_NAME = '/org/openbmc/managers/System' @@ -27,7 +29,12 @@ class SystemManager(DbusProperties,DbusObjectManager): DbusProperties.__init__(self) DbusObjectManager.__init__(self) dbus.service.Object.__init__(self,bus,obj_name) + self.bus = bus + bus.add_signal_receiver( + self.bus_handler, + dbus_interface=dbus.BUS_DAEMON_IFACE, + signal_name='NameOwnerChanged') bus.add_signal_receiver(self.NewObjectHandler, signal_name = "InterfacesAdded", sender_keyword = 'bus_name') bus.add_signal_receiver(self.SystemStateHandler,signal_name = "GotoSystemState") @@ -56,6 +63,10 @@ class SystemManager(DbusProperties,DbusObjectManager): print "Creating cache directory: "+PropertyCacher.CACHE_PATH os.makedirs(PropertyCacher.CACHE_PATH) + for s in self.bus.list_names(): + if obmc.utils.misc.org_dot_openbmc_match(s): + self.bus_handler(s, '', s) + self.InterfacesAdded(obj_name,self.properties) print "SystemManager Init Done" @@ -194,6 +205,29 @@ class SystemManager(DbusProperties,DbusObjectManager): return True + def bus_handler(self, owned_name, old, new): + if obmc.dbuslib.bindings.is_unique(owned_name) or not new: + return + + if owned_name == DBUS_NAME: + return + + objs = obmc.dbuslib.introspection.find_dbus_interfaces( + self.bus, owned_name, '/', bool) + current_state = self.Get(DBUS_NAME,"current_state") + for o in objs.keys(): + if o in self.bus_name_lookup: + continue + self.bus_name_lookup[o] = owned_name + + if current_state not in System.EXIT_STATE_DEPEND: + continue + if o in System.EXIT_STATE_DEPEND[current_state]: + print "New object: "+o+" ("+owned_name+")" + System.EXIT_STATE_DEPEND[current_state][o] = 1 + + self.try_next_state() + def NewObjectHandler(self, obj_path, iprops, bus_name = None): current_state = self.Get(DBUS_NAME,"current_state") if (self.bus_name_lookup.has_key(obj_path)): |