greatlakes: support SoL on multi-host

Description:
- Support Meta greatlakes SoL on multi-host

Design:
- We designed by 4 clients on port 2200~2203 represents Host1 ~ Host4,
and 4 clients on port 2300~2303 represents BIC1 ~ BIC4, the clients will
use socket-id to connect to corresponding server.
- For switching between Host/BIC, each client will manipulate the UART
mux by the cpld driver before connect to the server. The script for
switching the mux can be implemented in project layer.

Limitation:
- Since the CPLD device driver is not ready yet, we currently use raw
commands (i2ctransfer) to manipulate the register value, we will adapt
to the interface on CPLD device drvier when it's ready.

Issue:
- None

Test Case:
1. Check ssh -p 2200 ${ip} should successfully connect to Slot 1 Host.
- pass
2. Check ssh -p 2300 ${ip} should successfully connect to Slot 1 BIC.
- pass
3. Check ssh -p 2201 ${ip} should successfully connect to Slot 2 Host.
- pass
4. Check ssh -p 2301 ${ip} should successfully connect to Slot 2 BIC.
- pass
5. Check ssh -p 2202 ${ip} should successfully connect to Slot 3 Host.
- pass
6. Check ssh -p 2302 ${ip} should successfully connect to Slot 3 BIC.
- pass
7. Check ssh -p 2203 ${ip} should successfully connect to Slot 4 Host.
- pass
8. Check ssh -p 2303 ${ip} should successfully connect to Slot 4 BIC.
- pass

Change-Id: I3ebe12d4cabb01b401220c053cced089141e79e8
Signed-off-by: Bonnie Lo <Bonnie_Lo@wiwynn.com>
diff --git a/meta-facebook/recipes-phosphor/console/obmc-console_%.bbappend b/meta-facebook/recipes-phosphor/console/obmc-console_%.bbappend
index 05b4a4e..0253c39 100644
--- a/meta-facebook/recipes-phosphor/console/obmc-console_%.bbappend
+++ b/meta-facebook/recipes-phosphor/console/obmc-console_%.bbappend
@@ -1,5 +1,6 @@
 FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
 OBMC_CONSOLE_HOST_TTY = "ttyS2"
+OBMC_CONSOLE_TTYS:fb-compute-multihost = "ttyS0 ttyS1 ttyS2 ttyS3"
 
 SRC_URI:append:fb-compute-singlehost = " file://server.ttyS2.conf"
 
@@ -12,9 +13,28 @@
                                         file://client.2202.conf \
                                         file://client.2203.conf"
 
+CLIENT_SERVICE_FILES_FMT = "file://${BPN}-{0}-ssh-host@.service \
+                            file://${BPN}-{0}-ssh-bic@.service \
+                            file://${BPN}-{0}-ssh-host.socket \
+                            file://${BPN}-{0}-ssh-bic.socket"
+
+SRC_URI:append:fb-compute-multihost = " \
+                        ${@compose_list(d, 'CLIENT_SERVICE_FILES_FMT', 'OBMC_CONSOLE_TTYS')}"
+
+CLIENT_SERVICE_FMT = "${PN}-{0}-ssh-host@.service \
+                      ${PN}-{0}-ssh-bic@.service \
+                      ${PN}-{0}-ssh-host.socket \
+                      ${PN}-{0}-ssh-bic.socket"
+
+SYSTEMD_SERVICE:${PN}:append:fb-compute-multihost = " \
+                        ${@compose_list(d, 'CLIENT_SERVICE_FMT', 'OBMC_CONSOLE_TTYS')} \
+                        "
+
 SRC_URI:remove = "file://${BPN}.conf"
 
 SYSTEMD_SERVICE:${PN}:remove:fb-compute-multihost = "obmc-console-ssh.socket"
+SYSTEMD_SERVICE:${PN}:remove:fb-compute-multihost = "obmc-console-ssh@.service"
+
 EXTRA_OECONF:append:fb-compute-multihost = " --enable-concurrent-servers"
 
 do_install:append() {
@@ -24,3 +44,16 @@
         # Remove upstream-provided server configuration
         rm -f ${D}${sysconfdir}/${BPN}/server.ttyVUART0.conf
 }
+
+do_install:append:fb-compute-multihost() {
+        # Implement a script called "select-uart-mux" in project layer and follow the interface below:
+        # Usage: select-uart-mux <slot1|slot2|slot3|slot4> <host|bic>
+        install -m 0644 ${WORKDIR}/${BPN}-*-ssh-bic@.service ${D}${systemd_system_unitdir}
+        install -m 0644 ${WORKDIR}/${BPN}-*-ssh-bic.socket ${D}${systemd_system_unitdir}
+        install -m 0644 ${WORKDIR}/${BPN}-*-ssh-host@.service ${D}${systemd_system_unitdir}
+        install -m 0644 ${WORKDIR}/${BPN}-*-ssh-host.socket ${D}${systemd_system_unitdir}
+
+        rm -rf ${D}${systemd_system_unitdir}/obmc-console-ssh@.service.d/
+        rm -f ${D}${systemd_system_unitdir}/${BPN}-ssh@.service
+        rm -f ${D}${systemd_system_unitdir}/${BPN}-ssh.socket
+}