4 # ============LICENSE_START=======================================================
5 # Copyright (C) 2020 Nordix Foundation.
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.
18 # SPDX-License-Identifier: Apache-2.0
19 # ============LICENSE_END=========================================================
21 # @author Ajay Deep Singh (ajay.deep.singh@est.tech)
24 LOGFILE="${WORKSPACE}"/archives/config.log
25 CONTAINER_ID=$(docker inspect --format="{{.Id}}" "$CONTAINER_NAME")
30 CERT_DIR="${WORKSPACE}"/tests/sdnc/sdnc_netconf_tls_post_deploy/cert-data/*
33 date +"%Y-%m-%d %H:%M:%S.%3N"
40 printf "%s %-5s %s\n" "$(now_ms)" "$level" "$message" >>"$LOGFILE"
43 # Copy [keystore.jks, truststore.jks, truststore.pass, keystore.pass] files into SDNC container.
44 function docker_cp() {
46 docker cp "$file" "$CONTAINER_ID":"$DEST_DIR"
47 docker exec -u 0 "$CONTAINER_ID" chown "$OWNER":"$OWNER" "$DEST_DIR"/"${file##*/}"
50 # Run installCerts.py script to push X509 Certificates to SDNC-ODL Keystore/Truststore.
51 function sdnc_conf() {
52 log INFO "Configuring SDNC-ODL Keystore..."
56 for file in $CERT_DIR; do
57 if [[ -f $file ]]; then
58 log INFO "Uploading file :" "$file"
63 if [[ $count -eq 4 ]]; then
64 log INFO "SDNC JKS files upload successful"
68 log DEBUG "Waiting for JKS files to be uploaded to SDNC container.."
71 if [[ "$exit_code" != "true" ]]; then
72 log DEBUG "JKS files Not found in $CERT_DIR"
73 exit 1 # Return error code
76 docker exec "$CONTAINER_ID" rm -rf /tmp/certs.properties
77 docker exec "$CONTAINER_ID" rm -rf /tmp/keys0.zip
78 if ! docker exec "$CONTAINER_ID" /usr/bin/python /opt/onap/sdnc/bin/installCerts.py; then
79 log DEBUG "Issue executing installCerts.py script"
80 docker cp "$CONTAINER_ID":/opt/opendaylight/data/log/installCerts.log "${WORKSPACE}"/archives
81 exit 1 # Return error code
83 log INFO "Configuring SDNC-ODL Keystore successful"
86 # Copy [Server_key.pem, Server_cert.pem, Ca.pem] files into Netconf-Simulator container.
87 # Reconfigure TLS config by invoking reconfigure-tls.sh script.
88 function netconf-simulator_conf() {
89 log INFO "Configuring Netconf-Pnp-Simulator..."
93 for file in $CERT_DIR; do
94 if [[ -f $file && ${file: -4} == ".pem" ]]; then
95 log INFO "Uploading file :" "$file"
96 docker cp "$file" "$CONTAINER_ID":/config/tls
100 if [[ $count -eq 3 ]]; then
101 log INFO "PEM files upload successful"
105 log DEBUG "Waiting for PEM files to be uploaded to Netconf-Pnp-Simulator.."
108 if [[ "$exit_code" != "true" ]]; then
109 log DEBUG "PEM files Not found in $CERT_DIR"
110 exit 1 # Return error code
113 if ! docker exec "$CONTAINER_ID" /opt/bin/reconfigure-tls.sh; then
114 log DEBUG "Issue executing reconfigure-tls.sh script"
115 docker logs "$CONTAINER_ID" > "${WORKSPACE}"/archives/simulator.log
116 exit 1 # Return error code
118 log INFO "Configuring Netconf-Pnp-Simulator successful"
121 # Push Config on SDNC, Netconf-Simulator.
122 if [[ -n $CONTAINER_ID ]]; then
123 log INFO "Container Name: $CONTAINER_NAME, Container Id: $CONTAINER_ID"
124 if [[ "$CONTAINER_NAME" == "sdnc" ]]; then
126 elif [[ "$CONTAINER_NAME" == "netconf-simulator" ]]; then
127 netconf-simulator_conf