Recipe for phosphor-discover-system-state

This recipe will add the new program phosphor-discover-system-state
to new builds. Additionally, the old Python state manager is
removed from the build since discover_system_state.py was the last
thing in it.

Resolves openbmc/openbmc#773

Change-Id: I99ba0f1f0264cedebc5a9a7e5fa5dbaba0b79502
Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
diff --git a/meta-phosphor/common/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bb b/meta-phosphor/common/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bb
index a0415e0..815f40f 100644
--- a/meta-phosphor/common/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bb
+++ b/meta-phosphor/common/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bb
@@ -41,6 +41,7 @@
 SUMMARY_${PN}-host-state-mgmt = "Host state management"
 RDEPENDS_${PN}-host-state-mgmt = " \
         ${VIRTUAL-RUNTIME_obmc-host-state-manager} \
+        ${VIRTUAL-RUNTIME_obmc-discover-system-state} \
         "
 
 SUMMARY_${PN}-inventory = "Inventory applications"
diff --git a/meta-phosphor/common/recipes-phosphor/state/files/phosphor-discover-system-state@.service b/meta-phosphor/common/recipes-phosphor/state/files/phosphor-discover-system-state@.service
new file mode 100644
index 0000000..325e8dc
--- /dev/null
+++ b/meta-phosphor/common/recipes-phosphor/state/files/phosphor-discover-system-state@.service
@@ -0,0 +1,16 @@
+[Unit]
+Description=Reboot If Enabled
+Wants=mapper-wait@-org-openbmc-settings-host%i.service
+After=mapper-wait@-org-openbmc-settings-host%i.service
+Wants=mapper-wait@-xyz-openbmc_project-state-host%i.service
+After=mapper-wait@-xyz-openbmc_project-state-host%i.service
+Wants=mapper-wait@-xyz-openbmc_project-state-chassis%i.service
+After=mapper-wait@-xyz-openbmc_project-state-chassis%i.service
+
+[Service]
+Restart=no
+Type=oneshot
+ExecStart={sbindir}/phosphor-discover-system-state --host %i
+
+[Install]
+WantedBy={SYSTEMD_DEFAULT_TARGET}
diff --git a/meta-phosphor/common/recipes-phosphor/state/phosphor-state-manager.bb b/meta-phosphor/common/recipes-phosphor/state/phosphor-state-manager.bb
index 5258486..ce0fa1e 100644
--- a/meta-phosphor/common/recipes-phosphor/state/phosphor-state-manager.bb
+++ b/meta-phosphor/common/recipes-phosphor/state/phosphor-state-manager.bb
@@ -20,9 +20,7 @@
 
 DBUS_PACKAGES = "${STATE_MGR_PACKAGES}"
 
-# Set SYSTEMD_PACKAGES to empty because we do not want ${PN} and DBUS_PACKAGES
-# handles the rest.
-SYSTEMD_PACKAGES = ""
+SYSTEMD_PACKAGES = "${PN}-discover"
 
 inherit autotools pkgconfig
 inherit obmc-phosphor-dbus-service
@@ -48,6 +46,12 @@
 DBUS_SERVICE_${PN}-bmc += "xyz.openbmc_project.State.BMC.service"
 
 FILES_${PN}-discover = "${sbindir}/phosphor-discover-system-state"
+SYSTEMD_SERVICE_${PN}-discover += "phosphor-discover-system-state@.service"
+
+TMPL = "phosphor-discover-system-state@.service"
+INSTFMT = "phosphor-discover-system-state@{0}.service"
+FMT = "../${TMPL}:${SYSTEMD_DEFAULT_TARGET}.wants/${INSTFMT}"
+SYSTEMD_LINK_${PN}-discover += "${@compose_list(d, 'FMT', 'OBMC_HOST_INSTANCES')}"
 
 SRC_URI += "git://github.com/openbmc/phosphor-state-manager"
 SRCREV = "cc3fb5d9a720a9a5b2102683da716004cd938e39"
diff --git a/meta-phosphor/common/recipes-phosphor/system/obmc-mgr-state.bb b/meta-phosphor/common/recipes-phosphor/system/obmc-mgr-state.bb
deleted file mode 100644
index 464cf11..0000000
--- a/meta-phosphor/common/recipes-phosphor/system/obmc-mgr-state.bb
+++ /dev/null
@@ -1,28 +0,0 @@
-SUMMARY = "OpenBMC state manager"
-DESCRIPTION = "OpenBMC state manager."
-PR = "r1"
-
-inherit skeleton-python
-inherit obmc-phosphor-systemd
-
-VIRTUAL-RUNTIME_skeleton_workbook ?= ""
-
-RDEPENDS_${PN} += "\
-        python-dbus \
-        python-json \
-        python-subprocess \
-        python-pygobject \
-        "
-
-SKELETON_DIR = "pystatemgr"
-SYSTEMD_SERVICE_${PN} += "obmc-mgr-state.service obmc-mgr-state.target"
-
-TMPL = "mapper-wait@.service"
-TGT = "obmc-mgr-state.target"
-HOST_FMT = "../${TMPL}:${TGT}.wants/mapper-wait@-org-openbmc-settings-host{0}.service"
-CHASSIS_FMT = "../${TMPL}:${TGT}.wants/mapper-wait@-org-openbmc-control-chassis{0}.service"
-POWER_FMT = "../${TMPL}:${TGT}.wants/mapper-wait@-org-openbmc-control-power{0}.service"
-
-SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'HOST_FMT', 'OBMC_HOST_INSTANCES')}"
-SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'CHASSIS_FMT', 'OBMC_CHASSIS_INSTANCES')}"
-SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'POWER_FMT', 'OBMC_POWER_INSTANCES')}"
diff --git a/meta-phosphor/common/recipes-phosphor/system/obmc-mgr-state/obmc-mgr-state.service b/meta-phosphor/common/recipes-phosphor/system/obmc-mgr-state/obmc-mgr-state.service
deleted file mode 100644
index 681abb4..0000000
--- a/meta-phosphor/common/recipes-phosphor/system/obmc-mgr-state/obmc-mgr-state.service
+++ /dev/null
@@ -1,15 +0,0 @@
-[Unit]
-Description=Restore Last State
-Wants=obmc-mgr-state.target
-After=obmc-mgr-state.target
-Wants=mapper-wait@-org-openbmc-settings-host0.service
-After=mapper-wait@-org-openbmc-settings-host0.service
-
-[Service]
-Restart=no
-Type=oneshot
-ExecStart={sbindir}/discover_system_state.py
-Environment="PYTHONUNBUFFERED=1"
-
-[Install]
-WantedBy={SYSTEMD_DEFAULT_TARGET}
diff --git a/meta-phosphor/common/recipes-phosphor/system/obmc-mgr-state/obmc-mgr-state.target b/meta-phosphor/common/recipes-phosphor/system/obmc-mgr-state/obmc-mgr-state.target
deleted file mode 100644
index fef2a1f..0000000
--- a/meta-phosphor/common/recipes-phosphor/system/obmc-mgr-state/obmc-mgr-state.target
+++ /dev/null
@@ -1,2 +0,0 @@
-[Unit]
-Description=Restore Last State