Commit 92b8a6b5 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen
Browse files

Example for NF registration

parent ff4d54ef
......@@ -13,6 +13,7 @@
#include "NFInstanceIDDocumentApi.h"
#include "Helpers.h"
#include "nrf_config.hpp"
#include "logger.hpp"
extern oai::nrf::nrf_config nrf_cfg;
......
......@@ -57,7 +57,7 @@ public:
virtual ~NFInstancesStoreApi() {}
void init();
const std::string base = "/nnrf-disc/v1";
const std::string base = "/nnrf-disc/";
private:
void setupRoutes();
......
......@@ -40,7 +40,7 @@ public:
virtual ~StoredSearchDocumentApi() {}
void init();
const std::string base = "/nnrf-disc/v1";
const std::string base = "/nnrf-disc/";
private:
void setupRoutes();
......
......@@ -43,7 +43,7 @@ public:
virtual ~SubscriptionIDDocumentApi() {}
void init();
const std::string base = "/nnrf-nfm/v1";
const std::string base = "/nnrf-nfm/";
private:
void setupRoutes();
......
......@@ -40,7 +40,7 @@ public:
virtual ~SubscriptionsCollectionApi() {}
void init();
const std::string base = "/nnrf-nfm/v1";
const std::string base = "/nnrf-nfm/";
private:
void setupRoutes();
......
......@@ -11,6 +11,8 @@
*/
#include "NFInstanceIDDocumentApiImpl.h"
#include "logger.hpp"
#include "nrf_app.hpp"
namespace oai {
namespace nrf {
......@@ -32,7 +34,15 @@ void NFInstanceIDDocumentApiImpl::get_nf_instance(const std::string &nfInstanceI
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
}
void NFInstanceIDDocumentApiImpl::register_nf_instance(const std::string &nfInstanceID, const NFProfile &nFProfile, const Pistache::Optional<Pistache::Http::Header::Raw> &contentEncoding, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
Logger::nrf_sbi().info("Got a request to register an NF instance, Instance ID: %s", nfInstanceID.c_str());
NFProfile nf_profile = nFProfile;
int http_code = 0;
m_nrf_app->handle_nf_instance_registration_request(nfInstanceID, nf_profile, http_code, 1);
nlohmann::json json_data = { };
to_json(json_data, nf_profile);
response.send(Pistache::Http::Code::Ok, json_data.dump().c_str());
}
void NFInstanceIDDocumentApiImpl::update_nf_instance(const std::string &nfInstanceID, const std::vector<PatchItem> &patchItem, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
......
......@@ -83,8 +83,9 @@ void NRFApiServer::init(size_t thr) {
m_completeStoredSearchDocumentApiImpl->init();
m_nfInstancesStoreApiImpl->init();
m_storedSearchDocumentApiImpl->init();
m_nfInstanceIDDocumentApiImpl->init();
m_subscriptionIDDocumentApiImpl->init();
m_subscriptionsCollectionApiImpl->init();
}
void NRFApiServer::start() {
Logger::nrf_sbi().info("HTTP1 server started");
......
......@@ -46,6 +46,10 @@
#include "CompleteStoredSearchDocumentApiImpl.h"
#include "NFInstancesStoreApiImpl.h"
#include "StoredSearchDocumentApiImpl.h"
#include "NFInstanceIDDocumentApiImpl.h"
#include "SubscriptionIDDocumentApiImpl.h"
#include "SubscriptionsCollectionApiImpl.h"
#include "nrf_app.hpp"
using namespace oai::nrf::api;
......@@ -63,20 +67,26 @@ class NRFApiServer {
m_router, nrf_app_inst, m_address);
m_storedSearchDocumentApiImpl = std::make_shared<
StoredSearchDocumentApiImpl>(m_router, nrf_app_inst, m_address);
m_nfInstanceIDDocumentApiImpl = std::make_shared<
NFInstanceIDDocumentApiImpl>(m_router, nrf_app_inst, m_address);
m_subscriptionIDDocumentApiImpl = std::make_shared<
SubscriptionIDDocumentApiImpl>(m_router, nrf_app_inst, m_address);
m_subscriptionsCollectionApiImpl = std::make_shared<
SubscriptionsCollectionApiImpl>(m_router, nrf_app_inst, m_address);
}
void init(size_t thr = 1);
void start();
void shutdown();
private:
std::shared_ptr<Pistache::Http::Endpoint> m_httpEndpoint;
std::shared_ptr<Pistache::Rest::Router> m_router;
std::shared_ptr<CompleteStoredSearchDocumentApiImpl> m_completeStoredSearchDocumentApiImpl;
std::shared_ptr<NFInstancesStoreApiImpl> m_nfInstancesStoreApiImpl;
std::shared_ptr<StoredSearchDocumentApiImpl> m_storedSearchDocumentApiImpl;
std::shared_ptr<NFInstanceIDDocumentApiImpl> m_nfInstanceIDDocumentApiImpl;
std::shared_ptr<SubscriptionIDDocumentApiImpl> m_subscriptionIDDocumentApiImpl;
std::shared_ptr<SubscriptionsCollectionApiImpl> m_subscriptionsCollectionApiImpl;
std::string m_address;
};
......
......@@ -21,10 +21,10 @@
/*! \file nrf_app.cpp
\brief
\author Lionel GAUTHIER, Tien-Thinh NGUYEN
\author Tien-Thinh NGUYEN
\company Eurecom
\date 2019
\email: lionel.gauthier@eurecom.fr, tien-thinh.nguyen@eurecom.fr
\date 2020
\email: tien-thinh.nguyen@eurecom.fr
*/
#include "nrf_app.hpp"
......@@ -38,9 +38,19 @@ extern nrf_app *nrf_app_inst;
extern nrf_config nrf_cfg;
//------------------------------------------------------------------------------
nrf_app::nrf_app(const std::string &config_file)
{
nrf_app::nrf_app(const std::string &config_file) {
Logger::nrf_app().startup("Starting...");
Logger::nrf_app().startup("Started");
}
void nrf_app::handle_nf_instance_registration_request(
const std::string &nfInstanceID,
oai::nrf::model::NFProfile &nf_profile,
int &http_code,
const uint8_t http_version) {
Logger::nrf_app().info(
"Handle a NF Instance Registration Request (HTTP version %d)",
http_version);
}
......@@ -19,20 +19,21 @@
* contact@openairinterface.org
*/
/*! \file smf_app.hpp
/*! \file nrf_app.hpp
\brief
\author Lionel GAUTHIER, Tien-Thinh NGUYEN
\author Tien-Thinh NGUYEN
\company Eurecom
\date 2019
\email: lionel.gauthier@eurecom.fr, tien-thinh.nguyen@eurecom.fr
\date 2020
\email: tien-thinh.nguyen@eurecom.fr
*/
#ifndef FILE_NRF_APP_HPP_SEEN
#define FILE_NRF_APP_HPP_SEEN
#include <string>
#include "NFProfile.h"
namespace oai{
namespace oai {
namespace nrf {
class nrf_config;
class nrf_app {
......@@ -42,6 +43,12 @@ class nrf_app {
nrf_app(nrf_app const&) = delete;
void operator=(nrf_app const&) = delete;
void handle_nf_instance_registration_request(
const std::string &nfInstanceID,
oai::nrf::model::NFProfile &nf_profile,
int &http_code,
const uint8_t http_version);
};
}
}
......
......@@ -23,7 +23,7 @@
* \brief
\author Lionel GAUTHIER, Tien-Thinh NGUYEN
\company Eurecom
\date 2019
\date 2020
\email: lionel.gauthier@eurecom.fr, tien-thinh.nguyen@eurecom.fr
*/
......
curl -X PUT -H "Content-Type: application/json" -d @registration.json http://192.168.1.88/nnrf-nfm/v1/nf-instances/343a924e-6494-4927-860b-d45692c95c2d
{
"_comment" : "NRF Profile",
"nfInstanceId" : "343a924e-6494-4927-860b-d45692c95c2d",
"nfType" : "AMF",
"nfStatus" : "REGISTERED",
"heartBeatTimer": 10,
"amfInfo":
{
"amfSetId" : "1a1a",
"amfRegionId": "AA",
"guamiList": [
{
"plmnId":
{
"mcc": "208",
"mnc": "95"
},
"amfId": "AAAAAA"
}
]
}
}
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