Recipe and service to issue the host soft power off

Change-Id: I2536c07a30b5b26f04719474e4f3a87e2fd63903
Signed-off-by: Andrew Geissler <andrewg@us.ibm.com>
diff --git a/meta-phosphor/common/recipes-phosphor/host-ipmid/host-ipmid.bb b/meta-phosphor/common/recipes-phosphor/host-ipmid/host-ipmid.bb
index 29f54a0..8b986e6 100644
--- a/meta-phosphor/common/recipes-phosphor/host-ipmid/host-ipmid.bb
+++ b/meta-phosphor/common/recipes-phosphor/host-ipmid/host-ipmid.bb
@@ -27,3 +27,14 @@
 FILES_${PN}-dev_append = " ${libdir}/host-ipmid/lib*${SOLIBSDEV} ${libdir}/host-ipmid/*.la"
 
 DBUS_SERVICE_${PN} += "org.openbmc.HostServices.service"
+
+# Soft Power Off
+RDEPENDS_${PN} += "phosphor-mapper"
+
+TMPL = "op-stop-host@.service"
+INSTFMT = "op-stop-host@{0}.service"
+TGTFMT = "obmc-stop-host@{0}.target"
+FMT = "../${TMPL}:${TGTFMT}.wants/${INSTFMT}"
+
+SYSTEMD_SERVICE_${PN} += "${TMPL}"
+SYSTEMD_LINK_${PN} += "${@compose_list(d, 'FMT', 'OBMC_HOST_INSTANCES')}"
diff --git a/meta-phosphor/common/recipes-phosphor/host-ipmid/host-ipmid/op-stop-host@.service b/meta-phosphor/common/recipes-phosphor/host-ipmid/host-ipmid/op-stop-host@.service
new file mode 100644
index 0000000..83c16bb
--- /dev/null
+++ b/meta-phosphor/common/recipes-phosphor/host-ipmid/host-ipmid/op-stop-host@.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Soft power off of the host
+
+[Service]
+Restart=no
+Type=oneshot
+RemainAfterExit=yes
+ExecStart={sbindir}/mapper call /org/openbmc/HostServices org.openbmc.HostServices SoftPowerOff
+Conflicts=obmc-chassis-start@%i.target
+
+[Install]
+WantedBy=obmc-stop-host@%i.target