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/certs
34 mkdir -m 755 -p "${WORKSPACE}"/tests/sdnc/sdnc_netconf_tls_post_deploy/cert-data
36 export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
38 if [ "$MTU" == "" ]; then
42 # Export default Networking bridge created on the host machine
43 export LOCAL_IP=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+')
46 echo "Uninstall docker-py and reinstall docker."
47 pip uninstall -y docker-py
48 pip uninstall -y docker
49 pip install -U docker==2.7.0
51 # Reinstall pyOpenSSL library
52 echo "Reinstall pyOpenSSL library."
53 pip uninstall pyopenssl -y
54 pip install pyopenssl==17.5.0
56 # Install PYJKS for .jks files management
59 # Disable Proxy - for local run
60 unset http_proxy https_proxy
62 # Export AAF Certservice config path
63 export AAF_INITIAL_CERTS
64 export EJBCA_CERTPROFILE_PATH
65 export AAF_CERTSERVICE_CONFIG_PATH
66 export AAF_CERTSERVICE_SCRIPTS_PATH
67 export CERT_PROFILE=${EJBCA_CERTPROFILE_PATH}
68 export SCRIPTS_PATH=${AAF_CERTSERVICE_SCRIPTS_PATH}
69 export CONFIGURATION_PATH=${AAF_CERTSERVICE_CONFIG_PATH}
71 # Generate Keystores, Truststores, Certificates and Keys
74 cp "${WORKSPACE}"/plans/sdnc/sdnc_netconf_tls_post_deploy/certs/root.crt "${WORKSPACE}"/tests/sdnc/sdnc_netconf_tls_post_deploy/certs/root.crt
75 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
76 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
78 echo "Generated KeyStores, Server Certificate and Key"
80 # Start EJBCA, AAF-CertService Containers with docker-compose and configuration from docker-compose.yml
81 docker-compose -f "${SCRIPTS}"/sdnc/certservice/docker-compose.yml up -d
83 # Check if AAF-Certservice Service is healthy and ready
86 AAFCERT_IP=$(get-instance-ip.sh aaf-cert-service)
87 RESP_CODE=$(curl -s https://localhost:8443/actuator/health --cacert ./certs/root.crt --cert-type p12 --cert ./certs/certServiceServer-keystore.p12 --pass secret |
88 python2 -c 'import json,sys;obj=json.load(sys.stdin);print obj["status"]')
89 if [[ "${RESP_CODE}" == "UP" ]]; then
90 echo "AAF Cert Service is Ready."
91 export AAFCERT_IP=${AAFCERT_IP}
92 docker exec aafcert-ejbca /opt/primekey/scripts/ejbca-configuration.sh
95 echo "Waiting for AAF Cert Service to Start Up..."
99 if [[ "${AAFCERT_IP}" == "none" || "${AAFCERT_IP}" == '' || "${RESP_CODE}" != "UP" ]]; then
100 echo "AAF CertService not started Could cause problems for testing activities...!"
103 ############################## SDNC Setup ##############################
105 # Export Mariadb, SDNC tmp, cert directory path
106 export SDNC_CERT_PATH=${SDNC_CERT_PATH}
108 docker pull "${NEXUS_DOCKER_REPO}"/onap/sdnc-image:"${SDNC_IMAGE_TAG}"
109 docker tag "${NEXUS_DOCKER_REPO}"/onap/sdnc-image:"${SDNC_IMAGE_TAG}" onap/sdnc-image:latest
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 Could cause problems for testing activities...!"
130 # Check if SDNC-ODL Karaf Session started
132 EXEC_RESP=$(docker exec -it sdnc /opt/opendaylight/current/bin/client system:start-level)
133 if grep -q 'Level 100' <<<"${EXEC_RESP}"; then
134 echo "SDNC-ODL Karaf Session Started."
137 echo "Waiting for SDNC-ODL Karaf Session to Start Up..."
141 if ! grep -q 'Level 100' <<<"${EXEC_RESP}"; then
142 echo "SDNC-ODL Karaf Session not Started, Could cause problems for testing activities...!"
145 echo "Sleeping 5 minutes"
148 ###################### Netconf-PNP-Simulator Setup ######################
150 # Export netconf-pnp simulator conf path
151 export NETCONF_CONFIG_PATH=${NETCONF_CONFIG_PATH}
153 # Start Netconf-Pnp-Simulator Container with docker-compose and configuration from docker-compose.yml
154 docker-compose -f "${SCRIPTS}"/sdnc/netconf-pnp-simulator/docker-compose.yml up -d
156 # Update default Networking bridge IP in mount.json file
157 sed -i "s/pnfaddr/${LOCAL_IP}/g" "${REQUEST_DATA_PATH}"/mount.xml
159 #########################################################################
161 echo "Sleeping additional for 3 minutes to give application time to finish"
164 # Export SDNC, AAF-Certservice-Cient, Netconf-Pnp-Simulator Continer Names
165 export REQUEST_DATA_PATH="${REQUEST_DATA_PATH}"
166 export SDNC_CONTAINER_NAME="${SDNC_CONTAINER_NAME}"
167 export CLIENT_CONTAINER_NAME="${CLIENT_CONTAINER_NAME}"
168 export NETCONF_PNP_SIM_CONTAINER_NAME="${NETCONF_PNP_SIM_CONTAINER_NAME}"
171 ROBOT_VARIABLES+=" -v REPO_IP:${REPO_IP} "
172 ROBOT_VARIABLES+=" -v SCRIPTS:${SCRIPTS} "
174 echo "Finished executing setup for SDNC-Netconf-TLS-Post-Deploy"