Split Rocket startup from REST application

Enable drop-in replacement of WSGI application hosts
with PREFERRED_PROVIDER_virtual/obmc-wsgihost.

Change-Id: Ieaa4b17cb4645bfc3224aca2edebb15d023982d5
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/meta-phosphor/common/recipes-phosphor/interfaces/phosphor-rest.bb b/meta-phosphor/common/recipes-phosphor/interfaces/phosphor-rest.bb
index 3fda832..b03b245 100644
--- a/meta-phosphor/common/recipes-phosphor/interfaces/phosphor-rest.bb
+++ b/meta-phosphor/common/recipes-phosphor/interfaces/phosphor-rest.bb
@@ -1,28 +1,31 @@
-SUMMARY = "Phosphor DBUS REST Server"
-DESCRIPTION = "Phosphor DBUS REST manager."
+SUMMARY = "Phosphor DBUS to REST WSGI Application"
+DESCRIPTION = "Phosphor DBUS to REST WSGI Application."
 HOMEPAGE = "http://github.com/openbmc/phosphor-rest-server"
 PR = "r1"
 LICENSE = "Apache-2.0"
-LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=fa818a259cbed7ce8bc2a22d35a464fc"
+LIC_FILES_CHKSUM = "file://${WORKDIR}/git/LICENSE;md5=fa818a259cbed7ce8bc2a22d35a464fc"
 
 inherit allarch
 inherit obmc-phosphor-systemd
 inherit setuptools
 
+RRECOMMENDS_${PN} += "virtual-obmc-wsgihost"
+
 RDEPENDS_${PN} += " \
         python-xml \
         python-dbus \
-        python-pygobject \
         obmc-mapper \
-        python-rocket \
         python-bottle \
         python-spwd \
-        python-netserver \
         pyphosphor-utils \
         pyphosphor-dbus \
+        pyphosphor-wsgi-apps-ns \
         "
 SRC_URI += "git://github.com/openbmc/phosphor-rest-server"
 
-SRCREV = "803c6f1be7f589043c817a2b00fac5b0af93d200"
+SRCREV = "2c6fc760919cc214413874d60489e3643b639692"
 
-S = "${WORKDIR}/git"
+S = "${WORKDIR}/git/module"
+SYSTEMD_SERVICE_${PN} = ""
+SYSTEMD_OVERRIDE_${PN} += "rest-dbus.conf:obmc-mapper.target.d/rest-dbus.conf"
+SYSTEMD_ENVIRONMENT_FILE_${PN} += "obmc/wsgi_app"
diff --git a/meta-phosphor/common/recipes-phosphor/interfaces/phosphor-rest/obmc/wsgi_app b/meta-phosphor/common/recipes-phosphor/interfaces/phosphor-rest/obmc/wsgi_app
new file mode 100644
index 0000000..7bbffe7
--- /dev/null
+++ b/meta-phosphor/common/recipes-phosphor/interfaces/phosphor-rest/obmc/wsgi_app
@@ -0,0 +1 @@
+APPLICATION=rest_dbus
diff --git a/meta-phosphor/common/recipes-phosphor/interfaces/phosphor-rest/phosphor-rest.service b/meta-phosphor/common/recipes-phosphor/interfaces/phosphor-rest/phosphor-rest.service
deleted file mode 100644
index 6b1c33d..0000000
--- a/meta-phosphor/common/recipes-phosphor/interfaces/phosphor-rest/phosphor-rest.service
+++ /dev/null
@@ -1,13 +0,0 @@
-[Unit]
-Description=Phosphor DBus REST
-Requires=obmc-mapper.target
-After=obmc-mapper.target
-PartOf=systemd-networkd.service
-
-[Service]
-Restart=always
-ExecStart={sbindir}/phosphor-rest
-Environment="PYTHONUNBUFFERED=1"
-
-[Install]
-WantedBy={SYSTEMD_DEFAULT_TARGET}
diff --git a/meta-phosphor/common/recipes-phosphor/interfaces/phosphor-rest/rest-dbus.conf b/meta-phosphor/common/recipes-phosphor/interfaces/phosphor-rest/rest-dbus.conf
new file mode 100644
index 0000000..a92f0f1
--- /dev/null
+++ b/meta-phosphor/common/recipes-phosphor/interfaces/phosphor-rest/rest-dbus.conf
@@ -0,0 +1,3 @@
+[Unit]
+Wants=obmc-webserver-pre.target
+Before=obmc-webserver-pre.target
diff --git a/meta-phosphor/common/recipes-phosphor/interfaces/phosphor-rocket.bb b/meta-phosphor/common/recipes-phosphor/interfaces/phosphor-rocket.bb
new file mode 100644
index 0000000..0d93f23
--- /dev/null
+++ b/meta-phosphor/common/recipes-phosphor/interfaces/phosphor-rocket.bb
@@ -0,0 +1,22 @@
+SUMMARY = "Phosphor Rocket startup script"
+DESCRIPTION = "Phosphor Rocket startup script."
+HOMEPAGE = "http://github.com/openbmc/phosphor-rest-server"
+PR = "r1"
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://${WORKDIR}/git/LICENSE;md5=fa818a259cbed7ce8bc2a22d35a464fc"
+
+inherit allarch
+inherit setuptools
+inherit obmc-phosphor-systemd
+
+PROVIDES += "virtual/obmc-wsgihost"
+RPROVIDES_${PN} += "virtual-obmc-wsgihost"
+
+RDEPENDS_${PN} += " \
+        python-rocket \
+        "
+SRC_URI += "git://github.com/openbmc/phosphor-rest-server"
+
+SRCREV = "2c6fc760919cc214413874d60489e3643b639692"
+
+S = "${WORKDIR}/git/servers/rocket"
diff --git a/meta-phosphor/common/recipes-phosphor/interfaces/phosphor-rocket/phosphor-rocket.service b/meta-phosphor/common/recipes-phosphor/interfaces/phosphor-rocket/phosphor-rocket.service
new file mode 100644
index 0000000..41eaf8b
--- /dev/null
+++ b/meta-phosphor/common/recipes-phosphor/interfaces/phosphor-rocket/phosphor-rocket.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Phosphor Webserver
+PartOf=systemd-networkd.service
+After=obmc-webserver-pre.target
+
+[Service]
+Restart=always
+ExecStart={sbindir}/phosphor-rocket $APPLICATION
+Environment="PYTHONUNBUFFERED=1"
+EnvironmentFile={envfiledir}/obmc/wsgi_app
+
+[Install]
+WantedBy={SYSTEMD_DEFAULT_TARGET}