Commit 25e56ce1 authored by Waleed Akbar's avatar Waleed Akbar
Browse files

Refactor deployment script to use functions for patching WebUI title based on controller role.

parent 89bbbea2
Loading
Loading
Loading
Loading
+22 −4
Changes for src/tests/mwc26-f5ga/deploy.sh: 22 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -16,7 +16,22 @@
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "${SCRIPT_DIR}/../../../.." && pwd)"
REPO_ROOT="$(cd "${SCRIPT_DIR}/../../.." && pwd)"

WEBUI_HOME_HTML="${REPO_ROOT}/src/webui/service/templates/main/home.html"

# Temporarily label the WebUI title with the controller role, so the built image
# carries it. The working tree is restored by restore_webui_title, also armed as
# an EXIT trap so an aborted deployment leaves no local change behind.
patch_webui_title() {
    sed -i "s|\(<h2>ETSI TeraFlowSDN Controller\)</h2>|\1 ($1)</h2>|" "${WEBUI_HOME_HTML}"
    trap restore_webui_title EXIT
}

restore_webui_title() {
    trap - EXIT
    sed -i 's|\(<h2>ETSI TeraFlowSDN Controller\) ([^)]*)</h2>|\1</h2>|' "${WEBUI_HOME_HTML}"
}

# Assuming the instances are named as: simap-datastore, tfs-e2e-ctrl, tfs-agg-ctrl, tfs-ip-ctrl

@@ -74,9 +89,10 @@ case "$HOSTNAME" in
        ;;
    tfs-e2e-ctrl)
        echo "Deploying TFS E2E Controller..."
        sed -i 's|\(<h2>ETSI TeraFlowSDN Controller\)</h2>|\1 (End-to-End)</h2>|' src/webui/service/templates/main/home.html
        patch_webui_title "End-to-End"
        source ~/tfs-ctrl/src/tests/mwc26-f5ga/deploy-specs-e2e.sh
        ./deploy/all.sh
        restore_webui_title

        echo "Waiting for NATS connection..."
        while ! kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/contextservice -c server 2>&1 | grep -q 'Subscriber is Ready? True'; do sleep 1; done
@@ -84,9 +100,10 @@ case "$HOSTNAME" in
        ;;
    tfs-agg-ctrl)
        echo "Deploying TFS Agg Controller..."
        sed -i 's|\(<h2>ETSI TeraFlowSDN Controller\)</h2>|\1 (Aggregation)</h2>|' src/webui/service/templates/main/home.html
        patch_webui_title "Aggregation"
        source ~/tfs-ctrl/src/tests/mwc26-f5ga/deploy-specs-agg.sh
        ./deploy/all.sh
        restore_webui_title

        echo "Waiting for NATS connection..."
        while ! kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/contextservice -c server 2>&1 | grep -q 'Subscriber is Ready? True'; do sleep 1; done
@@ -94,9 +111,10 @@ case "$HOSTNAME" in
        ;;
    tfs-ip-ctrl)
        echo "Deploying TFS IP Controller..."
        sed -i 's|\(<h2>ETSI TeraFlowSDN Controller\)</h2>|\1 (IP)</h2>|' src/webui/service/templates/main/home.html
        patch_webui_title "IP"
        source ~/tfs-ctrl/src/tests/mwc26-f5ga/deploy-specs-ip.sh
        ./deploy/all.sh
        restore_webui_title

        echo "Waiting for NATS connection..."
        while ! kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/contextservice -c server 2>&1 | grep -q 'Subscriber is Ready? True'; do sleep 1; done