Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-UPF
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenXG
OpenXG-UPF
Commits
30defdf4
Unverified
Commit
30defdf4
authored
Sep 17, 2021
by
kharade
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nrf python client
parent
17c02ea1
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
422 additions
and
176 deletions
+422
-176
docker/Dockerfile.upf-vpp.ubuntu18
docker/Dockerfile.upf-vpp.ubuntu18
+7
-0
scripts/entrypoint.sh
scripts/entrypoint.sh
+9
-3
scripts/nrf_client.py
scripts/nrf_client.py
+165
-0
scripts/run.sh
scripts/run.sh
+11
-2
scripts/tests/docker-compose.yml
scripts/tests/docker-compose.yml
+191
-171
scripts/upf_conf/upf_profile.json
scripts/upf_conf/upf_profile.json
+39
-0
No files found.
docker/Dockerfile.upf-vpp.ubuntu18
View file @
30defdf4
...
...
@@ -93,16 +93,23 @@ RUN apt-get update && \
iproute2 \
iputils-ping \
vim \
python \
python-pip \
libcurl4-openssl-dev \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
RUN pip install pycurl termcolor
WORKDIR /openair-upf/bin
COPY --from=vpp-upf-builder /vpp-upf/scripts/entrypoint.sh .
COPY --from=vpp-upf-builder /vpp-upf/vpp/build-root/install-vpp-native/vpp/bin/vpp .
COPY --from=vpp-upf-builder /vpp-upf/vpp/build-root/install-vpp-native/vpp/bin/vppctl .
COPY --from=vpp-upf-builder /vpp-upf/scripts/nrf_client.py .
WORKDIR /openair-upf/etc
COPY --from=vpp-upf-builder /vpp-upf/scripts/upf_conf/init.conf .
COPY --from=vpp-upf-builder /vpp-upf/scripts/upf_conf/startup_debug.conf .
COPY --from=vpp-upf-builder /vpp-upf/scripts/upf_conf/upf_profile.json .
WORKDIR /usr/lib/x86_64-linux-gnu/
COPY --from=vpp-upf-builder /vpp-upf/vpp/build-root/install-vpp-native/vpp/lib/ .
...
...
scripts/entrypoint.sh
View file @
30defdf4
...
...
@@ -10,12 +10,19 @@
set
-euo
pipefail
CONFIG_DIR
=
"/openair-upf/etc"
SGI_IPV4
=
$(
ifconfig
$INTERFACE_SGI
|
grep
"inet "
|
awk
'{print $2}'
)
ACCESS_IPV4
=
$(
ifconfig
$INTERFACE_ACCESS
|
grep
"inet "
|
awk
'{print $2}'
)
CORE_IPV4
=
$(
ifconfig
$INTERFACE_CORE
|
grep
"inet "
|
awk
'{print $2}'
)
N3_IPV4_ADDRESS_LOCAL
=
$(
ifconfig
$INTERFACE_ACCESS
|
grep
"inet "
|
awk
'{print $2}'
|
cut
-d
"."
-f1-3
)
".202"
N4_IPV4_ADDRESS_LOCAL
=
$(
ifconfig
$INTERFACE_CORE
|
grep
"inet "
|
awk
'{print $2}'
|
cut
-d
"."
-f1-3
)
".202"
N6_IPV4_ADDRESS_LOCAL
=
$(
ifconfig
$INTERFACE_SGI
|
grep
"inet "
|
awk
'{print $2}'
|
cut
-d
"."
-f1-3
)
".202"
###############################
# UPF Config
###############################
for
c
in
${
CONFIG_DIR
}
/
*
.conf
;
do
array
=(
${
CONFIG_DIR
}
/
*
.conf
${
CONFIG_DIR
}
/
*
.json
)
for
c
in
"
${
array
[@]
}
"
;
do
# grep variable names (format: ${VAR}) from template to be rendered
VARS
=
$(
grep
-oP
'@[a-zA-Z0-9_]+@'
${
c
}
|
sort
|
uniq
| xargs
)
# create sed expressions for substituting each occurrence of ${VAR}
...
...
@@ -44,7 +51,6 @@ done
# Near future we will have multiple interfaces (e.g. two n6 interface for edge computing case)
# We define in this order in docker-compose -> it is alphabetical order
#
SGI_IPV4
=
$(
ifconfig
$INTERFACE_SGI
|
grep
"inet "
|
awk
'{print $2}'
)
ip
link set
$INTERFACE_ACCESS
down
ip
link set
$INTERFACE_ACCESS
name access
...
...
scripts/nrf_client.py
0 → 100755
View file @
30defdf4
#!/usr/bin/env python
"""
/*
* 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
*/
/*!
\f
ile nrf_client.py
\a
uthor Rohan KHARADE
\date 2018
\email: rohan.kharade@openairinterface.org
*/
"""
import
time
,
sys
,
json
,
logging
,
uuid
,
pycurl
,
argparse
,
atexit
from
termcolor
import
colored
logging
.
basicConfig
(
format
=
'%(asctime)s] %(filename)s: %(levelname)s '
'- %(message)s'
,
datefmt
=
'%m/%d/%Y %I:%M:%S %p'
)
class
upf_profile
(
object
):
def
__init__
(
self
,
create_topo_log_level
=
None
,
fqdn
=
None
,
nrf_ip
=
None
,
nrf_port
=
None
,
http_version
=
None
):
self
.
logger
=
logging
.
getLogger
(
"upf"
)
atexit
.
register
(
self
.
goodbye
)
# register a message to print out when exit
if
create_topo_log_level
:
if
create_topo_log_level
==
'debug'
:
self
.
logger
.
setLevel
(
logging
.
DEBUG
)
elif
create_topo_log_level
==
'info'
:
self
.
logger
.
setLevel
(
logging
.
INFO
)
elif
create_topo_log_level
==
'warn'
:
self
.
logger
.
setLevel
(
logging
.
WARNING
)
elif
create_topo_log_level
==
'error'
:
self
.
logger
.
setLevel
(
logging
.
ERROR
)
elif
create_topo_log_level
==
'critic'
:
self
.
logger
.
setLevel
(
logging
.
CRITICAL
)
message
=
" NRF UPF client started "
self
.
logger
.
info
(
message
)
#@@@@@@@@ Initialize arguments #@@@@@@@@
self
.
nrf_ip
=
nrf_ip
self
.
nrf_port
=
nrf_port
self
.
http_version
=
http_version
self
.
status_code
=
0
self
.
uuid
=
uuid
.
uuid4
()
self
.
url
=
'http://'
+
str
(
self
.
nrf_ip
)
+
':'
+
str
(
self
.
nrf_port
)
+
'/nnrf-nfm/v1/nf-instances/'
+
str
(
self
.
uuid
)
self
.
curl
=
pycurl
.
Curl
()
self
.
headers
=
[
"Content-Type:application/json"
]
self
.
dir_config
=
'/openair-upf/'
self
.
file_name
=
self
.
dir_config
+
'etc/upf_profile.json'
self
.
conf_file
=
open
(
self
.
file_name
,)
self
.
upf_profile
=
json
.
load
(
self
.
conf_file
)
#@@@@@@@@ Initialize upf profile #@@@@@@@@
self
.
upf_profile
[
'nfInstanceId'
]
=
str
(
self
.
uuid
)
self
.
capacity
=
self
.
upf_profile
[
'capacity'
]
self
.
fqdn
=
self
.
upf_profile
[
'fqdn'
]
self
.
heartBeatTimer
=
self
.
upf_profile
[
'heartBeatTimer'
]
self
.
ipv4Addresses
=
self
.
upf_profile
[
'ipv4Addresses'
]
self
.
nfInstanceId
=
self
.
upf_profile
[
'nfInstanceId'
]
self
.
nfInstanceName
=
self
.
upf_profile
[
'nfInstanceName'
]
self
.
nfStatus
=
self
.
upf_profile
[
'nfStatus'
]
self
.
nfType
=
self
.
upf_profile
[
'nfType'
]
self
.
priority
=
self
.
upf_profile
[
'priority'
]
self
.
sNssais
=
self
.
upf_profile
[
'sNssais'
]
self
.
upfInfo
=
self
.
upf_profile
[
'upfInfo'
]
message
=
" UPF profile is parsed "
self
.
logger
.
info
(
message
)
def
display_upf_profile
(
self
):
message
=
" Display UPF profile "
self
.
logger
.
info
(
message
)
print
(
colored
(
'[*] UPF Profile
\n
\t
fqdn = '
+
self
.
fqdn
+
\
'
\n
\t
capacity = '
+
str
(
self
.
capacity
)
+
\
'
\n
\t
heartBeatTimer = '
+
str
(
self
.
heartBeatTimer
)
+
\
'
\n
\t
ipv4Addresses = '
+
u", "
.
join
(
self
.
ipv4Addresses
)
+
\
'
\n
\t
nfInstanceId = '
+
self
.
nfInstanceId
+
\
'
\n
\t
nfInstanceName = '
+
self
.
nfInstanceName
+
\
'
\n
\t
nfStatus = '
+
self
.
nfStatus
+
\
'
\n
\t
nfType = '
+
self
.
nfType
+
\
'
\n
\t
priority = '
+
str
(
self
.
priority
)
+
\
'
\n
\t
sNssais = '
+
json
.
dumps
(
self
.
sNssais
)
+
\
'
\n
\t
upfInfo = '
+
json
.
dumps
(
self
.
upfInfo
,
indent
=
6
)
\
,
'green'
))
def
trigger_nf_registration
(
self
):
message
=
" Sending NF registration request (HTTP Version - "
+
str
(
self
.
http_version
)
+
")"
self
.
logger
.
info
(
message
)
self
.
curl
.
setopt
(
self
.
curl
.
URL
,
self
.
url
)
self
.
curl
.
setopt
(
self
.
curl
.
HTTPHEADER
,
self
.
headers
)
self
.
curl
.
setopt
(
self
.
curl
.
CUSTOMREQUEST
,
'PUT'
)
self
.
curl
.
setopt
(
self
.
curl
.
POSTFIELDS
,
json
.
dumps
(
self
.
upf_profile
))
if
(
str
(
self
.
http_version
)
==
'2'
):
self
.
curl
.
setopt
(
self
.
curl
.
HTTP_VERSION
,
pycurl
.
CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE
)
response
=
self
.
curl
.
perform
()
self
.
status_code
=
self
.
curl
.
getinfo
(
self
.
curl
.
RESPONSE_CODE
)
if
self
.
status_code
==
201
or
self
.
status_code
==
200
:
message
=
" Succussfully registered at NRF !!"
self
.
logger
.
info
(
message
)
self
.
trigger_nf_heartbeat
()
else
:
print
(
colored
(
'
\n\n
NF registration failed
\n\n
'
,
'red'
))
def
trigger_nf_heartbeat
(
self
):
patch_data
=
[{
"op"
:
"replace"
,
"path"
:
"/nfStatus"
,
"value"
:
"REGISTERED"
}]
while
True
:
message
=
" Sending NF heartbeat requset (HTTP Version - "
+
str
(
self
.
http_version
)
+
") !!"
self
.
logger
.
info
(
message
)
time
.
sleep
(
5
)
self
.
curl
.
setopt
(
self
.
curl
.
CUSTOMREQUEST
,
'PATCH'
)
self
.
curl
.
setopt
(
self
.
curl
.
POSTFIELDS
,
json
.
dumps
(
patch_data
))
response
=
self
.
curl
.
perform
()
self
.
status_code
=
self
.
curl
.
getinfo
(
self
.
curl
.
RESPONSE_CODE
)
if
self
.
status_code
==
204
:
message
=
" Succussfully received NF heartbeat response !!"
self
.
logger
.
info
(
message
)
else
:
print
(
colored
(
'
\n\n
NF heartbeat procedure failed
\n\n
'
,
'red'
))
def
goodbye
(
self
):
print
(
colored
(
'
\n\n\n
[*] You are now leaving OAI-NRF framework .....
\n\n\n
'
,
'yellow'
))
sys
.
exit
(
0
)
if
__name__
==
'__main__'
:
parser
=
argparse
.
ArgumentParser
(
description
=
'Process commandline arguments and override configurations'
)
parser
.
add_argument
(
'--log'
,
metavar
=
'[level]'
,
action
=
'store'
,
type
=
str
,
required
=
False
,
default
=
'debug'
,
help
=
'set the log level: debug, info (default), warning, error, critical. default = info'
)
parser
.
add_argument
(
'--fqdn'
,
metavar
=
'[number]'
,
action
=
'store'
,
type
=
str
,
required
=
False
,
default
=
'oai-upf-vpp.org'
,
help
=
'set the fqdn for upf. default = oai-upf-vpp.org'
)
parser
.
add_argument
(
'--nrf_ip'
,
metavar
=
'[number]'
,
action
=
'store'
,
type
=
str
,
required
=
False
,
default
=
'192.168.71.130'
,
help
=
'set the nrf ip address. default = 192.168.71.130'
)
parser
.
add_argument
(
'--nrf_port'
,
metavar
=
'[number]'
,
action
=
'store'
,
type
=
str
,
required
=
False
,
default
=
'8080'
,
help
=
'set the nrf ip address. default = 8080'
)
parser
.
add_argument
(
'--http_version'
,
metavar
=
'[number]'
,
action
=
'store'
,
type
=
str
,
required
=
False
,
default
=
'2'
,
help
=
'set the nrf ip address. default = 2'
)
args
=
parser
.
parse_args
()
nrf_client
=
upf_profile
(
args
.
log
,
args
.
fqdn
,
args
.
nrf_ip
,
args
.
nrf_port
,
args
.
http_version
)
nrf_client
.
display_upf_profile
()
nrf_client
.
trigger_nf_registration
()
()
\ No newline at end of file
scripts/run.sh
View file @
30defdf4
#!/bin/
sh -x
#!/bin/
bash
if
[
$(
id
-u
)
-ne
0
]
;
then
exec sudo
-E
"
$0
"
"
$@
"
...
...
@@ -25,10 +25,11 @@ while getopts ":r" opt; do
;;
esac
done
shift
$((
OPTIND-1
))
if
test
-z
"
$1
"
;
then
$APP
$ARGS
$APP
$ARGS
&
elif
test
"
$1
"
=
"debug"
;
then
shift
gdb
-ex
'set print pretty on'
-ex
'run'
--args
$APP
$ARGS
$@
...
...
@@ -37,3 +38,11 @@ else
exit
1
fi
if
[[
${
REGISTER_NRF
}
==
"yes"
]]
;
then
sleep
5
NRF_APP
=
"
$base
/bin/nrf_client.py"
NRF_ARGS
=
" --nrf_ip="
$NRF_IP_ADDR
" --nrf_port="
$NRF_PORT
" --http_version="
$HTTP_VERSION
python
$NRF_APP
$NRF_ARGS
fi
scripts/tests/docker-compose.yml
View file @
30defdf4
This diff is collapsed.
Click to expand it.
scripts/upf_conf/upf_profile.json
0 → 100644
View file @
30defdf4
{
"capacity"
:
100
,
"fqdn"
:
"gw@GW_ID@.vppupf.node.5gcn.mnc@MNC03@.mcc@MCC@.@REALM@"
,
"heartBeatTimer"
:
10
,
"ipv4Addresses"
:
[
"@N4_IPV4_ADDRESS_LOCAL@"
],
"json_data"
:
null
,
"nfInstanceName"
:
"OAI-UPF-VPP"
,
"nfServices"
:
[],
"nfStatus"
:
"REGISTERED"
,
"nfType"
:
"UPF"
,
"priority"
:
1
,
"sNssais"
:
[{
"sd"
:
"@NSSAI_SD_0@"
,
"sst"
:
@SST@
}],
"upfInfo"
:
{
"sNssaiUpfInfoList"
:
[{
"dnnUpfInfoList"
:
[{
"dnn"
:
"@DNN@"
}],
"sNssai"
:
{
"sd"
:
"@NSSAI_SD_0@"
,
"sst"
:
@SST@
}
}],
"interfaceUpfInfoList"
:
[{
"endpointFqdn"
:
"@NWI_ACCESS@"
,
"interfaceType"
:
"N3"
,
"ipv4EndpointAddresses"
:
[
"@ACCESS_IPV4@"
],
"networkInstance"
:
"@NWI_ACCESS@"
},
{
"endpointFqdn"
:
"@NWI_CORE@"
,
"interfaceType"
:
"N6"
,
"ipv4EndpointAddresses"
:
[
"@CORE_IPV4@"
],
"networkInstance"
:
"@NWI_CORE@"
}]
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment