Skip to content

Commit

Permalink
v2x-xapp
Browse files Browse the repository at this point in the history
  • Loading branch information
fgjeci committed Jan 23, 2024
0 parents commit 7a28138
Show file tree
Hide file tree
Showing 1,221 changed files with 125,231 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Module",
"type": "python",
"request": "launch",
"module": "enter-your-module-name",
"justMyCode": true
}
]
}
64 changes: 64 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"files.associations": {
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"csignal": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"chrono": "cpp",
"compare": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"cstdint": "cpp",
"deque": "cpp",
"list": "cpp",
"map": "cpp",
"set": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"random": "cpp",
"ratio": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"semaphore": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cinttypes": "cpp",
"typeinfo": "cpp"
}
}
20 changes: 20 additions & 0 deletions .vscode/sftp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "Antlion2",
"host": "ant2",
"protocol": "sftp",
"secure": true,
"port": 22,
"username": "fgjeci",
"remotePath": "/home/fgjeci/workspace/v2x-xapp-ric1/",
"privateKeyPath": "/home/fgjeci/.ssh/antlion_ftp_simple",
"uploadOnSave": true,
"useTempFile": false,
"openSsh": false,
"allow": [
"setup",
"setup-scripts"
],
"ignore": [
"setup/xapp-sm-connector/build"
]
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Millica-xapp
Millicar xapp
Empty file added report.log
Empty file.
78 changes: 78 additions & 0 deletions setup-scripts/create-new-xapp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/bin/sh
set -x

RIC_OCTET=5
XAPP_IP_BASE="10.0.$RIC_OCTET"
XAPP_NEW_NAME="xapp-ric$RIC_OCTET"
XAPP_NEW_IMAGE_NAME="ef-ric$RIC_OCTET"
EF_XAPP_DIR="$(dirname "$PWD")"
WORKSPACE_DIR="$(dirname "$EF_XAPP_DIR")"
XAPP_NEW_DIR=${WORKSPACE_DIR}/${XAPP_NEW_NAME}
XAPP_NEW_SETUP_DIR=${XAPP_NEW_DIR}/setup
XAPP_NEW_SM_CONNECTOR_DIR=${XAPP_NEW_SETUP_DIR}/xapp-sm-connector


# Check if xapp exist - if yes, we do nothing
if [ -d "$XAPP_NEW_DIR" ]; then
echo "Directory exists."
cd $WORKSPACE_DIR
rm -rf $XAPP_NEW_NAME
exit
else
echo "Directory do not exist."
echo "Coping directory to $XAPP_NEW_DIR"
cd $WORKSPACE_DIR
# create new dir
mkdir $XAPP_NEW_NAME
cp -r ${EF_XAPP_DIR}/.vscode ${XAPP_NEW_DIR}
# change the remote path directory to the new directory
sed -i "s#${EF_XAPP_DIR}#${XAPP_NEW_DIR}#g" ${XAPP_NEW_DIR}/.vscode/sftp.json
# copy xapp-sm-connector
cd $XAPP_NEW_DIR
mkdir setup
# cd setup
cp -r ${EF_XAPP_DIR}/setup/xapp-sm-connector ${XAPP_NEW_SETUP_DIR}
cp -r ${EF_XAPP_DIR}/setup/xapp ${XAPP_NEW_SETUP_DIR}

# copy setup-scripts
mkdir setup-scripts
cd ${EF_XAPP_DIR}/setup-scripts
cp $(ls --ignore=create-new-xapp.sh) ${XAPP_NEW_DIR}/setup-scripts

