3 # COPYRIGHT NOTICE STARTS HERE
5 # Copyright 2019 © Samsung Electronics Co., Ltd.
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 # COPYRIGHT NOTICE ENDS HERE
21 ### This script is preparing docker images list based on kubernetes project
23 ### NOTE: helm needs to be installed and working, it is required for correct processing
24 ### of helm charts in oom directory
31 echo " This script is preparing docker images list based on kubernetes project"
33 echo " ./$(basename $0) <path to project> [<output list file>]"
35 echo " Example: ./$(basename $0) /root/oom/kubernetes/onap"
37 echo " Dependencies: helm, python-yaml, make"
48 with open("${1}", 'r') as f:
49 values = yaml.load(f, Loader=yaml.SafeLoader)
50 enabled = filter(lambda x: values[x].get('enabled', False) == True, values)
51 print(' '.join(enabled))
56 if [ -d "${PROJECT_DIR}/../${1}" ]; then
57 SUBSYS_DIR="${PROJECT_DIR}/../${1}"
58 elif [ -d "${PROJECT_DIR}/../common/${1}" ]; then
59 SUBSYS_DIR="${PROJECT_DIR}/../common/${1}"
61 >&2 echo -e \n" !!! ${1} sybsystem does not exist !!!"\n
63 helm template --set global.masterPassword=TemplatePassword -f ${PROJECT_DIR}/values.yaml "${SUBSYS_DIR}" | grep 'image:\ \|tag_version:\ \|h._image' |
64 sed -e 's/^.*\"h._image\"\ :\ //; s/^.*\"\(.*\)\".*$/\1/' \
65 -e 's/\x27\|,//g; s/^.*\(image\|tag_version\):\ //' | tr -d '\r'
69 if [ "${1}" == "-h" ] || [ "${1}" == "--help" ] || [ $# -lt 1 ]; then
75 LISTS_DIR="$(readlink -f $(dirname ${0}))/../data_lists"
76 HELM_REPO="local http://127.0.0.1:8879"
77 PROJECT="$(basename ${1})"
79 if [ ! -f "${PROJECT_DIR}/../Makefile" ]; then
80 echo "Wrong path to project directory entered"
82 elif [ -z "${LIST}" ]; then
84 LIST="${LISTS_DIR}/${PROJECT}_docker_images.list"
86 # $2 is not empty - ensure LIST path exists
87 LIST_DIR="$(dirname ${LIST})"
88 mkdir -p "${LIST_DIR}"
89 MSG="${LIST_DIR} didn't exist, created\n"
92 if [ -e "${LIST}" ]; then
93 mv -f "${LIST}" "${LIST}.bk"
94 MSG="$(realpath ${LIST}) already existed\nCreated backup $(realpath ${LIST}).bk\n"
98 if ps -eaf | grep -v "grep" | grep "helm" > /dev/null; then
99 echo "helm is already running"
101 helm init -c > /dev/null
103 helm repo remove stable 2>/dev/null || true
106 # Create helm repository
107 if ! helm repo list 2>&1 | awk '{ print $1, $2 }' | grep -q "$HELM_REPO" > /dev/null; then
108 helm repo add $HELM_REPO
112 pushd "${PROJECT_DIR}/.."
113 echo "Building project..."
114 make all > /dev/null; make ${PROJECT} > /dev/null
117 # Create the list from all enabled subsystems
118 echo "Creating the list..."
119 if [ "${PROJECT}" == "onap" ]; then
120 COMMENT="OOM commit $(git --git-dir="${PROJECT_DIR}/../../.git" rev-parse HEAD)"
121 for subsystem in `parse_yaml "${PROJECT_DIR}/resources/overrides/onap-all.yaml"`; do
122 create_list ${subsystem}
123 done | sort -u > ${LIST}
126 create_list ${PROJECT} | sort -u > ${LIST}
129 # Add comment reffering to the project
130 sed -i "1i# generated from ${COMMENT}" "${LIST}"
133 echo -e 'The list has been created:\n '"${LIST}"