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

Bug fix for NF Deregister

parent 421287b2
......@@ -143,8 +143,9 @@ void NFInstanceIDDocumentApiImpl::register_nf_instance(
void NFInstanceIDDocumentApiImpl::update_nf_instance(
const std::string &nfInstanceID, const std::vector<PatchItem> &patchItem,
Pistache::Http::ResponseWriter &response) {
Logger::nrf_sbi().info("");
Logger::nrf_sbi().info(
"\nGot a request to update an NF instance, Instance ID: %s",
"Got a request to update an NF instance, Instance ID: %s",
nfInstanceID.c_str());
int http_code = 0;
......
......@@ -248,8 +248,7 @@ void nrf_app::handle_update_nf_instance(
std::chrono::system_clock::now().time_since_epoch())
.count();
Logger::nrf_app().debug(
"NF update for Heartbeat, current time %ld", ms);
Logger::nrf_app().debug("NF update for Heartbeat, current time %ld", ms);
// If this happens before the first Heartbeattimer expires -> remove this
// timer
if (sn.get()->unsubscribe_heartbeat_timeout_nfregistration()) {
......@@ -357,13 +356,18 @@ void nrf_app::handle_deregister_nf_instance(const std::string &nf_instance_id,
Logger::nrf_app().info("Handle Deregister an NF Instance (HTTP version %d)",
http_version);
if (is_profile_exist(nf_instance_id)) {
std::shared_ptr<nrf_profile> profile = {};
profile = find_nf_profile(nf_instance_id);
if (profile.get() != nullptr) {
// TODO: notify NF status changed event
// Notify NF status deregistered event
m_event_sub.nf_status_deregistered(profile); // from nrf_app
if (remove_nf_profile(nf_instance_id)) {
Logger::nrf_app().debug("Removed NF profile with profile ID %s",
nf_instance_id.c_str());
http_code = HTTP_STATUS_CODE_204_NO_CONTENT;
// Notify NF status change event
m_event_sub.nf_status_deregistered(nf_instance_id); // from nrf_app
return;
} else {
http_code = HTTP_STATUS_CODE_500_INTERNAL_SERVER_ERROR;
......@@ -940,28 +944,20 @@ void nrf_app::subscribe_nf_status_deregistered() {
}
//------------------------------------------------------------------------------
void nrf_app::handle_nf_status_deregistered(const std::string &profile_id) {
void nrf_app::handle_nf_status_deregistered(
const std::shared_ptr<nrf_profile> &p) {
Logger::nrf_app().info("Handle NF status deregistered event, profile id %s",
profile_id.c_str());
std::shared_ptr<nrf_profile> profile = {};
Logger::nrf_app().info("\tFind a NF profile with ID %s", profile_id.c_str());
find_nf_profile(profile_id, profile);
if (profile.get() != nullptr) {
std::vector<std::string> notification_uris = {};
get_subscription_list(profile_id, NOTIFICATION_TYPE_NF_DEREGISTERED,
notification_uris);
// send notifications
if (notification_uris.size() > 0)
nrf_client_inst->notify_subscribed_event(
profile, NOTIFICATION_TYPE_NF_DEREGISTERED, notification_uris);
else
Logger::nrf_app().debug("\tNo subscription found");
} else {
Logger::nrf_app().error("NF profile not found, profile id %s",
profile_id.c_str());
}
p.get()->get_nf_instance_id().c_str());
std::vector<std::string> notification_uris = {};
get_subscription_list(p.get()->get_nf_instance_id(),
NOTIFICATION_TYPE_NF_DEREGISTERED, notification_uris);
// send notifications
if (notification_uris.size() > 0)
nrf_client_inst->notify_subscribed_event(
p, NOTIFICATION_TYPE_NF_DEREGISTERED, notification_uris);
else
Logger::nrf_app().debug("\tNo subscription found");
}
//------------------------------------------------------------------------------
......
......@@ -373,10 +373,10 @@ class nrf_app {
/*
* Handle NF status deregistered event
* @param [const std::string &] profile_id: Profile ID of the deregistered NF
* @param [const std::shared_ptr<nrf_profile> &] profile: pointer to the deregistered NF
* @return void
*/
void handle_nf_status_deregistered(const std::string &profile_id);
void handle_nf_status_deregistered(const std::shared_ptr<nrf_profile> &p);
/*
* Subscribe to the event when a registered NF changes its profile
......
......@@ -78,7 +78,7 @@ bs2::connection nrf_event::subscribe_nf_status_registered(
//------------------------------------------------------------------------------
bs2::connection nrf_event::subscribe_nf_status_deregistered(
const nf_status_sig_t::slot_type &sig) {
const nf_deregistered_sig_t::slot_type &sig) {
return nf_status_deregistered.connect(sig);
}
......
......@@ -95,7 +95,7 @@ class nrf_event {
const nf_status_sig_t::slot_type &sig);
bs2::connection subscribe_nf_status_deregistered(
const nf_status_sig_t::slot_type &sig);
const nf_deregistered_sig_t::slot_type &sig);
bs2::connection subscribe_nf_status_profile_changed(
const nf_status_sig_t::slot_type &sig);
......@@ -104,7 +104,7 @@ class nrf_event {
task_sig_t task_tick;
nf_status_change_sig_t nf_status_change;
nf_status_sig_t nf_status_registered;
nf_status_sig_t nf_status_deregistered;
nf_deregistered_sig_t nf_status_deregistered;
nf_status_sig_t nf_status_profile_changed;
};
} // namespace app
......
......@@ -50,6 +50,10 @@ typedef bs2::signal_type<void(const std::string &),
bs2::keywords::mutex_type<bs2::dummy_mutex>>::type
nf_status_sig_t;
typedef bs2::signal_type<void(const std::shared_ptr<nrf_profile> &p),
bs2::keywords::mutex_type<bs2::dummy_mutex>>::type
nf_deregistered_sig_t;
typedef bs2::signal_type<void(const std::shared_ptr<nrf_profile> &p),
bs2::keywords::mutex_type<bs2::dummy_mutex>>::type
nf_status_change_sig_t;
......
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