cd ${XAPP_NEW_DIR}/setup-scripts
# change the name
sed -i "s#IMAGE_NAME=xapp#IMAGE_NAME=${XAPP_NEW_IMAGE_NAME}#g" ${XAPP_NEW_DIR}/setup-scripts/setup-xapp.sh
sed -i "s#ric #ric${RIC_OCTET} #g" ${XAPP_NEW_DIR}/setup-scripts/setup-xapp.sh
sed -i "s#10.0.2#${XAPP_IP_BASE}#g" ${XAPP_NEW_DIR}/setup-scripts/setup-lib.sh
sed -i "s#36422#$(($(($RIC_OCTET-2))*10000+36422))#g" ${XAPP_NEW_DIR}/setup-scripts/setup-lib.sh
sed -i "s#xapp-#${XAPP_NEW_IMAGE_NAME}-#g" ${XAPP_NEW_DIR}/setup-scripts/start-xapp-ns-o-ran.sh
# change init files
sed -i "s#10.0.2#${XAPP_IP_BASE}#g" ${XAPP_NEW_DIR}/setup/xapp-sm-connector/init/routes.txt
sed -i "s#10.0.2#${XAPP_IP_BASE}#g" ${XAPP_NEW_DIR}/setup/xapp-sm-connector/src/xapp_env.sh
# CHANGE ip in the Dockerfile
sed -i "s#10.0.2#${XAPP_IP_BASE}#g" ${XAPP_NEW_DIR}/setup/xapp/Dockerfile
fi

echo "Moving to the new created directory"

cd ${XAPP_NEW_DIR}
git init -b main
# git config --global init.defaultBranch "main"
git config --local user.name "fgjeci"
git config --local user.email "[email protected]"
cp ${EF_XAPP_DIR}/.git/info/exclude ${XAPP_NEW_DIR}/.git/info/exclude
git add .
git commit -m "Xapp creation"

# create github account
# GitHub CLI api
# https://cli.github.com/manual/gh_api

gh repo create ${XAPP_NEW_IMAGE_NAME} --private --source=. --remote=origin --push
git push --set-upstream origin main


# gh repo delete fgjeci/${XAPP_NEW_IMAGE_NAME}



2 changes: 2 additions & 0 deletions setup-scripts/gdb.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Already logging to gdb.txt.
Quit
22 changes: 22 additions & 0 deletions setup-scripts/setup-lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

# get sudo if needed
if [ -z "$EUID" ]; then
EUID=`id -u`
fi
SUDO=
if [ ! $EUID -eq 0 ] ; then
SUDO=sudo
fi

# default IPs and ports
RIC_SUBNET=10.0.2.0/24
RIC_IP=10.0.2.1
E2TERM_IP=10.0.2.10
E2TERM_SCTP_PORT=36422
E2MGR_IP=10.0.2.11
DBAAS_IP=10.0.2.12
DBAAS_PORT=6379
E2RTMANSIM_IP=10.0.2.15
XAPP_IP=10.0.2.24 # generic xApp IP

16 changes: 16 additions & 0 deletions setup-scripts/setup-xapp-base.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
SETUP_DIR=../setup
MODEL_DIR=xapp-v2x
CONNECTOR_DIR=xapp-sm-connector
IMAGE_NAME=xapp-base
DOCKER_FILE=Dockerfile_build_xapp_base


# Build docker image
$SUDO docker image inspect ${IMAGE_NAME}:latest >/dev/null 2>&1
if [ ! $? -eq 0 ]; then
cd ${SETUP_DIR}
cp ${MODEL_DIR}/${DOCKER_FILE} ./${DOCKER_FILE}_${IMAGE_NAME}
$SUDO docker build \
-f ${DOCKER_FILE}_${IMAGE_NAME} -t ${IMAGE_NAME}:latest .

fi
86 changes: 86 additions & 0 deletions setup-scripts/setup-xapp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/bin/sh
# call as setup-sample-xapp.sh gnb_id

set -x

IMAGE_NAME=xapp-v2x
MODEL_DIR=xapp-v2x
CONNECTOR_DIR=xapp-sm-connector
DOCKER_FILE=Dockerfile
SETUP_DIR=../setup

export SRC=`dirname $0`
cd $SRC
. $SRC/setup-lib.sh

ENTRYPOINT=/bin/bash
GNB_ID=$1

# if changing xApp IP or ID, you need to define new RMR routes
# in the setup-ric.sh/setup-lib.sh scripts and restart the RIC
XAPP_IP=$XAPP_IP
XAPP_ID=$(echo $XAPP_IP | cut -d "." -f 4)

