Skip to content
Snippets Groups Projects
Commit 158cb89f authored by Raphael Defosseux's avatar Raphael Defosseux
Browse files

chore(ci): clean-up on building properly the common source files

parent 829dee31
No related branches found
No related tags found
1 merge request!24chore(ci): clean-up on building properly the common source files
[submodule "src/oai-cn5g-common-src"]
path = src/oai-cn5g-common-src
url = https://gitlab.eurecom.fr/oai/cn5g/oai-cn5g-common-src.git
[submodule "build/build-common"]
path = build/build-common
url = https://gitlab.eurecom.fr/oai/cn5g/oai-cn5g-common-build.git
[submodule "ci-scripts/common-ci"]
path = ci-scripts/common-ci
url = https://gitlab.eurecom.fr/oai/cn5g/oai-cn5g-common-ci.git
Subproject commit 7ef996a4873ce487fb36da11325ae028974cc0df
......@@ -33,9 +33,8 @@ endif()
set (BUILD_TOP_DIR ${OPENAIRCN_DIR}/build)
set (SRC_TOP_DIR ${OPENAIRCN_DIR}/src)
set (NF_TARGET_LIB PCF)
set (NF_TARGET pcf)
set (NF_TARGET_API_LIB PCF_API)
set (MOUNTED_COMMON oai-cn5g-common-src)
project (OpenAirInterface)
......
......@@ -29,7 +29,7 @@
################################
SCRIPT=$(readlink -f ${BASH_SOURCE})
THIS_SCRIPT_PATH=`dirname $SCRIPT`
source $THIS_SCRIPT_PATH/../../src/oai-cn5g-common-src/scripts/build_helper
source $THIS_SCRIPT_PATH/../build-common/installation/build_helper
#-------------------------------------------------------------------------------
#arg1 is force (0 or 1) (no interactive script)
......
Subproject commit c458e9dd6a5cbce1306680d4289012b8f493ff85
......@@ -68,6 +68,10 @@ RUN ldconfig && \
./build_pcf --clean --Verbose --build-type Release --jobs && \
ldd /openair-pcf/build/pcf/build/pcf && \
mv /openair-pcf/build/pcf/build/pcf /openair-pcf/build/pcf/build/oai_pcf && \
# Adapting the entrypoint to PCF NF
sed -i -e "s@openair-nf-root-folder@openair-pcf@g" \
-e "s@nf-config-file@pcf.yaml@g" \
../build-common/docker-scripts/entrypoint.py && \
# Remove entitlements and Subscription Manager configs
rm -rf /etc/pki/entitlement && \
rm -rf /etc/rhsm
......@@ -112,7 +116,7 @@ RUN rm -f /etc/rhsm-host && \
WORKDIR /openair-pcf/bin
COPY --from=oai-pcf-builder \
/openair-pcf/build/pcf/build/oai_pcf \
/openair-pcf/scripts/entrypoint.py \
/openair-pcf/build/build-common/docker-scripts/entrypoint.py \
/openair-pcf/scripts/healthcheck.sh \
./
......
......@@ -51,9 +51,9 @@ RUN git config --global https.postBuffer 123289600 && \
# Copying source code
WORKDIR /openair-pcf
COPY ./build/scripts /openair-pcf/build/scripts/
COPY ./build/build-common /openair-pcf/build/build-common/
COPY ./build/pcf/CMakeLists.txt /openair-pcf/build/pcf/CMakeLists.txt
COPY ./build/cmake_modules /openair-pcf/build/cmake_modules/
COPY ./src/oai-cn5g-common-src/scripts/build_helper /openair-pcf/src/oai-cn5g-common-src/scripts/
# Installing all the needed libraries/packages to build and run PCF
WORKDIR /openair-pcf/build/scripts
......@@ -67,9 +67,14 @@ FROM oai-pcf-base as oai-pcf-builder
# Copying source code
COPY . /openair-pcf
# Building PCF
WORKDIR /openair-pcf/build/scripts
RUN ./build_pcf --clean --Verbose --build-type Release --jobs && \
ldd /openair-pcf/build/pcf/build/pcf && \
mv /openair-pcf/build/pcf/build/pcf /openair-pcf/build/pcf/build/oai_pcf
mv /openair-pcf/build/pcf/build/pcf /openair-pcf/build/pcf/build/oai_pcf && \
# Adapting the entrypoint to PCF NF
sed -i -e "s@openair-nf-root-folder@openair-pcf@g" \
-e "s@nf-config-file@pcf.yaml@g" \
../build-common/docker-scripts/entrypoint.py
#---------------------------------------------------------------------
# TARGET IMAGE
......@@ -111,7 +116,7 @@ RUN apt-get update && \
WORKDIR /openair-pcf/bin
COPY --from=oai-pcf-builder \
/openair-pcf/build/pcf/build/oai_pcf \
/openair-pcf/scripts/entrypoint.py \
/openair-pcf/build/build-common/docker-scripts/entrypoint.py \
/openair-pcf/scripts/healthcheck.sh \
./
......
#!/usr/bin/env python3
################################################################################
# Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The OpenAirInterface Software Alliance licenses this file to You under
# the OAI Public License, Version 1.1 (the "License"); you may not use this file
# except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.openairinterface.org/?page_id=698
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#-------------------------------------------------------------------------------
# For more information about the OpenAirInterface (OAI) Software Alliance:
# contact@openairinterface.org
################################################################################
from jinja2 import Environment, FileSystemLoader
import socket
import os
import sys
CONFIG_FILE = str(os.getenv('CONFIG_FILE','/openair-pcf/etc/pcf.yaml'))
MOUNT_CONFIG = str(os.getenv('MOUNT_CONFIG','no')).lower()
def resolve(hostname):
try:
return socket.gethostbyname(hostname)
except socket.error:
print(f"Not able to resolve {hostname}")
def render(filepath,funcs,values):
env = Environment(loader=FileSystemLoader(os.path.dirname(filepath)))
jinja_template = env.get_template(os.path.basename(filepath))
jinja_template.globals.update(funcs)
template_string = jinja_template.render(env=values)
return template_string
env_variables = dict()
#list of all the environment variables
for name, value in os.environ.items():
env_variables.update({name:value})
if MOUNT_CONFIG != "yes":
output = render(CONFIG_FILE,{"resolve":resolve},env_variables)
with open(CONFIG_FILE, "w") as fh:
fh.write(output)
print(f"Configuration file {CONFIG_FILE} is ready")
if len(sys.argv) == 1:
sys.exit(0)
os.execvp(sys.argv[1], sys.argv[1:]) #important for running the network function it works like exec $@
else:
print("Configuration file is mounted to the network function")
#!/bin/bash
set -euo pipefail
CONFIG_DIR="/openair-pcf/etc"
#Default values
POLICY_BASE_DIR=${POLICY_BASE_DIR:-"/openair-pcf/policy"}
TRAFFIC_RULES_DIR=${TRAFFIC_RULES_DIR:-"traffic_rules"}
PCC_RULES_DIR=${PCC_RULES_DIR:-"pcc_rules"}
POLICY_BASE_DIR=${POLICY_DECISIONS_DIR:-"policy_decisions"}
for c in ${CONFIG_DIR}/*.conf; do
# grep variable names (format: ${VAR}) from template to be rendered
if ! grep -oP '@[a-zA-Z0-9_]+@' ${c}; then
echo "Configuration is already set"
exec "$@"
fi
VARS=$(grep -oP '@[a-zA-Z0-9_]+@' ${c} | sort | uniq | xargs)
echo "Now setting these variables '${VARS}'"
# create sed expressions for substituting each occurrence of ${VAR}
# with the value of the environment variable "VAR"
EXPRESSIONS=""
for v in ${VARS}; do
NEW_VAR=`echo $v | sed -e "s#@##g"`
if [[ -z ${!NEW_VAR+x} ]]; then
echo "Error: Environment variable '${NEW_VAR}' is not set." \
"Config file '$(basename $c)' requires all of $VARS."
exit 1
fi
EXPRESSIONS="${EXPRESSIONS};s|${v}|${!NEW_VAR}|g"
done
EXPRESSIONS="${EXPRESSIONS#';'}"
# render template and inline replace config file
sed -i "${EXPRESSIONS}" ${c}
done
echo "Done setting the configuration"
exec "$@"
......@@ -28,6 +28,8 @@ include_directories(${PCF_API_SERVER_DIR}/)
include_directories(${SRC_TOP_DIR}/pcf_app)
include_directories(${SRC_TOP_DIR}/common)
include_directories(${SRC_TOP_DIR}/common/utils)
include_directories(${SRC_TOP_DIR}/${MOUNTED_COMMON}/logger)
include_directories(${SRC_TOP_DIR}/${MOUNTED_COMMON}/config)
file(GLOB PCF_API_SERVER_src_files
${PCF_API_SERVER_DIR}/pcf-api-server.cpp
......@@ -38,4 +40,4 @@ file(GLOB PCF_API_SERVER_src_files
)
add_library(PCF_API STATIC
${PCF_API_SERVER_src_files})
\ No newline at end of file
${PCF_API_SERVER_src_files})
......@@ -30,22 +30,3 @@ target_sources(${NF_TARGET} PRIVATE
${UTILS_DIR}/fqdn.cpp
${UTILS_DIR}/if.cpp
)
## Logger used in NF_TARGET_LIB ("app" library)
target_include_directories(${NF_TARGET_LIB} PUBLIC ${LOGGER_DIR})
target_sources(${NF_TARGET_LIB} PRIVATE
${UTILS_DIR}/conversions.cpp
${UTILS_DIR}/string.cpp
${UTILS_DIR}/fqdn.cpp
${UTILS_DIR}/if.cpp
)
## UTILS used in NF_TARGET_API (API library
target_include_directories(${NF_TARGET_API_LIB} PUBLIC ${LOGGER_DIR})
target_sources(${NF_TARGET_API_LIB} PRIVATE
${UTILS_DIR}/conversions.cpp
${UTILS_DIR}/string.cpp
${UTILS_DIR}/fqdn.cpp
${UTILS_DIR}/if.cpp
)
Subproject commit af4dfeb0b0da43016ce07ceec51596d967ab3351
Subproject commit db83907f0edcfcb4a9b189decedfd00fa01f98aa
......@@ -283,8 +283,10 @@ add_executable(pcf
${SRC_TOP_DIR}/oai_pcf/main.cpp
)
## Common modules
include(${BUILD_TOP_DIR}/pcf/used_common_files.cmake)
include(${SRC_TOP_DIR}/oai-cn5g-common-src/config/config.cmake)
include(${SRC_TOP_DIR}/${MOUNTED_COMMON}/logger/logger.cmake)
include(${SRC_TOP_DIR}/${MOUNTED_COMMON}/config/config.cmake)
IF(STATIC_LINKING)
SET(CMAKE_EXE_LINKER_FLAGS "-static")
......
......@@ -28,6 +28,8 @@ include_directories(${SRC_TOP_DIR}/api-server/impl)
include_directories(${SRC_TOP_DIR}/api-server/model)
include_directories(${SRC_TOP_DIR}/api-server/)
include_directories(${SRC_TOP_DIR}/pcf_app/sm_policy/)
include_directories(${SRC_TOP_DIR}/${MOUNTED_COMMON}/logger)
include_directories(${SRC_TOP_DIR}/${MOUNTED_COMMON}/config)
add_library (PCF STATIC
pcf_app.cpp
......@@ -48,8 +50,6 @@ add_library (PCF STATIC
)
## Common modules
include(${SRC_TOP_DIR}/oai-cn5g-common-src/logger/logger.cmake)
include(${SRC_TOP_DIR}/oai-cn5g-common-src/config/config.cmake)
include(${SRC_TOP_DIR}/common/utils/utils.cmake)
include(${BUILD_TOP_DIR}/pcf/used_common_files.cmake)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment