Commit ff4d54ef authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

add API version

parent f2a28bd2
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
#include "CompleteStoredSearchDocumentApi.h" #include "CompleteStoredSearchDocumentApi.h"
#include "Helpers.h" #include "Helpers.h"
#include "nrf_config.hpp"
extern oai::nrf::nrf_config nrf_cfg;
namespace oai { namespace oai {
namespace nrf { namespace nrf {
...@@ -31,7 +34,7 @@ void CompleteStoredSearchDocumentApi::init() { ...@@ -31,7 +34,7 @@ void CompleteStoredSearchDocumentApi::init() {
void CompleteStoredSearchDocumentApi::setupRoutes() { void CompleteStoredSearchDocumentApi::setupRoutes() {
using namespace Pistache::Rest; using namespace Pistache::Rest;
Routes::Get(*router, base + "/searches/:searchId/complete", Routes::bind(&CompleteStoredSearchDocumentApi::retrieve_complete_search_handler, this)); Routes::Get(*router, base + nrf_cfg.sbi_api_version + "/searches/:searchId/complete", Routes::bind(&CompleteStoredSearchDocumentApi::retrieve_complete_search_handler, this));
// Default handler, called when a route is not found // Default handler, called when a route is not found
router->addCustomHandler(Routes::bind(&CompleteStoredSearchDocumentApi::complete_stored_search_document_api_default_handler, this)); router->addCustomHandler(Routes::bind(&CompleteStoredSearchDocumentApi::complete_stored_search_document_api_default_handler, this));
......
...@@ -40,7 +40,7 @@ public: ...@@ -40,7 +40,7 @@ public:
virtual ~CompleteStoredSearchDocumentApi() {} virtual ~CompleteStoredSearchDocumentApi() {}
void init(); void init();
const std::string base = "/nnrf-disc/v1"; const std::string base = "/nnrf-disc/";
private: private:
void setupRoutes(); void setupRoutes();
......
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
#include "NFInstanceIDDocumentApi.h" #include "NFInstanceIDDocumentApi.h"
#include "Helpers.h" #include "Helpers.h"
#include "nrf_config.hpp"
extern oai::nrf::nrf_config nrf_cfg;
namespace oai { namespace oai {
namespace nrf { namespace nrf {
...@@ -31,10 +34,10 @@ void NFInstanceIDDocumentApi::init() { ...@@ -31,10 +34,10 @@ void NFInstanceIDDocumentApi::init() {
void NFInstanceIDDocumentApi::setupRoutes() { void NFInstanceIDDocumentApi::setupRoutes() {
using namespace Pistache::Rest; using namespace Pistache::Rest;
Routes::Delete(*router, base + "/nf-instances/:nfInstanceID", Routes::bind(&NFInstanceIDDocumentApi::deregister_nf_instance_handler, this)); Routes::Delete(*router, base + nrf_cfg.sbi_api_version + "/nf-instances/:nfInstanceID", Routes::bind(&NFInstanceIDDocumentApi::deregister_nf_instance_handler, this));
Routes::Get(*router, base + "/nf-instances/:nfInstanceID", Routes::bind(&NFInstanceIDDocumentApi::get_nf_instance_handler, this)); Routes::Get(*router, base + nrf_cfg.sbi_api_version + "/nf-instances/:nfInstanceID", Routes::bind(&NFInstanceIDDocumentApi::get_nf_instance_handler, this));
Routes::Put(*router, base + "/nf-instances/:nfInstanceID", Routes::bind(&NFInstanceIDDocumentApi::register_nf_instance_handler, this)); Routes::Put(*router, base + nrf_cfg.sbi_api_version + "/nf-instances/:nfInstanceID", Routes::bind(&NFInstanceIDDocumentApi::register_nf_instance_handler, this));
Routes::Patch(*router, base + "/nf-instances/:nfInstanceID", Routes::bind(&NFInstanceIDDocumentApi::update_nf_instance_handler, this)); Routes::Patch(*router, base + nrf_cfg.sbi_api_version + "/nf-instances/:nfInstanceID", Routes::bind(&NFInstanceIDDocumentApi::update_nf_instance_handler, this));
// Default handler, called when a route is not found // Default handler, called when a route is not found
router->addCustomHandler(Routes::bind(&NFInstanceIDDocumentApi::nf_instance_id_document_api_default_handler, this)); router->addCustomHandler(Routes::bind(&NFInstanceIDDocumentApi::nf_instance_id_document_api_default_handler, this));
......
...@@ -43,7 +43,7 @@ public: ...@@ -43,7 +43,7 @@ public:
virtual ~NFInstanceIDDocumentApi() {} virtual ~NFInstanceIDDocumentApi() {}
void init(); void init();
const std::string base = "/nnrf-nfm/v1"; const std::string base = "/nnrf-nfm/";
private: private:
void setupRoutes(); void setupRoutes();
......
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
#include "NFInstancesStoreApi.h" #include "NFInstancesStoreApi.h"
#include "Helpers.h" #include "Helpers.h"
#include "nrf_config.hpp"
extern oai::nrf::nrf_config nrf_cfg;
namespace oai { namespace oai {
namespace nrf { namespace nrf {
...@@ -31,7 +34,7 @@ void NFInstancesStoreApi::init() { ...@@ -31,7 +34,7 @@ void NFInstancesStoreApi::init() {
void NFInstancesStoreApi::setupRoutes() { void NFInstancesStoreApi::setupRoutes() {
using namespace Pistache::Rest; using namespace Pistache::Rest;
Routes::Get(*router, base + "/nf-instances", Routes::bind(&NFInstancesStoreApi::search_nf_instances_handler, this)); Routes::Get(*router, base + nrf_cfg.sbi_api_version + "/nf-instances", Routes::bind(&NFInstancesStoreApi::search_nf_instances_handler, this));
// Default handler, called when a route is not found // Default handler, called when a route is not found
router->addCustomHandler(Routes::bind(&NFInstancesStoreApi::nf_instances_store_api_default_handler, this)); router->addCustomHandler(Routes::bind(&NFInstancesStoreApi::nf_instances_store_api_default_handler, this));
......
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
#include "StoredSearchDocumentApi.h" #include "StoredSearchDocumentApi.h"
#include "Helpers.h" #include "Helpers.h"
#include "nrf_config.hpp"
extern oai::nrf::nrf_config nrf_cfg;
namespace oai { namespace oai {
namespace nrf { namespace nrf {
...@@ -31,7 +34,7 @@ void StoredSearchDocumentApi::init() { ...@@ -31,7 +34,7 @@ void StoredSearchDocumentApi::init() {
void StoredSearchDocumentApi::setupRoutes() { void StoredSearchDocumentApi::setupRoutes() {
using namespace Pistache::Rest; using namespace Pistache::Rest;
Routes::Get(*router, base + "/searches/:searchId", Routes::bind(&StoredSearchDocumentApi::retrieve_stored_search_handler, this)); Routes::Get(*router, base + nrf_cfg.sbi_api_version + "/searches/:searchId", Routes::bind(&StoredSearchDocumentApi::retrieve_stored_search_handler, this));
// Default handler, called when a route is not found // Default handler, called when a route is not found
router->addCustomHandler(Routes::bind(&StoredSearchDocumentApi::stored_search_document_api_default_handler, this)); router->addCustomHandler(Routes::bind(&StoredSearchDocumentApi::stored_search_document_api_default_handler, this));
......
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
#include "SubscriptionIDDocumentApi.h" #include "SubscriptionIDDocumentApi.h"
#include "Helpers.h" #include "Helpers.h"
#include "nrf_config.hpp"
extern oai::nrf::nrf_config nrf_cfg;
namespace oai { namespace oai {
namespace nrf { namespace nrf {
...@@ -31,8 +34,8 @@ void SubscriptionIDDocumentApi::init() { ...@@ -31,8 +34,8 @@ void SubscriptionIDDocumentApi::init() {
void SubscriptionIDDocumentApi::setupRoutes() { void SubscriptionIDDocumentApi::setupRoutes() {
using namespace Pistache::Rest; using namespace Pistache::Rest;
Routes::Delete(*router, base + "/subscriptions/:subscriptionID", Routes::bind(&SubscriptionIDDocumentApi::remove_subscription_handler, this)); Routes::Delete(*router, base + nrf_cfg.sbi_api_version + "/subscriptions/:subscriptionID", Routes::bind(&SubscriptionIDDocumentApi::remove_subscription_handler, this));
Routes::Patch(*router, base + "/subscriptions/:subscriptionID", Routes::bind(&SubscriptionIDDocumentApi::update_subscription_handler, this)); Routes::Patch(*router, base + nrf_cfg.sbi_api_version + "/subscriptions/:subscriptionID", Routes::bind(&SubscriptionIDDocumentApi::update_subscription_handler, this));
// Default handler, called when a route is not found // Default handler, called when a route is not found
router->addCustomHandler(Routes::bind(&SubscriptionIDDocumentApi::subscription_id_document_api_default_handler, this)); router->addCustomHandler(Routes::bind(&SubscriptionIDDocumentApi::subscription_id_document_api_default_handler, this));
......
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
#include "SubscriptionsCollectionApi.h" #include "SubscriptionsCollectionApi.h"
#include "Helpers.h" #include "Helpers.h"
#include "nrf_config.hpp"
extern oai::nrf::nrf_config nrf_cfg;
namespace oai { namespace oai {
namespace nrf { namespace nrf {
...@@ -31,7 +34,7 @@ void SubscriptionsCollectionApi::init() { ...@@ -31,7 +34,7 @@ void SubscriptionsCollectionApi::init() {
void SubscriptionsCollectionApi::setupRoutes() { void SubscriptionsCollectionApi::setupRoutes() {
using namespace Pistache::Rest; using namespace Pistache::Rest;
Routes::Post(*router, base + "/subscriptions", Routes::bind(&SubscriptionsCollectionApi::create_subscription_handler, this)); Routes::Post(*router, base + nrf_cfg.sbi_api_version + "/subscriptions", Routes::bind(&SubscriptionsCollectionApi::create_subscription_handler, this));
// Default handler, called when a route is not found // Default handler, called when a route is not found
router->addCustomHandler(Routes::bind(&SubscriptionsCollectionApi::subscriptions_collection_api_default_handler, this)); router->addCustomHandler(Routes::bind(&SubscriptionsCollectionApi::subscriptions_collection_api_default_handler, this));
......
/* /*
* Copyright (c) 2017 Sprint * Copyright (c) 2017 Sprint
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#include "nrf_app.hpp" #include "nrf_app.hpp"
#include "nrf-api-server.h" #include "nrf-api-server.h"
...@@ -35,63 +35,39 @@ ...@@ -35,63 +35,39 @@
using namespace oai::nrf; using namespace oai::nrf;
using namespace util; using namespace util;
using namespace std; using namespace std;
//using namespace oai::nrf_server::api;
nrf_app *nrf_app_inst = nullptr; nrf_app *nrf_app_inst = nullptr;
nrf_config nrf_cfg; nrf_config nrf_cfg;
NRFApiServer *api_server = nullptr;
void send_heartbeat_to_tasks(const uint32_t sequence);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void send_heartbeat_to_tasks(const uint32_t sequence) void my_app_signal_handler(int s) {
{
/* itti_msg_ping *itti_msg = new itti_msg_ping(TASK_SMF_APP, TASK_ALL, sequence);
std::shared_ptr<itti_msg_ping> i = std::shared_ptr<itti_msg_ping>(itti_msg);
int ret = itti_inst->send_broadcast_msg(i);
if (RETURNok != ret) {
Logger::nrf_app().error( "Could not send ITTI message %s to task TASK_ALL", i->get_msg_name());
}
*/
}
//------------------------------------------------------------------------------
void my_app_signal_handler(int s)
{
/*
std::cout << "Caught signal " << s << std::endl; std::cout << "Caught signal " << s << std::endl;
Logger::system().startup( "exiting" ); Logger::system().startup("exiting");
itti_inst->send_terminate_msg(TASK_SMF_APP);
itti_inst->wait_tasks_end();
std::cout << "Freeing Allocated memory..." << std::endl; std::cout << "Freeing Allocated memory..." << std::endl;
if (async_shell_cmd_inst) delete async_shell_cmd_inst; async_shell_cmd_inst = nullptr; if (api_server) {
std::cout << "Async Shell CMD memory done." << std::endl; api_server->shutdown();
if (nrf_api_server_1) { delete api_server;
nrf_api_server_1->shutdown(); api_server = nullptr;
delete nrf_api_server_1;
nrf_api_server_1 = nullptr;
}
if (nrf_api_server_2) {
nrf_api_server_2->stop();
delete nrf_api_server_2;
nrf_api_server_2 = nullptr;
} }
std::cout << "SMF API Server memory done." << std::endl;
if (itti_inst) delete itti_inst; itti_inst = nullptr; std::cout << "NRF API Server memory done." << std::endl;
std::cout << "ITTI memory done." << std::endl; if (nrf_app_inst)
if (nrf_app_inst) delete nrf_app_inst; nrf_app_inst = nullptr; delete nrf_app_inst;
std::cout << "SMF APP memory done." << std::endl; nrf_app_inst = nullptr;
std::cout << "NRF APP memory done." << std::endl;
std::cout << "Freeing Allocated memory done" << std::endl; std::cout << "Freeing Allocated memory done" << std::endl;
*/
exit(0); exit(0);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int main(int argc, char **argv) int main(int argc, char **argv) {
{
srand (time(NULL)); srand (time(NULL));
// Command line options // Command line options
if ( !Options::parse( argc, argv ) ) if ( !Options::parse( argc, argv ) )
{ {
std::cout << "Options::parse() failed" << std::endl; std::cout << "Options::parse() failed" << std::endl;
return 1; return 1;
...@@ -99,7 +75,6 @@ int main(int argc, char **argv) ...@@ -99,7 +75,6 @@ int main(int argc, char **argv)
// Logger // Logger
Logger::init( "nrf" , Options::getlogStdout() , Options::getlogRotFilelog()); Logger::init( "nrf" , Options::getlogStdout() , Options::getlogRotFilelog());
Logger::nrf_app().startup( "Options parsed" ); Logger::nrf_app().startup( "Options parsed" );
struct sigaction sigIntHandler; struct sigaction sigIntHandler;
...@@ -112,14 +87,7 @@ int main(int argc, char **argv) ...@@ -112,14 +87,7 @@ int main(int argc, char **argv)
nrf_cfg.load(Options::getlibconfigConfig()); nrf_cfg.load(Options::getlibconfigConfig());
nrf_cfg.display(); nrf_cfg.display();
// Inter task Interface // NRF application layer
// itti_inst = new itti_mw();
// itti_inst->start(nrf_cfg.itti.itti_timer_sched_params);
// system command
// async_shell_cmd_inst = new async_shell_cmd(nrf_cfg.itti.async_cmd_sched_params);
// SMF application layer
nrf_app_inst = new nrf_app(Options::getlibconfigConfig()); nrf_app_inst = new nrf_app(Options::getlibconfigConfig());
// PID file // PID file
...@@ -130,15 +98,12 @@ int main(int argc, char **argv) ...@@ -130,15 +98,12 @@ int main(int argc, char **argv)
exit (-EDEADLK); exit (-EDEADLK);
} }
/* //NRF Pistache API server (HTTP1)
//SMF Pistache API server (HTTP1)
Pistache::Address addr(std::string(inet_ntoa (*((struct in_addr *)&nrf_cfg.sbi.addr4))) , Pistache::Port(nrf_cfg.sbi.port)); Pistache::Address addr(std::string(inet_ntoa (*((struct in_addr *)&nrf_cfg.sbi.addr4))) , Pistache::Port(nrf_cfg.sbi.port));
nrf_api_server_1 = new SMFApiServer(addr, nrf_app_inst); api_server = new NRFApiServer(addr, nrf_app_inst);
nrf_api_server_1->init(2); api_server->init(2);
//nrf_api_server_1->start(); std::thread nrf_manager(&NRFApiServer::start, api_server);
std::thread nrf_http1_manager(&SMFApiServer::start, nrf_api_server_1); nrf_manager.join();
nrf_http1_manager.join();
*/
FILE *fp = NULL; FILE *fp = NULL;
std::string filename = fmt::format("/tmp/nrf_{}.status", getpid()); std::string filename = fmt::format("/tmp/nrf_{}.status", getpid());
......
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