Commit 26489b0b authored by Raphael Defosseux's avatar Raphael Defosseux

CI: first draft of standalone SPGW-U CI

  - Dockerfile to build image
  - script to generate configuration
Signed-off-by: default avatarRaphael Defosseux <raphael.defosseux@openairinterface.org>
parent c497e7f6
#/*
# * 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
# */
#---------------------------------------------------------------------
#
# Dockerfile for the Open-Air-Interface SPGW-U-TINY service
# Valid for Ubuntu-18.04 (bionic)
#
#---------------------------------------------------------------------
#---------------------------------------------------------------------
# BUILDER IMAGE
#---------------------------------------------------------------------
FROM ubuntu:bionic as oai-spgwu-tiny-builder
ARG EURECOM_PROXY
ARG BUILD_FOR_CI
ARG CI_SRC_BRANCH
ARG CI_SRC_COMMIT
ARG CI_DEST_BRANCH
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes
RUN DEBIAN_FRONTEND=noninteractive apt-get install --yes \
psmisc \
git \
&& rm -rf /var/lib/apt/lists/*
# Some GIT configuration command quite useful
RUN /bin/bash -c "if [[ -v EURECOM_PROXY ]]; then git config --global http.proxy $EURECOM_PROXY; fi"
RUN git config --global https.postBuffer 123289600
RUN git config --global http.sslverify false
# In normal case, we build out of the develop branch
RUN /bin/bash -c "if [[ -v CI_SRC_BRANCH ]]; then git clone https://github.com/OPENAIRINTERFACE/openair-spgwu-tiny.git -b $CI_SRC_BRANCH /openair-spgwu-tiny; else git clone https://github.com/OPENAIRINTERFACE/openair-spgwu-tiny.git -b develop /openair-spgwu-tiny; fi"
# For CI, especially for Pull/Merge Requests, we build out of temp merge
WORKDIR /openair-spgwu-tiny
RUN /bin/bash -c "if [[ -v BUILD_FOR_CI ]]; then git config --global user.name \"OAI CI\"; fi"
RUN /bin/bash -c "if [[ -v BUILD_FOR_CI ]]; then git config --global user.email ci@openairinterface.org; fi"
RUN /bin/bash -c "if [[ -v BUILD_FOR_CI ]]; then git checkout -f $CI_SRC_COMMIT; fi"
RUN /bin/bash -c "if [[ -v BUILD_FOR_CI ]]; then git merge --ff origin/$CI_DEST_BRANCH -m \"Temporary merge for CI\"; fi"
# Installing and Building SPGW-U-TINY
WORKDIR /openair-spgwu-tiny/build/scripts
RUN ./build_spgwu --install-deps --force
RUN ./build_spgwu --clean --build-type Release --jobs
RUN cat /openair-spgwu-tiny/build/log/spgwu.txt
#---------------------------------------------------------------------
# TARGET IMAGE
#---------------------------------------------------------------------
FROM ubuntu:bionic as oai-spgwu-tiny
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes
# We install some debug tools for the moment in addition of mandatory libraries
RUN DEBIAN_FRONTEND=noninteractive apt-get install --yes \
psmisc \
net-tools \
iproute2 \
tshark \
libgoogle-glog0v5 \
libdouble-conversion1 \
libconfig++9v5 \
libboost-system1.65.1 \
&& rm -rf /var/lib/apt/lists/*
# Copying executable and generated libraries
WORKDIR /openair-spgwu-tiny/bin
COPY --from=oai-spgwu-tiny-builder /openair-spgwu-tiny/build/spgw_u/build/spgwu oai_spgwu
# Copying template configuration files
# The configuration folder will be flat
WORKDIR /openair-spgwu-tiny/etc
COPY --from=oai-spgwu-tiny-builder /openair-spgwu-tiny/etc/spgw_u.conf .
WORKDIR /openair-spgwu-tiny
......@@ -24,72 +24,51 @@ import os
import re
import sys
def GenerateSpgwcConfigurer(s11c_name, sxc_name):
spgwcFile = open('./spgwc-cfg.sh', 'w')
spgwcFile.write('#!/bin/bash\n')
spgwcFile.write('\n')
spgwcFile.write('cd /home\n')
spgwcFile.write('\n')
spgwcFile.write('ifconfig lo:s5c 127.0.0.15 up\n')
spgwcFile.write('echo "ifconfig lo:s5c 127.0.0.15 up --> OK"\n')
spgwcFile.write('ifconfig lo:p5c 127.0.0.16 up\n')
spgwcFile.write('echo "ifconfig lo:p5c 127.0.0.16 up --> OK"\n')
spgwcFile.write('\n')
spgwcFile.write('INSTANCE=1\n')
spgwcFile.write('PREFIX=\'/usr/local/etc/oai\'\n')
spgwcFile.write('\n')
spgwcFile.write('MY_APN=\'apn.oai.svc.cluster.local\'\n')
spgwcFile.write('MY_PRIMARY_DNS=\'192.168.18.129\'\n')
spgwcFile.write('MY_SECONDARY_DNS=\'8.8.4.4\'\n')
spgwcFile.write('\n')
spgwcFile.write('mkdir -p $PREFIX\n')
spgwcFile.write('cp etc/spgw_c.conf $PREFIX\n')
spgwcFile.write('\n')
spgwcFile.write('declare -A SPGWC_CONF\n')
spgwcFile.write('\n')
spgwcFile.write('SPGWC_CONF[@INSTANCE@]=$INSTANCE\n')
spgwcFile.write('SPGWC_CONF[@PID_DIRECTORY@]=\'/var/run\'\n')
spgwcFile.write('SPGWC_CONF[@SGW_INTERFACE_NAME_FOR_S11@]=\'' + s11c_name + '\'\n')
spgwcFile.write('SPGWC_CONF[@SGW_INTERFACE_NAME_FOR_S5_S8_CP@]=\'lo:s5c\'\n')
spgwcFile.write('SPGWC_CONF[@PGW_INTERFACE_NAME_FOR_S5_S8_CP@]=\'lo:p5c\'\n')
spgwcFile.write('SPGWC_CONF[@PGW_INTERFACE_NAME_FOR_SX@]=\'' + sxc_name + '\'\n')
spgwcFile.write('SPGWC_CONF[@DEFAULT_DNS_IPV4_ADDRESS@]=$MY_PRIMARY_DNS\n')
spgwcFile.write('SPGWC_CONF[@DEFAULT_DNS_SEC_IPV4_ADDRESS@]=$MY_SECONDARY_DNS\n')
spgwcFile.write('SPGWC_CONF[@DEFAULT_APN@]=$MY_APN\n')
spgwcFile.write('\n')
spgwcFile.write('for K in "${!SPGWC_CONF[@]}"; do \n')
spgwcFile.write(' egrep -lRZ "$K" $PREFIX | xargs -0 -l sed -i -e "s|$K|${SPGWC_CONF[$K]}|g"\n')
spgwcFile.write('done\n')
spgwcFile.write('\n')
spgwcFile.write('exit 0\n')
spgwcFile.close()
class spgwuConfigGen():
def __init__(self):
self.kind = ''
self.s1u_name = ''
self.sxu_name = ''
self.spgwc0_ip_addr = ''
self.fromDockerFile = False
def GenerateSpgwuConfigurer(s1u_name, sxc_name, spgwc0_ip_addr):
spgwuFile = open('./spgwu-cfg.sh', 'w')
spgwuFile.write('#!/bin/bash\n')
spgwuFile.write('\n')
spgwuFile.write('cd /home\n')
spgwuFile.write('\n')
spgwuFile.write('INSTANCE=1\n')
spgwuFile.write('PREFIX=\'/usr/local/etc/oai\'\n')
spgwuFile.write('mkdir -p $PREFIX\n')
spgwuFile.write('cp etc/spgw_u.conf $PREFIX\n')
spgwuFile.write('\n')
spgwuFile.write('declare -A SPGWU_CONF\n')
spgwuFile.write('\n')
spgwuFile.write('SPGWU_CONF[@INSTANCE@]=$INSTANCE\n')
spgwuFile.write('SPGWU_CONF[@PID_DIRECTORY@]=\'/var/run\'\n')
spgwuFile.write('SPGWU_CONF[@SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP@]=\'' + s1u_name + '\'\n')
spgwuFile.write('SPGWU_CONF[@SGW_INTERFACE_NAME_FOR_SX@]=\'' + sxc_name + '\'\n')
spgwuFile.write('SPGWU_CONF[@SGW_INTERFACE_NAME_FOR_SGI@]=\'eth0\'\n')
spgwuFile.write('SPGWU_CONF[@SPGWC0_IP_ADDRESS@]=\'' + spgwc0_ip_addr + '\'\n')
spgwuFile.write('\n')
spgwuFile.write('for K in "${!SPGWU_CONF[@]}"; do \n')
spgwuFile.write(' egrep -lRZ "$K" $PREFIX | xargs -0 -l sed -i -e "s|$K|${SPGWU_CONF[$K]}|g"\n')
spgwuFile.write('done\n')
spgwuFile.write('\n')
spgwuFile.write('exit 0\n')
spgwuFile.close()
def GenerateSpgwuConfigurer(self):
spgwuFile = open('./spgwu-cfg.sh', 'w')
spgwuFile.write('#!/bin/bash\n')
spgwuFile.write('\n')
if self.fromDockerFile:
spgwuFile.write('cd /openair-spgwu-tiny\n')
else:
spgwuFile.write('cd /home\n')
spgwuFile.write('\n')
spgwuFile.write('INSTANCE=1\n')
if self.fromDockerFile:
spgwuFile.write('PREFIX=\'/openair-spgwu-tiny/etc\'\n')
else:
spgwuFile.write('PREFIX=\'/usr/local/etc/oai\'\n')
spgwuFile.write('\n')
if not self.fromDockerFile:
spgwuFile.write('mkdir -p $PREFIX\n')
spgwuFile.write('cp etc/spgw_u.conf $PREFIX\n')
spgwuFile.write('\n')
spgwuFile.write('declare -A SPGWU_CONF\n')
spgwuFile.write('\n')
spgwuFile.write('SPGWU_CONF[@INSTANCE@]=$INSTANCE\n')
spgwuFile.write('SPGWU_CONF[@PID_DIRECTORY@]=\'/var/run\'\n')
spgwuFile.write('SPGWU_CONF[@SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP@]=\'' + self.s1u_name + '\'\n')
spgwuFile.write('SPGWU_CONF[@SGW_INTERFACE_NAME_FOR_SX@]=\'' + self.sxu_name + '\'\n')
# SGI is fixed on SGI
spgwuFile.write('SPGWU_CONF[@SGW_INTERFACE_NAME_FOR_SGI@]=\'eth0\'\n')
spgwuFile.write('SPGWU_CONF[@SPGWC0_IP_ADDRESS@]=\'' + self.spgwc0_ip_addr + '\'\n')
spgwuFile.write('\n')
spgwuFile.write('for K in "${!SPGWU_CONF[@]}"; do \n')
spgwuFile.write(' egrep -lRZ "$K" $PREFIX | xargs -0 -l sed -i -e "s|$K|${SPGWU_CONF[$K]}|g"\n')
spgwuFile.write('done\n')
spgwuFile.write('\n')
spgwuFile.write('exit 0\n')
spgwuFile.close()
#-----------------------------------------------------------
# Usage()
......@@ -97,31 +76,23 @@ def GenerateSpgwuConfigurer(s1u_name, sxc_name, spgwc0_ip_addr):
def Usage():
print('----------------------------------------------------------------------------------------------------------------------')
print('generateConfigFiles.py')
print(' Prepare a bash script to be run in the workspace where either SPGW-C and/or SPGW-U are being built.')
print(' Prepare a bash script to be run in the workspace where SPGW-U-TINY is being built.')
print(' That bash script will copy configuration template files and adapt to your configuration.')
print('----------------------------------------------------------------------------------------------------------------------')
print('Usage: python3 generateConfigFiles.py [options]')
print(' --help Show this help.')
print('------------------------------------------------------------------------------------------------- SPGW-C Options -----')
print(' --kind=SPGW-C')
print(' --s11c=[SPGW-C S11 Interface Name]')
print(' --sxc=[SPGW-C SX Interface Name]')
print('------------------------------------------------------------------------------------------------- SPGW-U Options -----')
print(' --kind=SPGW-U')
print(' --sxc_ip_addr=[SPGW-C SX IP address]')
print(' --sxu=[SPGW-U SX Interface Name]')
print(' --s1u=[SPGW-U S1-U Interface Name]')
print(' --from_docker_file')
argvs = sys.argv
argc = len(argvs)
cwd = os.getcwd()
kind = ''
s11c = ''
sxc = ''
sxu = ''
spgwc0_ip_addr = ''
s1u = ''
mySpgwuCfg = spgwuConfigGen()
while len(argvs) > 1:
myArgv = argvs.pop(1)
......@@ -130,51 +101,39 @@ while len(argvs) > 1:
sys.exit(0)
elif re.match('^\-\-kind=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-kind=(.+)$', myArgv, re.IGNORECASE)
kind = matchReg.group(1)
elif re.match('^\-\-s11c=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-s11c=(.+)$', myArgv, re.IGNORECASE)
s11c = matchReg.group(1)
elif re.match('^\-\-sxc=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-sxc=(.+)$', myArgv, re.IGNORECASE)
sxc = matchReg.group(1)
mySpgwuCfg.kind = matchReg.group(1)
elif re.match('^\-\-sxu=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-sxu=(.+)$', myArgv, re.IGNORECASE)
sxu = matchReg.group(1)
mySpgwuCfg.sxu_name = matchReg.group(1)
elif re.match('^\-\-sxc_ip_addr=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-sxc_ip_addr=(.+)$', myArgv, re.IGNORECASE)
spgwc0_ip_addr = matchReg.group(1)
mySpgwuCfg.spgwc0_ip_addr = matchReg.group(1)
elif re.match('^\-\-s1u=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-s1u=(.+)$', myArgv, re.IGNORECASE)
s1u = matchReg.group(1)
mySpgwuCfg.s1u_name = matchReg.group(1)
elif re.match('^\-\-from_docker_file', myArgv, re.IGNORECASE):
mySpgwuCfg.fromDockerFile = True
else:
Usage()
sys.exit('Invalid Parameter: ' + myArgv)
if kind == '':
if mySpgwuCfg.kind == '':
Usage()
sys.exit('missing kind parameter')
if kind == 'SPGW-C':
if s11c == '':
Usage()
sys.exit('missing S11 Interface Name on SPGW-C container')
elif sxc == '':
Usage()
sys.exit('missing SX Interface Name on SPGW-C container')
else:
GenerateSpgwcConfigurer(s11c, sxc)
sys.exit(0)
if kind == 'SPGW-U':
if sxu == '':
if mySpgwuCfg.kind == 'SPGW-U':
if mySpgwuCfg.sxu_name == '':
Usage()
sys.exit('missing SX Interface Name on SPGW-U container')
elif s1u == '':
elif mySpgwuCfg.s1u_name == '':
Usage()
sys.exit('missing S1-U Interface Name on SPGW-U container')
elif spgwc0_ip_addr == '':
elif mySpgwuCfg.spgwc0_ip_addr == '':
Usage()
sys.exit('missing SPGW-C #0 IP address on SX interface')
else:
GenerateSpgwuConfigurer(s1u, sxu, spgwc0_ip_addr)
mySpgwuCfg.GenerateSpgwuConfigurer()
sys.exit(0)
else:
Usage()
sys.exit('invalid kind parameter')
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment