SDC schema init improvements 63/143363/4
authorFiete Ostkamp <fiete.ostkamp@telekom.de>
Mon, 23 Feb 2026 10:27:10 +0000 (11:27 +0100)
committerLukasz Rajewski <lukasz.rajewski@t-mobile.pl>
Tue, 24 Feb 2026 11:20:53 +0000 (11:20 +0000)
- reset retry attempts for each normative element group instead of
  globally increasing counter when importing them
- do not fail silently when schema import fails

Issue-ID: SDC-4788
Change-Id: I1382189e8653fd36db83f7cd98171210e31f0167
Signed-off-by: Fiete Ostkamp <fiete.ostkamp@telekom.de>
asdctool/sdc-cassandra-init/scripts/importconformance.sh
catalog-be/sdc-backend-init/custom-scripts/import_normatives.sh
catalog-be/sdc-backend-init/startup.sh
catalog-be/src/main/resources/scripts/sdcBePy/common/normative/main.py

index 23d4039..c0cea65 100644 (file)
@@ -1,20 +1,30 @@
 #!/bin/sh
 
-# Set the working directory
-working_directory="/home/sdc"
+# Accept sdctool base directory as optional first argument,
+# defaulting to /home/sdc/sdctool (the path inside the Docker image).
+sdctool_base="${1:-/home/sdc/sdctool}"
+
+# Extract the cl_release version dynamically from the asdctool jar filename
+# The jar is named asdctool-<version>-jar-with-dependencies.jar
+version=$(ls "$sdctool_base"/asdctool-*-jar-with-dependencies.jar 2>/dev/null \
+    | sed 's|.*/asdctool-||;s|-jar-with-dependencies.jar||' \
+    | head -1)
+
+if [ -z "$version" ]; then
+    echo "ERROR: Could not determine SDC version from asdctool jar in $sdctool_base" >&2
+    exit 1
+fi
 
-# Extract the cl_release version
-version="1.14.5"
 cl_release=$(echo $version | cut -d. -f1-3 | cut -d- -f1)
-echo -e "\033[33mcl_release=[$cl_release]\033[0m"
+printf "\033[33mcl_release=[$cl_release]\033[0m\n"
 
 # Execute the import-Conformance command
-conf_dir="/home/sdc/sdctool/config"
-tosca_dir="/home/sdc/sdctool/tosca"
+conf_dir="$sdctool_base/config"
+tosca_dir="$sdctool_base/tosca"
 cl_version=$(grep 'toscaConformanceLevel:' $conf_dir/configuration.yaml | awk '{print $2}')
 
-cd /home/sdc/sdctool/scripts
+cd "$sdctool_base/scripts"
 chmod +x sdcSchemaFileImport.sh
 
-echo "execute /home/sdc/sdctool/scripts/sdcSchemaFileImport.sh ${tosca_dir} ${cl_release} ${cl_version} ${conf_dir} onap"
+echo "execute $sdctool_base/scripts/sdcSchemaFileImport.sh ${tosca_dir} ${cl_release} ${cl_version} ${conf_dir} onap"
 ./sdcSchemaFileImport.sh ${tosca_dir} ${cl_release} ${cl_version} ${conf_dir} onap
index e21e1b0..12da11d 100644 (file)
@@ -51,7 +51,7 @@ echo "[$start_time] Starting sdcinit..."
 
 # Run sdcinit command with the constructed parameters
 cd /var/tmp/normatives/import/tosca || exit 1
-sdcinit $param $basic_auth_config $tls_cert $tls_key $tls_key_pw $ca_cert > "/home/onap/logs/init.log" 2>&1
+sdcinit $param $basic_auth_config $tls_cert $tls_key $tls_key_pw $ca_cert
 
 end_time=$(date +"%Y-%m-%d %H:%M:%S")
 echo "[$end_time] Done sdcinit."
@@ -61,5 +61,5 @@ end_ts=$(date -d "$end_time" +%s)
 elapsed=$((end_ts - start_ts))
 echo "Elapsed time: $elapsed seconds"
 
-echo "SDC initialization Done. Logs can be found at ${ONAP_LOG}/init.log"
+echo "SDC initialization Done."
 
index e35bab3..42b88f3 100644 (file)
@@ -5,8 +5,11 @@ set -e
 
 log_script() {
     script_name=$1
-    sh "$script_name" 2>&1 | sed "s|^|[$script_name] |" || \
-    echo "$script_name failed. Continuing with other scripts..." >&2
+    echo "Running $script_name..."
+    sh "$script_name" || {
+        echo "$script_name failed." >&2
+        exit 1
+    }
 }
 
 log_script "/home/onap/create_consumer_and_user.sh"
index 805f0b0..d4fc5ad 100644 (file)
@@ -12,10 +12,10 @@ colors = BColors()
 
 
 def process_element_list(normative_elements_list, sdc_be_proxy, model=None):
-    attempt = 0
     for normative_element in normative_elements_list:
         if normative_element is None:
             continue
+        attempt = 0
         while True:
             attempt += 1
             try:
@@ -29,8 +29,8 @@ def process_element_list(normative_elements_list, sdc_be_proxy, model=None):
 
 
 def process_type_list(normative_type_list, sdc_be_proxy, update_version):
-    attempt = 0
     for normative_type in normative_type_list:
+        attempt = 0
         while True:
             attempt += 1
             try: