Chore: Add gerrit maven verify GHA workflow
[sdnc/oam.git] / csit / plans / sdnc / setup.sh
index ba1c0b8..7c953a3 100644 (file)
 # Modifications copyright (c) 2021 AT&T Intellectual Property
 #
 
-# 
+# Remove all dangling images and cleanup /w/workspace and /tmp
+docker image prune -f
+echo "Remove onap repository artifacts"
+rm -r /tmp/r/org/onap
+echo "Remove all target folders from workspace"
+rm -r $(find /w/workspace -name target)
 
 ###################### Netconf Simulator Setup ######################
 
+echo "Clean"
+sudo apt clean
+
 # Get integration/simulators
 if [ -d ${WORKSPACE}/archives/pnf-simulator ]
 then
@@ -30,15 +38,20 @@ fi
 mkdir ${WORKSPACE}/archives/pnf-simulator
 git clone "https://gerrit.onap.org/r/integration/simulators/pnf-simulator" ${WORKSPACE}/archives/pnf-simulator
 
-# Fix docker-compose to add nexus repo for onap dockers 
+# Fix docker-compose to add nexus repo for onap dockers
+PNF_SIM_REGISTRY=nexus3.onap.org:10001
+PNF_SIM_VERSION=1.0.5
 mv ${WORKSPACE}/archives/pnf-simulator/netconfsimulator/docker-compose.yml ${WORKSPACE}/archives/pnf-simulator/netconfsimulator/docker-compose.yml.orig
-cat ${WORKSPACE}/archives/pnf-simulator/netconfsimulator/docker-compose.yml.orig | sed -e "s/image: onap/image: nexus3.onap.org:10001\/onap/" > ${WORKSPACE}/archives/pnf-simulator/netconfsimulator/docker-compose.yml
+cat ${WORKSPACE}/archives/pnf-simulator/netconfsimulator/docker-compose.yml.orig | sed -re "s/image: onap\/org.onap.integration.simulators.(.*$)/image: $PNF_SIM_REGISTRY\/onap\/org.onap.integration.simulators.\1:$PNF_SIM_VERSION/"  > ${WORKSPACE}/archives/pnf-simulator/netconfsimulator/docker-compose.yml
 
 # Remove carriage returns (if any) from netopeer start script
 mv ${WORKSPACE}/archives/pnf-simulator/netconfsimulator/netconf/initialize_netopeer.sh ${WORKSPACE}/archives/pnf-simulator/netconfsimulator/netconf/initialize_netopeer.sh.orig
 cat ${WORKSPACE}/archives/pnf-simulator/netconfsimulator/netconf/initialize_netopeer.sh.orig | sed -e "s/\r$//g" > ${WORKSPACE}/archives/pnf-simulator/netconfsimulator/netconf/initialize_netopeer.sh
 chmod 755 ${WORKSPACE}/archives/pnf-simulator/netconfsimulator/netconf/initialize_netopeer.sh
 
+# generate fresh certificates for netconfserver [INT-2269]
+
+./generate_certs.sh "${WORKSPACE}"/archives/pnf-simulator/netconfsimulator/tls
 
 # Start Netconf Simulator Container with docker-compose and configuration from docker-compose.yml
 docker-compose -f "${WORKSPACE}"/archives/pnf-simulator/netconfsimulator/docker-compose.yml up -d
@@ -108,10 +121,8 @@ fi
 num_bundles=$(docker exec -i ${SDNC_CONTAINER_NAME} sh -c "echo '' | /opt/opendaylight/current/bin/client bundle:list" | tail -1 | cut -d' ' -f1)
 
   if [ "$num_bundles" -ge 333 ]; then
-    num_bundles=$(docker exec -i ${SDNC_CONTAINER_NAME} sh -c "echo '' | /opt/opendaylight/current/bin/client bundle:list" | tail -1 | cut -d' ' -f1)
-
-    num_failed_bundles=$(docker exec -i ${SDNC_CONTAINER_NAME} sh -c "echo '' | /opt/opendaylight/current/bin/client bundle:list" | grep Failure | wc -l)
-    failed_bundles=$(docker exec -i ${SDNC_CONTAINER_NAME} sh -c "echo '' | /opt/opendaylight/current/bin/client bundle:list" | grep Failure)
+    num_failed_bundles=$(docker exec -i ${SDNC_CONTAINER_NAME} sh -c "echo '' | /opt/opendaylight/current/bin/client bundle:list" | grep -w Failure | wc -l)
+    failed_bundles=$(docker exec -i ${SDNC_CONTAINER_NAME} sh -c "echo '' | /opt/opendaylight/current/bin/client bundle:list" | grep -w Failure)
     echo There is/are $num_failed_bundles failed bundles out of $num_bundles installed bundles.
   fi
 
@@ -148,20 +159,6 @@ cp ${REQUEST_DATA_PATH}/mount.xml.tmpl ${REQUEST_DATA_PATH}/mount.xml
 sed -i "s/pnfaddr/${LOCAL_IP}/g" "${REQUEST_DATA_PATH}"/mount.xml
 
 
-# Load test dgs
-docker exec ${SDNC_CONTAINER_NAME} mkdir -p /tmp/gra.patch
-
-for file in ${WORKSPACE}/plans/sdnc/testdata/*xml
-do
-    docker cp $file ${SDNC_CONTAINER_NAME}:/tmp/gra.patch
-    mname=$(basename $file | cut -d. -f1| cut -d_ -f1)
-    bname=$(basename $file | cut -d. -f1| cut -d_ -f2-)
-    echo ${mname} ${bname} aai-disabled sync >> ${WORKSPACE}/archives/graph.versions
-done
-docker cp ${WORKSPACE}/archives/graph.versions ${SDNC_CONTAINER_NAME}:/tmp/gra.patch
-docker exec ${SDNC_CONTAINER_NAME} /opt/onap/sdnc/svclogic/bin/svclogic.sh install /tmp/gra.patch /opt/onap/sdnc/svclogic/config/svclogic.properties
-
-
 #########################################################################
 
 # Export SDNC, AAF-Certservice-Cient, Netconf-Pnp-Simulator Continer Names