From 5377075da4798b96b470a2f218bb0a7e55e2ee33 Mon Sep 17 00:00:00 2001
From: gifrerenom <lluis.gifre@cttc.es>
Date: Mon, 8 Apr 2024 16:36:02 +0000
Subject: [PATCH] GitLab CI/CD pipeline - OFC'24:

- Correct order of TFS components being deployed when optical controller is activated
---
 src/tests/ofc24/deploy_specs.sh | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/tests/ofc24/deploy_specs.sh b/src/tests/ofc24/deploy_specs.sh
index e7458dc9d..4ade75923 100755
--- a/src/tests/ofc24/deploy_specs.sh
+++ b/src/tests/ofc24/deploy_specs.sh
@@ -30,7 +30,14 @@ export TFS_COMPONENTS="context device pathcomp service slice nbi webui"
 #export TFS_COMPONENTS="${TFS_COMPONENTS} bgpls_speaker"
 
 # Uncomment to activate Optical Controller
-export TFS_COMPONENTS="${TFS_COMPONENTS} opticalcontroller"
+# To manage optical connections, "service" requires "opticalcontroller" to be deployed
+# before "service", thus we "hack" the TFS_COMPONENTS environment variable prepending the
+# "opticalcontroller" only if "service" is already in TFS_COMPONENTS, and re-export it.
+if [[ "$TFS_COMPONENTS" == *"service"* ]]; then
+    BEFORE="${TFS_COMPONENTS% service*}"
+    AFTER="${TFS_COMPONENTS#* service}"
+    export TFS_COMPONENTS="${BEFORE} opticalcontroller service ${AFTER}"
+fi
 
 # Uncomment to activate ZTP
 #export TFS_COMPONENTS="${TFS_COMPONENTS} ztp"
-- 
GitLab