From 6bdeea2f40de7ce7e4528af96af53b0364f06e3c Mon Sep 17 00:00:00 2001
From: Daniel Caires <daniel.caires@encora.com>
Date: Thu, 25 May 2023 11:46:34 -0300
Subject: [PATCH] Initialize Ceph-Storage

Add a step in lab_setup1 to initialize a
host-based Ceph solution

Test Plan:
PASS: Run STG_LAB_SETUP1 and initilize a
host-based ceph storage on controller0

Story: 2005051
Task: 47936

Change-Id: Iab89ef8be22e4940ae44dab2c8da28407145685d
Signed-off-by: Daniel Caires <daniel.caires@encora.com>
---
 .../pybox/config/labSetupFiles/lab_setup1.sh  | 23 +++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/virtualbox/pybox/config/labSetupFiles/lab_setup1.sh b/virtualbox/pybox/config/labSetupFiles/lab_setup1.sh
index e8a42fc..3b32ae3 100644
--- a/virtualbox/pybox/config/labSetupFiles/lab_setup1.sh
+++ b/virtualbox/pybox/config/labSetupFiles/lab_setup1.sh
@@ -2,10 +2,11 @@
 
 ## This file makes the necessary configuration for the unlock of the Controller-0
 
-GROUPNO=0
 DATE_FORMAT="%Y-%m-%d %T"
-LOG_FILE=${LOG_FILE:-"${HOME}/lab_setup_1.group${GROUPNO}.log"}
+LOG_FILE=${LOG_FILE:-"${HOME}/lab_setup_1.log"}
 VERBOSE_LEVEL=0
+##For now ceph_storage variable will be set to true but can be changed before executing the script
+CEPH_STORAGE="true"
 
 OPENRC=/etc/platform/openrc
 source ${OPENRC}
@@ -62,4 +63,22 @@ function configure_OAM_interface {
 }
 
 
+## Initialize and set ceph_storage
+function initialize_ceph_storage {
+    echo "Setting host-based Ceph storage backend solution"
+
+    #Adding ceph backend
+    log_command "system storage-backend-add ceph --confirmed"
+
+    #Adding OSD on controller-0
+    log_command "system host-disk-list controller-0"
+    log_command "system host-disk-list controller-0 | awk '/\/dev\/sdb/{print \$2}' | xargs -i system host-stor-add controller-0 {}"
+    log_command "system host-stor-list controller-0"
+}
+
+
 configure_OAM_interface
+
+if [ "${CEPH_STORAGE}" == "true" ]; then
+    initialize_ceph_storage
+fi
\ No newline at end of file