CONTAINER_NAME=${IMAGE_NAME}-${XAPP_ID}
# CONTAINER_NAME=${IMAGE_NAME}

# Build docker image
$SUDO docker image inspect ${IMAGE_NAME}:latest >/dev/null 2>&1
if [ ! $? -eq 0 ]; then
tagvers=`git log --pretty=format:"%h" -n 1`
$SUDO docker image inspect ${IMAGE_NAME}:$tagvers >/dev/null 2>&1
if [ ! $? -eq 0 ]; then
# copy Dockerfile out
cd ${SETUP_DIR}
cp ${MODEL_DIR}/${DOCKER_FILE} ./${DOCKER_FILE}_${IMAGE_NAME}

$SUDO docker build \
--build-arg DBAAS_SERVICE_HOST=$DBAAS_IP \
--build-arg DBAAS_SERVICE_PORT=$DBAAS_PORT \
-f ${DOCKER_FILE}_${IMAGE_NAME} -t ${IMAGE_NAME}:$tagvers .

# remove copied Dockerfile
rm ${DOCKER_FILE}_${IMAGE_NAME}

fi
$SUDO docker tag ${IMAGE_NAME}:$tagvers ${IMAGE_NAME}:latest
$SUDO docker rmi ${IMAGE_NAME}:$tagvers
fi

remove_container() {
$SUDO docker inspect $1 >/dev/null 2>&1
if [ $? -eq 0 ]; then
$SUDO docker kill $1
$SUDO docker rm $1
fi
}

# run containers
remove_container ${CONTAINER_NAME}

# --log-driver json-file \
# --log-opt max-size=15m \
# --log-opt max-file=5 \

# replace parameters, recompile code and restart container
$SUDO docker run -d -it --entrypoint ${ENTRYPOINT} --network ric --ip ${XAPP_IP} \
-e DBAAS_SERVICE_HOST=$DBAAS_IP -e DBAAS_SERVICE_PORT=$DBAAS_PORT --name ${CONTAINER_NAME} ${IMAGE_NAME}:latest
# -v ~/workspace/docker_ef:/home/traces \
# $SUDO docker run -d -it --entrypoint ${ENTRYPOINT} --network=ric --ip ${XAPP_IP} -p :37422:37423/sctp\
# -e DBAAS_SERVICE_HOST=$DBAAS_IP -e DBAAS_SERVICE_PORT=$DBAAS_PORT --name ${CONTAINER_NAME} ${IMAGE_NAME}:latest


if [ -n "${GNB_ID}" ]; then
docker exec ${CONTAINER_NAME} sed -i "s/^export GNB_ID.*/export GNB_ID=${GNB_ID}/g" /home/${CONNECTOR_DIR}/build_xapp.sh
fi

docker exec ${CONTAINER_NAME} sed -i "s/^export XAPP_ID.*/export XAPP_ID=${XAPP_ID}/g" /home/${CONNECTOR_DIR}/build_xapp.sh

docker exec ${CONTAINER_NAME} chmod +x /home/${CONNECTOR_DIR}/build_xapp.sh
docker exec ${CONTAINER_NAME} chmod +x /home/${CONNECTOR_DIR}/rebuild_xapp.sh
docker exec ${CONTAINER_NAME} chmod +x /home/${CONNECTOR_DIR}/ric_message_sl.sh
docker exec ${CONTAINER_NAME} chmod +x /home/${CONNECTOR_DIR}/run_xapp.sh

docker exec ${CONTAINER_NAME} /home/${CONNECTOR_DIR}/build_xapp.sh clean
docker container restart ${CONTAINER_NAME}

7 changes: 7 additions & 0 deletions setup-scripts/start-xapp-ns-o-ran.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
docker kill xapp-v2x-24
docker rm xapp-v2x-24
# docker rmi ef-xapp:latest
./setup-xapp.sh ns-o-ran

docker exec -it xapp-v2x-24 bash
Loading

0 comments on commit 7a28138

Please sign in to comment.