diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2016-07-24 10:04:09 -0400 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2016-07-26 15:21:17 -0400 |
commit | 6173a8965e28e2bc2981f90eaee3c5ee1b44c5e9 (patch) | |
tree | ce0363b56daecfa79c98f32a4f0fb7dfda8ceff0 /pysystemmgr | |
parent | fc38a575c694d8611e71a8b5800fe09240d4bbdb (diff) | |
download | talos-skeleton-6173a8965e28e2bc2981f90eaee3c5ee1b44c5e9.tar.gz talos-skeleton-6173a8965e28e2bc2981f90eaee3c5ee1b44c5e9.zip |
system_manager: wait for objects with mapper wait
This is much faster than the current introspection based
mechanism.
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Change-Id: I1a737cab00311e9e0c0b63f4d8a487085cdf44e0
Diffstat (limited to 'pysystemmgr')
-rw-r--r-- | pysystemmgr/system_manager.py | 55 |
1 files changed, 7 insertions, 48 deletions
diff --git a/pysystemmgr/system_manager.py b/pysystemmgr/system_manager.py index cfbb0f4..d6f9fe7 100644 --- a/pysystemmgr/system_manager.py +++ b/pysystemmgr/system_manager.py @@ -13,6 +13,7 @@ import obmc.enums import obmc_system_config as System import obmc.dbuslib.introspection import obmc.utils.misc +import obmc.mapper.utils DBUS_NAME = 'org.openbmc.managers.System' OBJ_NAME = '/org/openbmc/managers/System' @@ -29,10 +30,6 @@ class SystemManager(DbusProperties, DbusObjectManager): 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( @@ -62,30 +59,9 @@ 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) - print "SystemManager Init Done" - def try_next_state(self): - current_state = self.Get(DBUS_NAME, "current_state") - if current_state not in System.EXIT_STATE_DEPEND: - return - - if all(System.EXIT_STATE_DEPEND[current_state].values()): - print "All required objects started for "+current_state - self.gotoNextState() - def SystemStateHandler(self, state_name): - ## clearing object started flags - current_state = self.Get(DBUS_NAME, "current_state") - try: - for obj_path in System.EXIT_STATE_DEPEND[current_state]: - System.EXIT_STATE_DEPEND[current_state][obj_path] = 0 - except: - pass - print "Running System State: "+state_name if state_name in self.system_states: for name in self.system_states[state_name]: @@ -106,6 +82,12 @@ class SystemManager(DbusProperties, DbusObjectManager): self.Set(DBUS_NAME, "current_state", state_name) + waitlist = System.EXIT_STATE_DEPEND.get(state_name, {}).keys() + if waitlist: + self.waiter = obmc.mapper.utils.Wait( + self.bus, waitlist, + callback=self.gotoNextState) + def gotoNextState(self): s = 0 current_state = self.Get(DBUS_NAME, "current_state") @@ -182,25 +164,6 @@ class SystemManager(DbusProperties, DbusObjectManager): ## TODO: error print "ERROR: starting process: "+" ".join(cmdline) - 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 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 current_state not in System.EXIT_STATE_DEPEND: @@ -208,10 +171,6 @@ class SystemManager(DbusProperties, DbusObjectManager): if obj_path in System.EXIT_STATE_DEPEND[current_state]: print "New object: "+obj_path+" ("+bus_name+")" - System.EXIT_STATE_DEPEND[current_state][obj_path] = 1 - ## check if all required objects are - # started to move to next state - self.try_next_state() @dbus.service.method(DBUS_NAME, in_signature='s', out_signature='sis') def gpioInit(self, name): |