3 # ============LICENSE_START=======================================================
4 # Copyright (C) 2020 Nordix Foundation.
5 # Modification copyright (C) 2021 Samsung Electronics, Co., Ltd.
6 # ================================================================================
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
19 # SPDX-License-Identifier: Apache-2.0
20 # ============LICENSE_END=========================================================
22 # @author Ajay Deep Singh (ajay.deep.singh@est.tech)
24 # Source SDNC, AAF-CertService, Netconf-Pnp-Simulator config env
25 source "${WORKSPACE}"/plans/sdnc/sdnc_netconf_tls_post_deploy/sdnc-csit.env
27 chmod +x "${WORKSPACE}"/tests/sdnc/sdnc_netconf_tls_post_deploy/libraries/config.sh
28 chmod +x "${WORKSPACE}"/tests/sdnc/sdnc_netconf_tls_post_deploy/libraries/config_tls.sh
30 # Export temp directory
31 export TEMP_DIR_PATH=${TEMP_DIR_PATH}
34 export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
36 if [ "$MTU" == "" ]; then
40 # Export default Networking bridge created on the host machine
41 export LOCAL_IP=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+')
44 echo "Uninstall docker-py and reinstall docker."
45 pip uninstall -y docker-py
46 pip uninstall -y docker
47 pip install -U docker==2.7.0
49 # Reinstall pyOpenSSL library
50 echo "Reinstall pyOpenSSL library."
51 pip uninstall pyopenssl -y
52 pip install pyopenssl==17.5.0
54 # Install PYJKS for .jks files management
57 # Disable Proxy - for local run
58 unset http_proxy https_proxy
60 ###################### Netconf Simulator Setup ######################
62 # Get integration/simulators
63 if [ -d ${SCRIPTS}/sdnc/pnf-simulator ]
65 rm -rf ${SCRIPTS}/sdnc/pnf-simulator
67 mkdir ${SCRIPTS}/sdnc/pnf-simulator
68 git clone "https://gerrit.onap.org/r/integration/simulators/pnf-simulator" ${SCRIPTS}/sdnc/pnf-simulator
70 # Fix docker-compose to add nexus repo for onap dockers
71 mv ${SCRIPTS}/sdnc/pnf-simulator/netconfsimulator/docker-compose.yml ${SCRIPTS}/sdnc/pnf-simulator/netconfsimulator/docker-compose.yml.orig
72 cat ${SCRIPTS}/sdnc/pnf-simulator/netconfsimulator/docker-compose.yml.orig | sed -e "s/image: onap/image: nexus3.onap.org:10001\/onap/" > ${SCRIPTS}/sdnc/pnf-simulator/netconfsimulator/docker-compose.yml
74 # Remove carriage returns (if any) from netopeer start script
75 mv ${SCRIPTS}/sdnc/pnf-simulator/netconfsimulator/netconf/initialize_netopeer.sh ${SCRIPTS}/sdnc/pnf-simulator/netconfsimulator/netconf/initialize_netopeer.sh.orig
76 cat ${SCRIPTS}/sdnc/pnf-simulator/netconfsimulator/netconf/initialize_netopeer.sh.orig | sed -e "s/\r$//g" > ${SCRIPTS}/sdnc/pnf-simulator/netconfsimulator/netconf/initialize_netopeer.sh
77 chmod 755 ${SCRIPTS}/sdnc/pnf-simulator/netconfsimulator/netconf/initialize_netopeer.sh
80 # Start Netconf Simulator Container with docker-compose and configuration from docker-compose.yml
81 docker-compose -f "${SCRIPTS}"/sdnc/pnf-simulator/netconfsimulator/docker-compose.yml up -d
83 # Add test user in netopeer container
85 docker exec netconfsimulator_netopeer_1 useradd --system test
88 ############################## SDNC Setup ##############################
90 # Copy client certs from netconf simulator to SDNC certs directory
92 cp ${SCRIPTS}/sdnc/pnf-simulator/netconfsimulator/tls/client.crt /tmp/keys0
93 cp ${SCRIPTS}/sdnc/pnf-simulator/netconfsimulator/tls/client.key /tmp/keys0
94 cp ${SCRIPTS}/sdnc/pnf-simulator/netconfsimulator/tls/ca.crt /tmp/keys0/trustedCertificates.crt
97 zip -r $SDNC_CERT_PATH/keys0.zip keys0
100 # Export Mariadb, SDNC tmp, cert directory path
101 export SDNC_CERT_PATH=${SDNC_CERT_PATH}
103 docker pull "${NEXUS_DOCKER_REPO}"/onap/sdnc-image:"${SDNC_IMAGE_TAG}"
104 docker tag "${NEXUS_DOCKER_REPO}"/onap/sdnc-image:"${SDNC_IMAGE_TAG}" onap/sdnc-image:latest
106 # Fix permissions on certs directory to guarantee directory is read/
107 # writable and that files are readable
108 chmod ugo+rwx ${SCRIPTS}/sdnc/sdnc/certs
109 chmod ugo+r ${SCRIPTS}/sdnc/sdnc/certs/*
111 # Start Mariadb, SDNC Containers with docker-compose and configuration from docker-compose.yml
112 docker-compose -f "${SCRIPTS}"/sdnc/sdnc/docker-compose.yml up -d
114 # Check if SDNC Service is healthy and ready
116 SDNC_IP=$(get-instance-ip.sh sdnc)
117 RESP_CODE=$(curl --write-out '%{http_code}' --silent --output /dev/null -H "Authorization: Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==" -X POST -H "X-FromAppId: csit-sdnc" -H "X-TransactionId: csit-sdnc" -H "Accept: application/json" -H "Content-Type: application/json" http://localhost:8282/restconf/operations/SLI-API:healthcheck)
118 if [[ "${RESP_CODE}" == '200' ]]; then
119 echo "SDNC Service is Ready."
122 echo "Waiting for SDNC Service to Start Up..."
126 if [[ "${SDNC_IP}" == 'none' || "${SDNC_IP}" == '' || "${RESP_CODE}" != '200' ]]; then
127 echo "SDNC Service not started, setup failed"
131 # Check if SDNC-ODL Karaf Session started
135 while [ "$TIME" -lt "$TIME_OUT" ]; do
137 docker exec sdnc cat /opt/opendaylight/data/log/karaf.log | grep 'warp coils'
139 if [ $? == 0 ] ; then
140 echo SDNC karaf started in $TIME seconds
144 echo Sleep: $INTERVAL seconds before testing if SDNC is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
146 TIME=$(($TIME+$INTERVAL))
149 if [ "$TIME" -ge "$TIME_OUT" ]; then
150 echo TIME OUT: karaf session not started in $TIME_OUT seconds, setup failed
154 # Check if certificate installation is done
158 while [ "$TIME" -lt "$TIME_OUT" ]; do
160 docker-compose -f "${SCRIPTS}"/sdnc/sdnc/docker-compose.yml logs sdnc | grep 'Everything OK in Certificate Installation'
162 if [ $? == 0 ] ; then
163 echo SDNC karaf started in $TIME seconds
167 echo Sleep: $INTERVAL seconds before testing if SDNC is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
169 TIME=$(($TIME+$INTERVAL))
172 if [ "$TIME" -ge "$TIME_OUT" ]; then
173 echo TIME OUT: karaf session not started in $TIME_OUT seconds, setup failed
177 # Update default Networking bridge IP in mount.json file
178 sed -i "s/pnfaddr/${LOCAL_IP}/g" "${REQUEST_DATA_PATH}"/mount.xml
180 #########################################################################
182 # Export SDNC, AAF-Certservice-Cient, Netconf-Pnp-Simulator Continer Names
183 export REQUEST_DATA_PATH="${REQUEST_DATA_PATH}"
184 export SDNC_CONTAINER_NAME="${SDNC_CONTAINER_NAME}"
185 export CLIENT_CONTAINER_NAME="${CLIENT_CONTAINER_NAME}"
186 export NETCONF_PNP_SIM_CONTAINER_NAME="${NETCONF_PNP_SIM_CONTAINER_NAME}"
189 ROBOT_VARIABLES+=" -v REPO_IP:${REPO_IP} "
190 ROBOT_VARIABLES+=" -v SCRIPTS:${SCRIPTS} "
192 echo "Finished executing setup for SDNC-Netconf-TLS-Post-Deploy"