3 # Copyright 2019 Samsung Electronics Co., Ltd.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
18 # Gather information on ONAP cluster required by security tests.
19 # Copy results to Robot pod.
24 TMPTPL='onap_security'
25 CSV2JSON='import csv; import json; import sys; print(json.dumps({i[0]: i[1] for i in csv.reader(sys.stdin)}))'
26 FILTER="$(tr -d [:space:] <<TEMPLATE
30 {{.nodePort}}{{','}}{{.name}}{{'\n'}}
38 export NODEPORTS_FILE="$(mktemp -p ${TMPDIR} ${TMPTPL}XXX)"
41 create_actual_nodeport_json () {
42 kubectl get svc -n $NAMESPACE -o go-template="$FILTER" | python3 -c "$CSV2JSON" > "$NODEPORTS_FILE"
45 copy_actual_nodeport_json_to_robot () {
46 kubectl cp "$1" "$2/$3:$4"
55 create_actual_nodeport_json
56 copy_actual_nodeport_json_to_robot "$NODEPORTS_FILE" "$NAMESPACE" "$POD" "$TMPDIR"