From 61cdfad0356929c025837e82296ae38869f0a266 Mon Sep 17 00:00:00 2001 From: Raptor Engineering Development Team Date: Sun, 21 Jan 2018 06:01:29 -0600 Subject: Update IPL status observer to allow IPL complete target holdoff --- pyiplobserver/ipl_status_observer.py | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/pyiplobserver/ipl_status_observer.py b/pyiplobserver/ipl_status_observer.py index 3d08b13..f5e3d25 100644 --- a/pyiplobserver/ipl_status_observer.py +++ b/pyiplobserver/ipl_status_observer.py @@ -26,6 +26,9 @@ import obmc.system DBUS_NAME = 'org.openbmc.status.IPL' OBJ_NAME = u'/org/openbmc/status/IPL' +IPL_FLAG_DIR = '/run/openbmc/' +IPL_FLAG_FILE = 'host@0-ipl-complete' + HOST_STATUS_RUNNING = "xyz.openbmc_project.State.Host.HostState.Running" IPL_SBE_DONE_ISTEP_MAJOR = 5 @@ -48,6 +51,9 @@ class IPLStatus(DbusProperties, DbusObjectManager): self.last_status = ""; self.last_istep = ""; + if not os.path.exists(IPL_FLAG_DIR): + os.makedirs(IPL_FLAG_DIR) + host_state_dev = self.bus.get_object("xyz.openbmc_project.State.Host", u'/xyz/openbmc_project/state/host0') host_state_iface = dbus.Interface(host_state_dev, 'org.freedesktop.DBus.Properties') host_state_value = host_state_iface.Get("xyz.openbmc_project.State.Host", "CurrentHostState") @@ -177,15 +183,24 @@ class IPLStatus(DbusProperties, DbusObjectManager): if (self.prev_access_fail_count < 255): self.prev_access_fail_count += 1 - if ((current_status == "IPL_COMPLETE") and (self.last_status != current_status)): - # Signal systemd that IPL is complete - try: - systemd_emit_dev = self.bus.get_object("org.freedesktop.systemd1", u"/org/freedesktop/systemd1") - systemd_emit_iface = dbus.Interface(systemd_emit_dev, 'org.freedesktop.systemd1.Manager') - systemd_emit_function = getattr(systemd_emit_iface, 'StartUnit') - systemd_emit_function.call_async('obmc-host-ipl-complete@0.target', 'replace') - except Exception as e: - pass + if (self.last_status != current_status): + if (current_status == "IPL_COMPLETE"): + # Signal systemd that IPL is complete + try: + with open(IPL_FLAG_DIR + IPL_FLAG_FILE, 'a'): + os.utime(IPL_FLAG_DIR + IPL_FLAG_FILE, None) + + systemd_emit_dev = self.bus.get_object("org.freedesktop.systemd1", u"/org/freedesktop/systemd1") + systemd_emit_iface = dbus.Interface(systemd_emit_dev, 'org.freedesktop.systemd1.Manager') + systemd_emit_function = getattr(systemd_emit_iface, 'StartUnit') + systemd_emit_function.call_async('obmc-host-ipl-complete@0.target', 'replace') + except Exception as e: + pass + else: + try: + os.remove(IPL_FLAG_DIR + IPL_FLAG_FILE,) + except: + pass # Since it is extremely unlikely that both fetches will fail unless the host is offline, simply check that both fetches passed or failed before continuing if (sbe_fetch_failed == hostboot_fetch_failed): -- cgit v1.2.1