#!/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
# 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."
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."
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"
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:
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: