3 # ============LICENSE_START=======================================================
4 # Copyright (C) 2020 Nordix Foundation.
5 # ================================================================================
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
18 # SPDX-License-Identifier: Apache-2.0
19 # ============LICENSE_END=========================================================
21 # @author Ajay Deep Singh (ajay.deep.singh@est.tech)
23 # Source SDNC, AAF-CertService, Netconf-Pnp-Simulator config env
24 source "${WORKSPACE}"/plans/sdnc/sdnc_netconf_tls_post_deploy/sdnc-csit.env
26 chmod +x "${WORKSPACE}"/tests/sdnc/sdnc_netconf_tls_post_deploy/libraries/config.sh
27 chmod +x "${WORKSPACE}"/tests/sdnc/sdnc_netconf_tls_post_deploy/libraries/config_tls.sh
29 # Export temp directory
30 export TEMP_DIR_PATH=${TEMP_DIR_PATH}
32 # Create temp directory to bind with docker containers
33 mkdir -m 755 -p "${WORKSPACE}"/tests/sdnc/sdnc_netconf_tls_post_deploy/tmp
34 mkdir -m 755 -p "${WORKSPACE}"/tests/sdnc/sdnc_netconf_tls_post_deploy/certs
35 mkdir -m 755 -p "${WORKSPACE}"/tests/sdnc/sdnc_netconf_tls_post_deploy/cert-data
37 export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
39 if [ "$MTU" == "" ]; then
43 # Export default Networking bridge created on the host machine
44 export LOCAL_IP=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+')
47 echo "Uninstall docker-py and reinstall docker."
48 pip uninstall -y docker-py
49 pip uninstall -y docker
50 pip install -U docker==2.7.0
52 # Reinstall pyOpenSSL library
53 echo "Reinstall pyOpenSSL library."
54 pip uninstall pyopenssl -y
55 pip install pyopenssl==17.5.0
57 # Disable Proxy - for local run
58 unset http_proxy https_proxy
60 # Export AAF Certservice config path
61 export AAF_INITIAL_CERTS
62 export EJBCA_CERTPROFILE_PATH
63 export AAF_CERTSERVICE_CONFIG_PATH
64 export AAF_CERTSERVICE_SCRIPTS_PATH
65 export CERT_PROFILE=${EJBCA_CERTPROFILE_PATH}
66 export SCRIPTS_PATH=${AAF_CERTSERVICE_SCRIPTS_PATH}
67 export CONFIGURATION_PATH=${AAF_CERTSERVICE_CONFIG_PATH}
69 # Generate Keystores, Truststores, Certificates and Keys
72 cp "${WORKSPACE}"/plans/sdnc/sdnc_netconf_tls_post_deploy/certs/root.crt "${WORKSPACE}"/tests/sdnc/sdnc_netconf_tls_post_deploy/certs/root.crt
73 openssl pkcs12 -in "${WORKSPACE}"/plans/sdnc/sdnc_netconf_tls_post_deploy/certs/certServiceServer-keystore.p12 -clcerts -nokeys -password pass:secret | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' >"${WORKSPACE}"/tests/sdnc/sdnc_netconf_tls_post_deploy/certs/certServiceServer.crt
74 openssl pkcs12 -in "${WORKSPACE}"/plans/sdnc/sdnc_netconf_tls_post_deploy/certs/certServiceServer-keystore.p12 -nocerts -nodes -password pass:secret | sed -ne '/-BEGIN PRIVATE KEY-/,/-END PRIVATE KEY-/p' >"${WORKSPACE}"/tests/sdnc/sdnc_netconf_tls_post_deploy/certs/certServiceServer.key
76 echo "Generated KeyStores, Server Certificate and Key"
78 # Start EJBCA, AAF-CertService Containers with docker-compose and configuration from docker-compose.yml
79 docker-compose -f "${SCRIPTS}"/sdnc/certservice/docker-compose.yml up -d
81 # Check if AAF-Certservice Service is healthy and ready
84 AAFCERT_IP=$(get-instance-ip.sh aaf-cert-service)
85 RESP_CODE=$(curl -s https://localhost:8443/actuator/health --cacert ./certs/root.crt --cert-type p12 --cert ./certs/certServiceServer-keystore.p12 --pass secret |
86 python2 -c 'import json,sys;obj=json.load(sys.stdin);print obj["status"]')
87 if [[ "${RESP_CODE}" == "UP" ]]; then
88 echo "AAF Cert Service is Ready."
89 export AAFCERT_IP=${AAFCERT_IP}
90 docker exec aafcert-ejbca /opt/primekey/scripts/ejbca-configuration.sh
93 echo "Waiting for AAF Cert Service to Start Up..."
97 if [[ "${AAFCERT_IP}" == "none" || "${AAFCERT_IP}" == '' || "${RESP_CODE}" != "UP" ]]; then
98 echo "AAF CertService not started Could cause problems for testing activities...!"
101 ############################## SDNC Setup ##############################
103 # Export Mariadb, SDNC tmp, cert directory path
104 export SDNC_CERT_PATH=${SDNC_CERT_PATH}
106 docker pull "${NEXUS_DOCKER_REPO}"/onap/sdnc-image:"${SDNC_IMAGE_TAG}"
107 docker tag "${NEXUS_DOCKER_REPO}"/onap/sdnc-image:"${SDNC_IMAGE_TAG}" onap/sdnc-image:latest
109 # Start Mariadb, SDNC Containers with docker-compose and configuration from docker-compose.yml
110 docker-compose -f "${SCRIPTS}"/sdnc/sdnc/docker-compose.yml up -d
112 # Check if SDNC Service is healthy and ready
114 SDNC_IP=$(get-instance-ip.sh sdnc)
115 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)
116 if [[ "${RESP_CODE}" == '200' ]]; then
117 echo "SDNC Service is Ready."
120 echo "Waiting for SDNC Service to Start Up..."
124 if [[ "${SDNC_IP}" == 'none' || "${SDNC_IP}" == '' || "${RESP_CODE}" != '200' ]]; then
125 echo "SDNC Service not started Could cause problems for testing activities...!"
128 # Check if SDNC-ODL Karaf Session started
130 EXEC_RESP=$(docker exec -it sdnc /opt/opendaylight/current/bin/client system:start-level)
131 if grep -q 'Level 100' <<<"${EXEC_RESP}"; then
132 echo "SDNC-ODL Karaf Session Started."
135 echo "Waiting for SDNC-ODL Karaf Session to Start Up..."
139 if ! grep -q 'Level 100' <<<"${EXEC_RESP}"; then
140 echo "SDNC-ODL Karaf Session not Started, Could cause problems for testing activities...!"
143 echo "Sleeping 5 minutes"
146 ###################### Netconf-PNP-Simulator Setup ######################
148 # Export netconf-pnp simulator conf path
149 export NETCONF_CONFIG_PATH=${NETCONF_CONFIG_PATH}
151 # Start Netconf-Pnp-Simulator Container with docker-compose and configuration from docker-compose.yml
152 docker-compose -f "${SCRIPTS}"/sdnc/netconf-pnp-simulator/docker-compose.yml up -d
154 # Update default Networking bridge IP in mount.json file
155 sed -i "s/pnfaddr/${LOCAL_IP}/g" "${REQUEST_DATA_PATH}"/mount.xml
157 #########################################################################
159 echo "Sleeping additional for 3 minutes to give application time to finish"
162 # Export SDNC, AAF-Certservice-Cient, Netconf-Pnp-Simulator Continer Names
163 export REQUEST_DATA_PATH="${REQUEST_DATA_PATH}"
164 export SDNC_CONTAINER_NAME="${SDNC_CONTAINER_NAME}"
165 export CLIENT_CONTAINER_NAME="${CLIENT_CONTAINER_NAME}"
166 export NETCONF_PNP_SIM_CONTAINER_NAME="${NETCONF_PNP_SIM_CONTAINER_NAME}"
169 ROBOT_VARIABLES+=" -v REPO_IP:${REPO_IP} "
170 ROBOT_VARIABLES+=" -v SCRIPTS:${SCRIPTS} "
172 echo "Finished executing setup for SDNC-Netconf-TLS-Post-Deploy"