Commit f25642f7 authored by sagar arora's avatar sagar arora

Merge branch 'releasev1.4.0' into 'master'

Release v1.4.0

See merge request oai/cn5g/oai-cn5g-ausf!24
parents 61753eaf f2d7a44e
# RELEASE NOTES : # # RELEASE NOTES : #
## v1.4.0 -- January 2021 ##
* Remove unused packages
* HTTP/2 support for SBI interface
* NRF Registration and heartbeat exchange
* Official images produced by CI are pushed to `oaisoftwarealliance` Docker-Hub Team account
* Reduce image size
## v1.3.0 -- January 2021 ## ## v1.3.0 -- January 2021 ##
* HTTP2 Support * HTTP2 Support
......
...@@ -50,6 +50,9 @@ def AUSF_BASE_IMAGE_TAG = params.AusfBaseImageTag ...@@ -50,6 +50,9 @@ def AUSF_BASE_IMAGE_TAG = params.AusfBaseImageTag
// Merge Request Link // Merge Request Link
def gitlabMergeRequestLink def gitlabMergeRequestLink
// Docker Hub account to push to
def DH_Account = "oaisoftwarealliance"
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
// Pipeline start // Pipeline start
pipeline { pipeline {
...@@ -183,7 +186,7 @@ pipeline { ...@@ -183,7 +186,7 @@ pipeline {
echo "Maybe a previous build went wrong" echo "Maybe a previous build went wrong"
} }
// In case of push to `develop` branch we build from scratch // In case of push to `develop` branch we build from scratch
myShCmd('docker build --no-cache --target oai-ausf --tag oai-ausf:' + ausf_tag + ' --file docker/Dockerfile.ausf.ubuntu18 --build-arg NEEDED_GIT_PROXY="http://proxy.eurecom.fr:8080" . > archives/ausf_docker_image_build.log 2>&1', rem_u18_host_flag, rem_u18_host_user, rem_u18_host) myShCmd('docker build --no-cache --target oai-ausf --tag oai-ausf:' + ausf_tag + ' --file docker/Dockerfile.ausf.ubuntu18 . > archives/ausf_docker_image_build.log 2>&1', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
} }
if ("MERGE".equals(env.gitlabActionType)) { if ("MERGE".equals(env.gitlabActionType)) {
try { try {
...@@ -198,6 +201,9 @@ pipeline { ...@@ -198,6 +201,9 @@ pipeline {
myShCmd('docker image tag oai-ausf-base:' + AUSF_BASE_IMAGE_TAG + ' oai-ausf-base:latest', rem_u18_host_flag, rem_u18_host_user, rem_u18_host) myShCmd('docker image tag oai-ausf-base:' + AUSF_BASE_IMAGE_TAG + ' oai-ausf-base:latest', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker build --no-cache --target oai-ausf --tag oai-ausf:' + ausf_tag + ' --file ci-scripts/docker/Dockerfile.ci.ubuntu.18.04 . > archives/ausf_docker_image_build.log 2>&1', rem_u18_host_flag, rem_u18_host_user, rem_u18_host) myShCmd('docker build --no-cache --target oai-ausf --tag oai-ausf:' + ausf_tag + ' --file ci-scripts/docker/Dockerfile.ci.ubuntu.18.04 . > archives/ausf_docker_image_build.log 2>&1', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
} }
// Putting a place holder to try out on the flattening of image.
// If not satisfactory, we can remove it.
myShCmd('python3 ./ci-scripts/flatten_image.py --tag oai-ausf:' + ausf_tag, rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker image ls >> archives/ausf_docker_image_build.log', rem_u18_host_flag, rem_u18_host_user, rem_u18_host) myShCmd('docker image ls >> archives/ausf_docker_image_build.log', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
// We will keep also the TMP image in U18 case. // We will keep also the TMP image in U18 case.
if ("MERGE".equals(env.gitlabActionType)) { if ("MERGE".equals(env.gitlabActionType)) {
...@@ -240,10 +246,14 @@ pipeline { ...@@ -240,10 +246,14 @@ pipeline {
} }
myShCmd('sudo podman image prune --force', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host) myShCmd('sudo podman image prune --force', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
// Copy the RHEL Host certificates for building // Copy the RHEL Host certificates for building
myShCmd('mkdir -p tmp/ca tmp/entitlement', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host) myShCmd('mkdir -p ./etc-pki-entitlement ./rhsm-conf ./rhsm-ca', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
myShCmd('cp /etc/pki/entitlement/*pem tmp/entitlement', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host) myShCmd('cp /etc/pki/entitlement/*pem ./etc-pki-entitlement', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
myShCmd('sudo cp /etc/rhsm/ca/redhat-uep.pem tmp/ca', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host) myShCmd('sudo cp /etc/rhsm/rhsm.conf ./rhsm-conf', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
myShCmd('sudo podman build --no-cache --target oai-ausf --tag oai-ausf:' + ausf_tag + ' --file docker/Dockerfile.ausf.rhel8 --build-arg NEEDED_GIT_PROXY="http://proxy.eurecom.fr:8080" . > archives/ausf_podman_image_build.log 2>&1', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host) myShCmd('sudo cp /etc/rhsm/ca/*.pem ./rhsm-ca', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
myShCmd('sudo podman build --no-cache --target oai-ausf --tag oai-ausf:' + ausf_tag + ' --file docker/Dockerfile.ausf.rhel8 . > archives/ausf_podman_image_build.log 2>&1', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
// Putting a place holder to try out on the flattening of image.
// If not satisfactory, we can remove it.
myShCmd('python3 ./ci-scripts/flatten_image.py --tag oai-ausf:' + ausf_tag, rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
myShCmd('sudo podman image ls >> archives/ausf_podman_image_build.log', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host) myShCmd('sudo podman image ls >> archives/ausf_podman_image_build.log', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
if ("MERGE".equals(env.gitlabActionType)) { if ("MERGE".equals(env.gitlabActionType)) {
myShCmd('sudo podman image tag oai-ausf:' + ausf_tag + ' oai-ausf:' + rhel_ausf_tag, rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host) myShCmd('sudo podman image tag oai-ausf:' + ausf_tag + ' oai-ausf:' + rhel_ausf_tag, rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
...@@ -409,6 +419,36 @@ pipeline { ...@@ -409,6 +419,36 @@ pipeline {
} }
} }
} }
stage ('Testing the tutorials') {
steps {
script {
gitlabCommitStatus(name: "Test tutorials") {
localStatus = build job: 'OAI-CN5G-Tutorials-Check',
parameters: [
string(name: 'AUSF_TAG', value: String.valueOf(ausf_tag)),
string(name: 'AUSF_BRANCH', value: String.valueOf(ausf_branch))
], propagate: false
localResult = localStatus.getResult()
if (localStatus.resultIsBetterOrEqualTo('SUCCESS')) {
echo "Tutorials Test Job is OK"
} else {
echo "Tutorials Test Job is KO"
sh "ci-scripts/fail.sh"
}
}
}
}
post {
always {
script {
copyArtifacts(projectName: 'OAI-CN5G-Tutorials-Check',
filter: '*_results_oai_cn5g*.html',
selector: lastCompleted())
}
}
}
}
} }
} }
// For the moment it is Docker-Hub, but we might have a new one internally. // For the moment it is Docker-Hub, but we might have a new one internally.
...@@ -421,9 +461,9 @@ pipeline { ...@@ -421,9 +461,9 @@ pipeline {
[$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.DockerHubCredentials}", usernameVariable: 'DH_Username', passwordVariable: 'DH_Password'] [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.DockerHubCredentials}", usernameVariable: 'DH_Username', passwordVariable: 'DH_Password']
]) { ]) {
myShCmd("echo ${DH_Password} | docker login --username ${DH_Username} --password-stdin", rem_u18_host_flag, rem_u18_host_user, rem_u18_host) myShCmd("echo ${DH_Password} | docker login --username ${DH_Username} --password-stdin", rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd("docker image tag oai-ausf:develop ${DH_Username}/oai-ausf:develop", rem_u18_host_flag, rem_u18_host_user, rem_u18_host) myShCmd("docker image tag oai-ausf:develop ${DH_Account}/oai-ausf:develop", rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd("docker push ${DH_Username}/oai-ausf:develop", rem_u18_host_flag, rem_u18_host_user, rem_u18_host) myShCmd("docker push ${DH_Account}/oai-ausf:develop", rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd("docker rmi ${DH_Username}/oai-ausf:develop", rem_u18_host_flag, rem_u18_host_user, rem_u18_host) myShCmd("docker rmi ${DH_Account}/oai-ausf:develop", rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd("docker logout", rem_u18_host_flag, rem_u18_host_user, rem_u18_host) myShCmd("docker logout", rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
} }
} }
......
...@@ -139,6 +139,16 @@ then ...@@ -139,6 +139,16 @@ then
exit 1 exit 1
fi fi
# When running in a container, in /home folder
IS_CONTAINER=`egrep -c "docker|kubepods|podman|buildah|libpod" /proc/self/cgroup || true`
if [ $IS_CONTAINER -ne 0 ]
then
if [ $PWD = "/home/src" ]
then
git config --global --add safe.directory /home
fi
fi
# Merge request scenario # Merge request scenario
MERGE_COMMMIT=`git log -n1 --pretty=format:%H` MERGE_COMMMIT=`git log -n1 --pretty=format:%H`
......
...@@ -36,7 +36,9 @@ RUN cp -Rf /openair-ausf-ext-ref /openair-ausf/build/ext ...@@ -36,7 +36,9 @@ RUN cp -Rf /openair-ausf-ext-ref /openair-ausf/build/ext
# Building AUSF # Building AUSF
WORKDIR /openair-ausf/build/scripts WORKDIR /openair-ausf/build/scripts
RUN ./build_ausf --clean --Verbose --build-type Release --jobs && \ RUN ldconfig && \
./build_ausf --clean --Verbose --build-type Release --jobs && \
ldd /openair-ausf/build/ausf/build/ausf && \
mv /openair-ausf/build/ausf/build/ausf /openair-ausf/build/ausf/build/oai_ausf mv /openair-ausf/build/ausf/build/ausf /openair-ausf/build/ausf/build/oai_ausf
#--------------------------------------------------------------------- #---------------------------------------------------------------------
...@@ -53,13 +55,13 @@ RUN apt-get update && \ ...@@ -53,13 +55,13 @@ RUN apt-get update && \
net-tools \ net-tools \
tzdata \ tzdata \
bc \ bc \
tshark \
perl \ perl \
libasan4 \ libasan4 \
libnettle6 \ libnettle6 \
libnghttp2-14 \ libnghttp2-14 \
libhogweed4 \ libhogweed4 \
libldap-2.4-2 \ libldap-2.4-2 \
libgssapi-krb5-2 \
librtmp1 \ librtmp1 \
libpsl5 \ libpsl5 \
libconfig++9v5 \ libconfig++9v5 \
...@@ -79,7 +81,8 @@ COPY --from=oai-ausf-builder \ ...@@ -79,7 +81,8 @@ COPY --from=oai-ausf-builder \
/usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4 \ /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4 \
/usr/local/lib/ /usr/local/lib/
RUN ldconfig RUN ldconfig && \
ldd /openair-ausf/bin/oai_ausf
WORKDIR /openair-ausf/etc WORKDIR /openair-ausf/etc
COPY --from=oai-ausf-builder /openair-ausf/etc/ausf.conf . COPY --from=oai-ausf-builder /openair-ausf/etc/ausf.conf .
......
"""
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
"""
import argparse
import re
import subprocess
import sys
def main() -> None:
args = _parse_args()
status = perform_flattening(args.tag)
sys.exit(status)
def _parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description='Flattening Image')
parser.add_argument(
'--tag', '-t',
action='store',
required=True,
help='Image Tag in image-name:image tag format',
)
return parser.parse_args()
def perform_flattening(tag):
# First detect which docker/podman command to use
cli = ''
image_prefix = ''
cmd = 'which podman || true'
podman_check = subprocess.check_output(cmd, shell=True, universal_newlines=True)
if re.search('podman', podman_check.strip()):
cli = 'sudo podman'
image_prefix = 'localhost/'
if cli == '':
cmd = 'which docker || true'
docker_check = subprocess.check_output(cmd, shell=True, universal_newlines=True)
if re.search('docker', docker_check.strip()):
cli = 'docker'
image_prefix = ''
if cli == '':
print ('No docker / podman installed: quitting')
return -1
print (f'Flattening {tag}')
# Creating a container
cmd = cli + ' run --name test-flatten --entrypoint /bin/true -d ' + tag
print (cmd)
subprocess.check_output(cmd, shell=True, universal_newlines=True)
# Export / Import trick
cmd = cli + ' export test-flatten | ' + cli + ' import '
# Bizarro syntax issue with podman
if cli == 'docker':
cmd += ' --change "ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" '
else:
cmd += ' --change "ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" '
cmd += ' --change "WORKDIR /openair-ausf" '
cmd += ' --change "EXPOSE 80/tcp" '
cmd += ' --change "CMD [\\"/openair-ausf/bin/oai_ausf\\", \\"-c\\", \\"/openair-ausf/etc/ausf.conf\\", \\"-o\\"]" '
cmd += ' --change "ENTRYPOINT [\\"/bin/bash\\", \\"/openair-ausf/bin/entrypoint.sh\\"]" '
cmd += ' - ' + image_prefix + tag
print (cmd)
subprocess.check_output(cmd, shell=True, universal_newlines=True)
# Remove container
cmd = cli + ' rm -f test-flatten'
print (cmd)
subprocess.check_output(cmd, shell=True, universal_newlines=True)
# At this point the original image is a dangling image.
# CI pipeline will clean up (`image prune --force`)
return 0
if __name__ == '__main__':
main()
...@@ -808,7 +808,7 @@ class HtmlReport(): ...@@ -808,7 +808,7 @@ class HtmlReport():
result = re.search('oai-ausf *ci-tmp', line) result = re.search('oai-ausf *ci-tmp', line)
else: else:
result = re.search('oai-ausf *develop', line) result = re.search('oai-ausf *develop', line)
if result is not None: if result is not None and not status:
if variant == 'docker': if variant == 'docker':
result = re.search('ago *([0-9A-Z]+)', line) result = re.search('ago *([0-9A-Z]+)', line)
else: else:
......
...@@ -32,8 +32,12 @@ FROM registry.access.redhat.com/ubi8/ubi:latest AS oai-ausf-builder ...@@ -32,8 +32,12 @@ FROM registry.access.redhat.com/ubi8/ubi:latest AS oai-ausf-builder
ARG NEEDED_GIT_PROXY ARG NEEDED_GIT_PROXY
COPY tmp/ca/redhat-uep.pem /etc/rhsm/ca # Copy the entitlements
COPY tmp/entitlement/*.pem /etc/pki/entitlement COPY ./etc-pki-entitlement /etc/pki/entitlement
# Copy the subscription manager configurations
COPY ./rhsm-conf /etc/rhsm
COPY ./rhsm-ca /etc/rhsm/ca
RUN rm -f /etc/rhsm-host && \ RUN rm -f /etc/rhsm-host && \
yum repolist --disablerepo=* && \ yum repolist --disablerepo=* && \
...@@ -81,12 +85,10 @@ RUN yum update -y && \ ...@@ -81,12 +85,10 @@ RUN yum update -y && \
psmisc \ psmisc \
net-tools \ net-tools \
nettle \ nettle \
libubsan \
libasan \ libasan \
liblsan \
libevent && \ libevent && \
yum clean all -y && \ yum clean all -y && \
rm -rf /var/cache/yum && \ rm -rf /var/cache/yum /var/cache/dnf && \
echo "/usr/local/lib" > /etc/ld.so.conf.d/local-lib.conf && \ echo "/usr/local/lib" > /etc/ld.so.conf.d/local-lib.conf && \
echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local-lib.conf echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local-lib.conf
......
...@@ -55,6 +55,7 @@ COPY . /openair-ausf ...@@ -55,6 +55,7 @@ COPY . /openair-ausf
WORKDIR /openair-ausf/build/scripts WORKDIR /openair-ausf/build/scripts
RUN ./build_ausf --install-deps --force RUN ./build_ausf --install-deps --force
RUN ./build_ausf --clean --Verbose --build-type Release --jobs && \ RUN ./build_ausf --clean --Verbose --build-type Release --jobs && \
ldd /openair-ausf/build/ausf/build/ausf && \
mv /openair-ausf/build/ausf/build/ausf /openair-ausf/build/ausf/build/oai_ausf mv /openair-ausf/build/ausf/build/ausf /openair-ausf/build/ausf/build/oai_ausf
#--------------------------------------------------------------------- #---------------------------------------------------------------------
...@@ -71,13 +72,13 @@ RUN apt-get update && \ ...@@ -71,13 +72,13 @@ RUN apt-get update && \
net-tools \ net-tools \
tzdata \ tzdata \
bc \ bc \
tshark \
perl \ perl \
libasan4 \ libasan4 \
libnettle6 \ libnettle6 \
libnghttp2-14 \ libnghttp2-14 \
libhogweed4 \ libhogweed4 \
libldap-2.4-2 \ libldap-2.4-2 \
libgssapi-krb5-2 \
librtmp1 \ librtmp1 \
libpsl5 \ libpsl5 \
libconfig++9v5 \ libconfig++9v5 \
...@@ -97,7 +98,8 @@ COPY --from=oai-ausf-builder \ ...@@ -97,7 +98,8 @@ COPY --from=oai-ausf-builder \
/usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4 \ /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4 \
/usr/local/lib/ /usr/local/lib/
RUN ldconfig RUN ldconfig && \
ldd /openair-ausf/bin/oai_ausf
WORKDIR /openair-ausf/etc WORKDIR /openair-ausf/etc
COPY --from=oai-ausf-builder /openair-ausf/etc/ausf.conf . COPY --from=oai-ausf-builder /openair-ausf/etc/ausf.conf .
......
/*
* 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
*/
/**
* Nausf_DataRepository API OpenAPI file
* Unified Data Repository Service. © 2020, 3GPP Organizational Partners (ARIB,
* ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 2.1.2
*
*
* NOTE: This class is auto generated by OpenAPI Generator
* (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/
#include "PatchItem.h"
#include <iostream>
using namespace std;
namespace oai {
namespace ausf_server {
namespace model {
PatchItem::PatchItem() {
m_Path = "";
m_From = "";
m_Value = "";
m_FromIsSet = false;
m_ValueIsSet = false;
}
PatchItem::~PatchItem() {}
void PatchItem::validate() {
// TODO: implement validation
}
void to_json(nlohmann::json& j, const PatchItem& o) {
j = nlohmann::json();
j["op"] = o.m_Op;
j["path"] = o.m_Path;
if (o.fromIsSet()) j["from"] = o.m_From;
if (o.valueIsSet()) j["value"] = o.m_Value;
}
void from_json(const nlohmann::json& j, PatchItem& o) {
j.at("op").get_to(o.m_Op);
j.at("path").get_to(o.m_Path);
if (j.find("from") != j.end()) {
j.at("from").get_to(o.m_From);
o.m_FromIsSet = true;
}
if (j.find("value") != j.end()) {
j.at("value").get_to(o.m_Value);
o.m_ValueIsSet = true;
}
}
std::string PatchItem::getOp() const {
return m_Op;
}
void PatchItem::setOp(std::string const& value) {
m_Op = value;
}
std::string PatchItem::getPath() const {
return m_Path;
}
void PatchItem::setPath(std::string const& value) {
m_Path = value;
}
std::string PatchItem::getFrom() const {
return m_From;
}
void PatchItem::setFrom(std::string const& value) {
m_From = value;
m_FromIsSet = true;
}
bool PatchItem::fromIsSet() const {
return m_FromIsSet;
}
void PatchItem::unsetFrom() {
m_FromIsSet = false;
}
std::string PatchItem::getValue() const {
return m_Value;
}
void PatchItem::setValue(std::string const& value) {
m_Value = value;
m_ValueIsSet = true;
}
bool PatchItem::valueIsSet() const {
return m_ValueIsSet;
}
void PatchItem::unsetValue() {
m_ValueIsSet = false;
}
} // namespace model
} // namespace ausf_server
} // namespace oai
/*
* 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
*/
/**
* Nausf_DataRepository API OpenAPI file
* Unified Data Repository Service. © 2020, 3GPP Organizational Partners (ARIB,
* ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 2.1.2
*
*
* NOTE: This class is auto generated by OpenAPI Generator
* (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/
/*
* PatchItem.h
*
*
*/
#ifndef PatchItem_H_
#define PatchItem_H_
#include <string>
#include "PatchOperation.h"
//#include "AnyType.h"
#include <nlohmann/json.hpp>
namespace oai {
namespace ausf_server {
namespace model {
/// <summary>
///
/// </summary>
class PatchItem {
public:
PatchItem();
virtual ~PatchItem();
void validate();
/////////////////////////////////////////////
/// PatchItem members
/// <summary>
///
/// </summary>
std::string getOp() const;
void setOp(std::string const& value);
/// <summary>
///
/// </summary>
std::string getPath() const;
void setPath(std::string const& value);
/// <summary>
///
/// </summary>
std::string getFrom() const;
void setFrom(std::string const& value);
bool fromIsSet() const;
void unsetFrom();
/// <summary>
///
/// </summary>
std::string getValue() const;
void setValue(std::string const& value);
bool valueIsSet() const;
void unsetValue();
friend void to_json(nlohmann::json& j, const PatchItem& o);
friend void from_json(const nlohmann::json& j, PatchItem& o);
protected:
std::string m_Op;
std::string m_Path;
std::string m_From;
bool m_FromIsSet;
std::string m_Value;
bool m_ValueIsSet;
};
} // namespace model
} // namespace ausf_server
} // namespace oai
#endif /* PatchItem_H_ */
/*
* 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
*/
/**
* Nausf_DataRepository API OpenAPI file
* Unified Data Repository Service. © 2020, 3GPP Organizational Partners (ARIB,
* ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 2.1.2
*
*
* NOTE: This class is auto generated by OpenAPI Generator
* (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/
#include "PatchOperation.h"
namespace oai {
namespace ausf_server {
namespace model {
PatchOperation::PatchOperation() {}
PatchOperation::~PatchOperation() {}
void PatchOperation::validate() {
// TODO: implement validation
}
void to_json(nlohmann::json& j, const PatchOperation& o) {
j = nlohmann::json();
}
void from_json(const nlohmann::json& j, PatchOperation& o) {}
} // namespace model
} // namespace ausf_server
} // namespace oai
/*
* 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
*/
/**
* NUDR_DataRepository API OpenAPI file
* Unified Data Repository Service. © 2020, 3GPP Organizational Partners (ARIB,
* ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 2.1.2
*
*
* NOTE: This class is auto generated by OpenAPI Generator
* (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/
/*
* PatchOperation.h
*
*
*/
#ifndef PatchOperation_H_
#define PatchOperation_H_
#include <nlohmann/json.hpp>
#define PATCH_OPERATION_ADD "add"
#define PATCH_OPERATION_COPY "copy"
#define PATCH_OPERATION_MOVE "move"
#define PATCH_OPERATION_REMOVE "remove"
#define PATCH_OPERATION_REPLACE "replace"
namespace oai {
namespace ausf_server {
namespace model {
/// <summary>
///
/// </summary>
class PatchOperation {
public:
PatchOperation();
virtual ~PatchOperation();
void validate();
/////////////////////////////////////////////
/// PatchOperation members
friend void to_json(nlohmann::json& j, const PatchOperation& o);
friend void from_json(const nlohmann::json& j, PatchOperation& o);
protected:
};
} // namespace model
} // namespace ausf_server
} // namespace oai
#endif /* PatchOperation_H_ */
...@@ -31,6 +31,8 @@ add_library (AUSF STATIC ...@@ -31,6 +31,8 @@ add_library (AUSF STATIC
ausf_app.cpp ausf_app.cpp
ausf_client.cpp ausf_client.cpp
ausf_config.cpp ausf_config.cpp
task_manager.cpp
ausf_event.cpp
ausf_profile.cpp ausf_profile.cpp
ausf_nrf.cpp ausf_nrf.cpp
) )
...@@ -30,21 +30,21 @@ ...@@ -30,21 +30,21 @@
#include "ausf_app.hpp" #include "ausf_app.hpp"
#include "ausf_nrf.hpp" #include "ausf_nrf.hpp"
#include <unistd.h>
#include "logger.hpp"
#include "ausf_client.hpp"
#include "ProblemDetails.h" #include "ProblemDetails.h"
#include "ausf_client.hpp"
#include "logger.hpp"
#include <unistd.h>
#include "conversions.hpp"
#include "sha256.hpp"
#include "UEAuthenticationCtx.h"
#include "ConfirmationDataResponse.h"
#include "AuthenticationInfo.h" #include "AuthenticationInfo.h"
#include "ConfirmationDataResponse.h"
#include "UEAuthenticationCtx.h"
#include "authentication_algorithms_with_5gaka.hpp" #include "authentication_algorithms_with_5gaka.hpp"
#include <string> #include "conversions.hpp"
#include "iostream" #include "iostream"
#include "sha256.hpp"
#include <algorithm> #include <algorithm>
#include <iterator> #include <iterator>
#include <string>
using namespace std; using namespace std;
using namespace oai::ausf::app; using namespace oai::ausf::app;
...@@ -56,8 +56,9 @@ extern ausf_config ausf_cfg; ...@@ -56,8 +56,9 @@ extern ausf_config ausf_cfg;
ausf_nrf* ausf_nrf_inst = nullptr; ausf_nrf* ausf_nrf_inst = nullptr;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
ausf_app::ausf_app(const std::string& config_file) ausf_app::ausf_app(const std::string& config_file, ausf_event& ev)
: contextId2security_context(), : event_sub(ev),
contextId2security_context(),
supi2security_context(), supi2security_context(),
imsi2security_context() { imsi2security_context() {
Logger::ausf_app().startup("Starting..."); Logger::ausf_app().startup("Starting...");
...@@ -70,7 +71,7 @@ ausf_app::ausf_app(const std::string& config_file) ...@@ -70,7 +71,7 @@ ausf_app::ausf_app(const std::string& config_file)
// Register to NRF // Register to NRF
if (ausf_cfg.register_nrf) { if (ausf_cfg.register_nrf) {
try { try {
ausf_nrf_inst = new ausf_nrf(); ausf_nrf_inst = new ausf_nrf(ev);
ausf_nrf_inst->register_to_nrf(); ausf_nrf_inst->register_to_nrf();
Logger::ausf_app().info("NRF TASK Created "); Logger::ausf_app().info("NRF TASK Created ");
} catch (std::exception& e) { } catch (std::exception& e) {
...@@ -384,7 +385,8 @@ void ausf_app::handle_ue_authentications_confirmation( ...@@ -384,7 +385,8 @@ void ausf_app::handle_ue_authentications_confirmation(
} }
Logger::ausf_app().info( Logger::ausf_app().info(
"Received authCtxId %s", authCtxId.c_str()); // authCtxId "Received authCtxId %s",
authCtxId.c_str()); // authCtxId
Logger::ausf_app().info( Logger::ausf_app().info(
"Received res* %s", confirmationData.getResStar().c_str()); "Received res* %s", confirmationData.getResStar().c_str());
...@@ -394,7 +396,8 @@ void ausf_app::handle_ue_authentications_confirmation( ...@@ -394,7 +396,8 @@ void ausf_app::handle_ue_authentications_confirmation(
ConfirmationDataResponse confirmResponse; ConfirmationDataResponse confirmResponse;
uint8_t authCtxId_seaf[16]; uint8_t authCtxId_seaf[16];
conv::hex_str_to_uint8( conv::hex_str_to_uint8(
authCtxId.c_str(), authCtxId_seaf); // authCtxId in SEAF authCtxId.c_str(),
authCtxId_seaf); // authCtxId in SEAF
Logger::ausf_app().debug( Logger::ausf_app().debug(
"authCtxId in AUSF: %s", "authCtxId in AUSF: %s",
......
...@@ -29,15 +29,16 @@ ...@@ -29,15 +29,16 @@
#ifndef FILE_AUSF_APP_HPP_SEEN #ifndef FILE_AUSF_APP_HPP_SEEN
#define FILE_AUSF_APP_HPP_SEEN #define FILE_AUSF_APP_HPP_SEEN
#include "ausf_event.hpp"
#include <string>
#include "AuthenticationInfo.h" #include "AuthenticationInfo.h"
#include "UEAuthenticationCtx.h"
#include "ConfirmationData.h" #include "ConfirmationData.h"
#include "UEAuthenticationCtx.h"
#include "ausf.h" #include "ausf.h"
#include <pistache/http.h>
#include <map> #include <map>
#include <pistache/http.h>
#include <shared_mutex> #include <shared_mutex>
#include <string>
namespace oai { namespace oai {
namespace ausf { namespace ausf {
...@@ -68,7 +69,7 @@ class security_context { ...@@ -68,7 +69,7 @@ class security_context {
// class ausf_config; // class ausf_config;
class ausf_app { class ausf_app {
public: public:
explicit ausf_app(const std::string& config_file); explicit ausf_app(const std::string& config_file, ausf_event& ev);
ausf_app(ausf_app const&) = delete; ausf_app(ausf_app const&) = delete;
void operator=(ausf_app const&) = delete; void operator=(ausf_app const&) = delete;
...@@ -96,6 +97,7 @@ class ausf_app { ...@@ -96,6 +97,7 @@ class ausf_app {
const std::string& contextId, std::shared_ptr<security_context> sc); const std::string& contextId, std::shared_ptr<security_context> sc);
private: private:
ausf_event& event_sub;
std::map<supi64_t, std::shared_ptr<security_context>> imsi2security_context; std::map<supi64_t, std::shared_ptr<security_context>> imsi2security_context;
mutable std::shared_mutex m_imsi2security_context; mutable std::shared_mutex m_imsi2security_context;
......
...@@ -30,13 +30,13 @@ ...@@ -30,13 +30,13 @@
#include "ausf_client.hpp" #include "ausf_client.hpp"
#include <curl/curl.h> #include <curl/curl.h>
#include <nlohmann/json.hpp>
#include <pistache/http.h> #include <pistache/http.h>
#include <pistache/mime.h> #include <pistache/mime.h>
#include <nlohmann/json.hpp>
#include <stdexcept> #include <stdexcept>
#include "logger.hpp"
#include "ausf.h" #include "ausf.h"
#include "logger.hpp"
using namespace Pistache::Http; using namespace Pistache::Http;
using namespace Pistache::Http::Mime; using namespace Pistache::Http::Mime;
......
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
#include <curl/curl.h> #include <curl/curl.h>
#include "logger.hpp"
#include "ausf_config.hpp" #include "ausf_config.hpp"
#include "logger.hpp"
namespace oai { namespace oai {
namespace ausf { namespace ausf {
......
...@@ -28,13 +28,13 @@ ...@@ -28,13 +28,13 @@
#include "ausf_config.hpp" #include "ausf_config.hpp"
#include "string.hpp"
#include <iostream> #include <iostream>
#include <libconfig.h++> #include <libconfig.h++>
#include "string.hpp"
#include "logger.hpp"
#include "if.hpp"
#include "fqdn.hpp" #include "fqdn.hpp"
#include "if.hpp"
#include "logger.hpp"
#include "string.hpp" #include "string.hpp"
...@@ -347,7 +347,7 @@ void ausf_config::display() { ...@@ -347,7 +347,7 @@ void ausf_config::display() {
if (use_fqdn_dns) if (use_fqdn_dns)
Logger::config().info( Logger::config().info(
" FQDN .................: %s", udm_addr.fqdn.c_str()); " FQDN .................: %s", nrf_addr.fqdn.c_str());
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
...@@ -33,11 +33,11 @@ ...@@ -33,11 +33,11 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#include <libconfig.h++> #include <libconfig.h++>
#include <mutex>
#include <netinet/in.h> #include <netinet/in.h>
#include <string>
#include <sys/socket.h> #include <sys/socket.h>
#include <mutex>
#include <vector> #include <vector>
#include <string>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/classification.hpp>
......
/*
* 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
*/
/*! \file ausf_event.cpp
\brief
\author Tien-Thinh NGUYEN (EURECOM)
\company
\date 2022
\email: contact@openairinterface.org
*/
#include "ausf_event.hpp"
using namespace oai::ausf::app;
bs2::connection ausf_event::subscribe_task_nf_heartbeat(
const task_sig_t::slot_type& sig, uint64_t period, uint64_t start) {
/* Wrap the actual callback in a lambda. The latter checks whether the
* current time is after start time, and ensures that the callback is only
* called every X ms with X being the period time. This way, it is possible
* to register to be notified every X ms instead of every ms, which provides
* greater freedom to implementations. */
auto f = [period, start, sig](uint64_t t) {
if (t >= start && (t - start) % period == 0) sig(t);
};
return task_tick.connect(f);
}
//------------------------------------------------------------------------------
bs2::connection ausf_event::subscribe_loss_of_connectivity(
const loss_of_connectivity_sig_t::slot_type& sig) {
return loss_of_connectivity.connect(sig);
}
//------------------------------------------------------------------------------
bs2::connection ausf_event::subscribe_ue_reachability_for_data(
const ue_reachability_for_data_sig_t::slot_type& sig) {
return ue_reachability_for_data.connect(sig);
}
/*
* 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
*/
/*! \file ausf_event.hpp
\brief
\author Tien-Thinh NGUYEN (EURECOM)
\company
\date 2022
\email: contact@openairinterface.org
*/
#ifndef FILE_AUSF_EVENT_HPP_SEEN
#define FILE_AUSF_EVENT_HPP_SEEN
#include <boost/signals2.hpp>
namespace bs2 = boost::signals2;
#include "ausf.h"
#include "ausf_event_sig.hpp"
#include "task_manager.hpp"
namespace oai::ausf::app {
class task_manager;
class ausf_event {
public:
ausf_event(){};
ausf_event(ausf_event const&) = delete;
void operator=(ausf_event const&) = delete;
static ausf_event& get_instance() {
static ausf_event instance;
return instance;
}
// class register/handle event
friend class ausf_app;
friend class ausf_nrf;
friend class task_manager;
//------------------------------------------------------------------------------
/*
* Subscribe to the task tick event
* @param [const task_sig_t::slot_type &] sig
* @param [uint64_t] period: interval between two events
* @param [uint64_t] start:
* @return void
*/
bs2::connection subscribe_task_nf_heartbeat(
const task_sig_t::slot_type& sig, uint64_t period, uint64_t start = 0);
//------------------------------------------------------------------------------
/*
* Subscribe to UE Loss of Connectivity Status signal
* @param [const loss_of_connectivity_sig_t::slot_type&] sig: slot_type
* parameter
* @return boost::signals2::connection: the connection between the signal and
* the slot
*/
bs2::connection subscribe_loss_of_connectivity(
const loss_of_connectivity_sig_t::slot_type& sig);
/*
* Subscribe to UE Reachability for Data signal
* @param [const ue_reachability_for_data_sig_t::slot_type&] sig: slot_type
* parameter
* @return boost::signals2::connection: the connection between the signal and
* the slot
*/
bs2::connection subscribe_ue_reachability_for_data(
const ue_reachability_for_data_sig_t::slot_type& sig);
private:
task_sig_t task_tick;
loss_of_connectivity_sig_t
loss_of_connectivity; // Signal for Loss of Connectivity Report
ue_reachability_for_data_sig_t
ue_reachability_for_data; // Signal for UE Reachability for Data Report
};
} // namespace oai::ausf::app
#endif
/*
* 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
*/
/*! \file ausf_event_sig.hpp
\brief
\author Tien-Thinh NGUYEN (EURECOM)
\company
\date 2022
\email: contact@openairinterface.org
*/
#ifndef FILE_AUSF_EVENT_SIG_HPP_SEEN
#define FILE_AUSF_EVENT_SIG_HPP_SEEN
#include <boost/signals2.hpp>
#include <string>
namespace bs2 = boost::signals2;
namespace oai::ausf::app {
typedef bs2::signal_type<
void(uint64_t), bs2::keywords::mutex_type<bs2::dummy_mutex>>::type
task_sig_t;
// Signal for Loss of Connectivity
// SUPI, Connectivity status, HTTP version
typedef bs2::signal_type<
void(std::string, uint8_t, uint8_t),
bs2::keywords::mutex_type<bs2::dummy_mutex>>::type
loss_of_connectivity_sig_t;
// Signal for UE Reachability for Data
// SUPI, Reachability status, HTTP version
typedef bs2::signal_type<
void(std::string, uint8_t, uint8_t),
bs2::keywords::mutex_type<bs2::dummy_mutex>>::type
ue_reachability_for_data_sig_t;
// UE_REACHABILITY_FOR_SMS
// LOCATION_REPORTING
// CHANGE_OF_SUPI_PEI_ASSOCIATION
// ROAMING_STATUS
// COMMUNICATION_FAILURE
// AVAILABILITY_AFTER_DNN_FAILURE
// CN_TYPE_CHANGE
} // namespace oai::ausf::app
#endif
...@@ -29,19 +29,19 @@ ...@@ -29,19 +29,19 @@
#include "ausf_nrf.hpp" #include "ausf_nrf.hpp"
#include "ausf_app.hpp" #include "ausf_app.hpp"
#include "ausf_profile.hpp"
#include "ausf_client.hpp" #include "ausf_client.hpp"
#include "ausf_profile.hpp"
#include <boost/uuid/random_generator.hpp> #include <boost/uuid/random_generator.hpp>
#include <boost/uuid/uuid_io.hpp> #include <boost/uuid/uuid_io.hpp>
#include <curl/curl.h> #include <curl/curl.h>
#include <nlohmann/json.hpp>
#include <pistache/http.h> #include <pistache/http.h>
#include <pistache/mime.h> #include <pistache/mime.h>
#include <nlohmann/json.hpp>
#include <stdexcept> #include <stdexcept>
#include "logger.hpp"
#include "ausf.h" #include "ausf.h"
#include "logger.hpp"
using namespace config; using namespace config;
// using namespace ausf; // using namespace ausf;
...@@ -54,7 +54,7 @@ extern ausf_nrf* ausf_nrf_inst; ...@@ -54,7 +54,7 @@ extern ausf_nrf* ausf_nrf_inst;
ausf_client* ausf_client_instance = nullptr; ausf_client* ausf_client_instance = nullptr;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
ausf_nrf::ausf_nrf() {} ausf_nrf::ausf_nrf(ausf_event& ev) : m_event_sub(ev) {}
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
void ausf_nrf::get_ausf_api_root(std::string& api_root) { void ausf_nrf::get_ausf_api_root(std::string& api_root) {
api_root = std::string( api_root = std::string(
...@@ -95,7 +95,6 @@ void ausf_nrf::generate_ausf_profile( ...@@ -95,7 +95,6 @@ void ausf_nrf::generate_ausf_profile(
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
void ausf_nrf::register_to_nrf() { void ausf_nrf::register_to_nrf() {
// generate UUID // generate UUID
std::string ausf_instance_id; // AUSF instance id
ausf_instance_id = to_string(boost::uuids::random_generator()()); ausf_instance_id = to_string(boost::uuids::random_generator()());
nlohmann::json response_data = {}; nlohmann::json response_data = {};
...@@ -119,11 +118,57 @@ void ausf_nrf::register_to_nrf() { ...@@ -119,11 +118,57 @@ void ausf_nrf::register_to_nrf() {
try { try {
response_data = nlohmann::json::parse(response); response_data = nlohmann::json::parse(response);
if (response_data["nfStatus"].dump().c_str() == "REGISTERED") { response_data = nlohmann::json::parse(response);
// ToDo Trigger NF heartbeats if (response.find("REGISTERED") != 0) {
start_event_nf_heartbeat(remoteUri);
} }
} catch (nlohmann::json::exception& e) { } catch (nlohmann::json::exception& e) {
Logger::ausf_nrf().info("NF registeration procedure failed"); Logger::ausf_nrf().info("NF registeration procedure failed");
} }
} }
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
void ausf_nrf::start_event_nf_heartbeat(std::string& remoteURI) {
// get current time
uint64_t ms = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count();
struct itimerspec its;
its.it_value.tv_sec = HEART_BEAT_TIMER; // seconds
its.it_value.tv_nsec = 0; // 100 * 1000 * 1000; //100ms
const uint64_t interval =
its.it_value.tv_sec * 1000 +
its.it_value.tv_nsec / 1000000; // convert sec, nsec to msec
task_connection = m_event_sub.subscribe_task_nf_heartbeat(
boost::bind(&ausf_nrf::trigger_nf_heartbeat_procedure, this, _1),
interval, ms + interval);
}
//---------------------------------------------------------------------------------------------
void ausf_nrf::trigger_nf_heartbeat_procedure(uint64_t ms) {
_unused(ms);
oai::ausf_server::model::PatchItem patch_item = {};
std::vector<oai::ausf_server::model::PatchItem> patch_items;
//{"op":"replace","path":"/nfStatus", "value": "REGISTERED"}
patch_item.setOp("replace");
patch_item.setPath("/nfStatus");
patch_item.setValue("REGISTERED");
patch_items.push_back(patch_item);
Logger::ausf_nrf().info("Sending NF heartbeat request");
std::string response = {};
std::string method = {"PATCH"};
nlohmann::json json_data = nlohmann::json::array();
for (auto i : patch_items) {
nlohmann::json item = {};
to_json(item, i);
json_data.push_back(item);
}
std::string ausf_api_root = {};
get_ausf_api_root(ausf_api_root);
std::string remoteUri =
ausf_api_root + AUSF_NF_REGISTER_URL + ausf_instance_id;
ausf_client_instance->curl_http_client(
remoteUri, method, json_data.dump().c_str(), response);
if (!response.empty()) task_connection.disconnect();
}
\ No newline at end of file
...@@ -34,9 +34,13 @@ ...@@ -34,9 +34,13 @@
#include <curl/curl.h> #include <curl/curl.h>
#include "logger.hpp" #include "PatchItem.h"
#include "ausf_config.hpp" #include "ausf_config.hpp"
#include "ausf_event.hpp"
#include "ausf_profile.hpp" #include "ausf_profile.hpp"
#include "logger.hpp"
using namespace oai::ausf_server::model;
namespace oai { namespace oai {
namespace ausf { namespace ausf {
...@@ -49,12 +53,23 @@ class ausf_nrf { ...@@ -49,12 +53,23 @@ class ausf_nrf {
std::string ausf_instance_id; // AUSF instance id std::string ausf_instance_id; // AUSF instance id
// timer_id_t timer_ausf_heartbeat; // timer_id_t timer_ausf_heartbeat;
ausf_nrf(); ausf_nrf(ausf_event& ev);
ausf_nrf(ausf_nrf const&) = delete; ausf_nrf(ausf_nrf const&) = delete;
void operator=(ausf_nrf const&) = delete; void operator=(ausf_nrf const&) = delete;
void generate_uuid(); void generate_uuid();
/*
* Start event nf heartbeat procedure
* @param [void]
* @return void
*/
void start_event_nf_heartbeat(std::string& remoteURI);
/*
* Trigger NF heartbeat procedure
* @param [void]
* @return void
*/
void trigger_nf_heartbeat_procedure(uint64_t ms);
/* /*
* Generate a AUSF profile for this instance * Generate a AUSF profile for this instance
* @param [void] * @param [void]
...@@ -75,6 +90,10 @@ class ausf_nrf { ...@@ -75,6 +90,10 @@ class ausf_nrf {
* @return void * @return void
*/ */
void get_ausf_api_root(std::string& api_root); void get_ausf_api_root(std::string& api_root);
private:
ausf_event& m_event_sub;
bs2::connection task_connection;
}; };
} // namespace app } // namespace app
} // namespace ausf } // namespace ausf
......
...@@ -30,8 +30,8 @@ ...@@ -30,8 +30,8 @@
#include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp> #include <boost/algorithm/string/split.hpp>
#include "logger.hpp"
#include "ausf_profile.hpp" #include "ausf_profile.hpp"
#include "logger.hpp"
#include "string.hpp" #include "string.hpp"
// using namespace ausf; // using namespace ausf;
......
...@@ -36,9 +36,9 @@ ...@@ -36,9 +36,9 @@
#include <shared_mutex> #include <shared_mutex>
#include <vector> #include <vector>
#include "logger.hpp"
#include "3gpp_29.510.h" #include "3gpp_29.510.h"
#include "ausf.h" #include "ausf.h"
#include "logger.hpp"
namespace oai { namespace oai {
namespace ausf { namespace ausf {
......
/*
* 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
*/
/*! \file task_manager.cpp
\brief
\author
\company Eurecom
\date 2020
\email: Tien-Thinh.Nguyen@eurecom.fr
*/
#include "task_manager.hpp"
#include <iostream>
#include <thread>
#include <unistd.h>
#include "logger.hpp"
using namespace oai::ausf::app;
//------------------------------------------------------------------------------
task_manager::task_manager(ausf_event& ev) : event_sub_(ev) {
struct itimerspec its;
sfd = timerfd_create(CLOCK_MONOTONIC, 0);
/* Start the timer */
its.it_value.tv_sec = 0;
its.it_value.tv_nsec = 1000 * 1000;
its.it_interval.tv_sec = its.it_value.tv_sec;
its.it_interval.tv_nsec = its.it_value.tv_nsec;
if (timerfd_settime(sfd, TFD_TIMER_ABSTIME, &its, NULL) == -1) {
Logger::ausf_app().error("Failed to set timer for task manager");
}
}
//------------------------------------------------------------------------------
void task_manager::run() {
manage_tasks();
}
//------------------------------------------------------------------------------
void task_manager::manage_tasks() {
// starting from current time
uint64_t t = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count();
while (1) {
event_sub_.task_tick(t);
t++;
wait_for_cycle();
}
}
//------------------------------------------------------------------------------
void task_manager::wait_for_cycle() {
uint64_t exp;
ssize_t res;
if (sfd > 0) {
res = read(sfd, &exp, sizeof(exp));
if ((res < 0) || (res != sizeof(exp))) {
Logger::ausf_app().error("Failed in task manager timer wait");
}
}
}
/*
* 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
*/
/*! \file task_manager.hpp
\brief
\author
\company Eurecom
\date 2020
\email: Tien-Thinh.Nguyen@eurecom.fr
*/
#ifndef TASK_MANAGER_H_
#define TASK_MANAGER_H_
#include "ausf_event.hpp"
#include <linux/types.h>
#include <sys/timerfd.h>
using namespace oai::ausf::app;
namespace oai {
namespace ausf {
namespace app {
class ausf_event;
class task_manager {
public:
task_manager(ausf_event& ev);
/*
* Manage the tasks
* @param [void]
* @return void
*/
void manage_tasks();
/*
* Run the tasks (for the moment, simply call function manage_tasks)
* @param [void]
* @return void
*/
void run();
private:
/*
* Make sure that the task tick run every 1ms
* @param [void]
* @return void
*/
void wait_for_cycle();
ausf_event& event_sub_;
int sfd;
};
} // namespace app
} // namespace ausf
} // namespace oai
#endif
...@@ -26,6 +26,9 @@ ...@@ -26,6 +26,9 @@
#define _unused(x) ((void) (x)) #define _unused(x) ((void) (x))
#define NNRF_NFM_BASE "/nnrf-nfm/"
#define AUSF_NF_REGISTER_URL "/nf-instances/"
typedef enum nf_type_s { typedef enum nf_type_s {
NF_TYPE_NRF = 0, NF_TYPE_NRF = 0,
NF_TYPE_AMF = 1, NF_TYPE_AMF = 1,
......
...@@ -28,6 +28,7 @@ bool fqdn::resolve( ...@@ -28,6 +28,7 @@ bool fqdn::resolve(
const std::string& host_name, std::string& address, uint32_t& port, const std::string& host_name, std::string& address, uint32_t& port,
uint8_t& addr_type, const std::string& protocol) { uint8_t& addr_type, const std::string& protocol) {
try { try {
Logger::ausf_app().debug("Resolving DNS:- %s", host_name.c_str());
boost::asio::io_context io_context = {}; boost::asio::io_context io_context = {};
boost::asio::ip::tcp::resolver resolver{io_context}; boost::asio::ip::tcp::resolver resolver{io_context};
......
...@@ -14,11 +14,11 @@ ...@@ -14,11 +14,11 @@
* limitations under the License. * limitations under the License.
*/ */
#include "logger.hpp"
#include "ausf-api-server.h" #include "ausf-api-server.h"
#include "ausf-http2-server.h" #include "ausf-http2-server.h"
#include "ausf_config.hpp"
#include "ausf_app.hpp" #include "ausf_app.hpp"
#include "ausf_config.hpp"
#include "logger.hpp"
#include "options.hpp" #include "options.hpp"
#include "pid_file.hpp" #include "pid_file.hpp"
...@@ -26,12 +26,12 @@ ...@@ -26,12 +26,12 @@
#include "pistache/http.h" #include "pistache/http.h"
#include "pistache/router.h" #include "pistache/router.h"
#include <iostream>
#include <signal.h> #include <signal.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> // srand #include <stdlib.h> // srand
#include <unistd.h> // get_pid(), pause()
#include <iostream>
#include <thread> #include <thread>
#include <unistd.h> // get_pid(), pause()
using namespace oai::ausf::app; using namespace oai::ausf::app;
using namespace util; using namespace util;
...@@ -87,12 +87,19 @@ int main(int argc, char** argv) { ...@@ -87,12 +87,19 @@ int main(int argc, char** argv) {
sigIntHandler.sa_flags = 0; sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL); sigaction(SIGINT, &sigIntHandler, NULL);
// Event subsystem
ausf_event ev;
// Config // Config
ausf_cfg.load(Options::getlibconfigConfig()); ausf_cfg.load(Options::getlibconfigConfig());
ausf_cfg.display(); ausf_cfg.display();
// AUSF application layer // AUSF application layer
ausf_app_inst = new ausf_app(Options::getlibconfigConfig()); ausf_app_inst = new ausf_app(Options::getlibconfigConfig(), ev);
// Task Manager
task_manager tm(ev);
std::thread task_manager_thread(&task_manager::run, &tm);
// PID file // PID file
// Currently hard-coded value. TODO: add as config option. // Currently hard-coded value. TODO: add as config option.
......
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