osaf/services/saf/amf/amfd/include/node.h | 1 + osaf/services/saf/amf/amfd/ndproc.cc | 23 ++- osaf/services/saf/amf/amfd/node.cc | 2 +- osaf/services/saf/amf/amfd/nodegroup.cc | 230 ++++++++++++++++++++++++++++++ 4 files changed, 253 insertions(+), 3 deletions(-)
diff --git a/osaf/services/saf/amf/amfd/include/node.h b/osaf/services/saf/amf/amfd/include/node.h --- a/osaf/services/saf/amf/amfd/include/node.h +++ b/osaf/services/saf/amf/amfd/include/node.h @@ -232,4 +232,5 @@ extern void avd_nodeswbundle_constructor extern void ng_complete_admin_op(AVD_AMF_NG *ng, SaAisErrorT result); extern void avd_ng_admin_state_set(AVD_AMF_NG* ng, SaAmfAdminStateT state); extern bool are_all_ngs_in_unlocked_state(const AVD_AVND *node); +extern void node_sus_termstate_set(AVD_AVND *node, bool term_state); #endif diff --git a/osaf/services/saf/amf/amfd/ndproc.cc b/osaf/services/saf/amf/amfd/ndproc.cc --- a/osaf/services/saf/amf/amfd/ndproc.cc +++ b/osaf/services/saf/amf/amfd/ndproc.cc @@ -779,8 +779,26 @@ void avd_data_update_req_evh(AVD_CL_CB * l_val = ntohl(*((uint32_t *)&n2d_msg->msg_info.n2d_data_req.param_info.value[0])); su->set_pres_state(static_cast<SaAmfPresenceStateT>(l_val)); + AVD_AMF_NG *ng = su->su_on_node->admin_ng; + + if (ng != 0) { + TRACE("NG: admin_oper %u", ng->admin_ng_pend_cbk.admin_oper); + TRACE("NG: node->su_cnt_admin_oper %u", node->su_cnt_admin_oper); + TRACE("NG: node_oper_list size: %u", node->admin_ng->oper_list_size()); + + su->su_on_node->su_cnt_admin_oper--; + + if (node->su_cnt_admin_oper == 0) { + ng->node_oper_list.erase(Amf::to_string(&node->name)); + TRACE("node_oper_list size:%u", ng->oper_list_size()); + } + /*If adm oper changes are done on all the SUs on each node of nodegroup + then reply to IMM for status of admin operation.*/ + if (ng->node_oper_list.empty()) + ng_complete_admin_op(ng, SA_AIS_OK); + /* Send response to any admin callbacks delivered by IMM if not sent already. */ - if (su->su_on_node->admin_node_pend_cbk.invocation != 0) { + } else if (su->su_on_node->admin_node_pend_cbk.invocation != 0) { node_admin_op_report_to_imm(su, static_cast<SaAmfPresenceStateT>(l_val)); } else if (su->pend_cbk.invocation != 0) { su_admin_op_report_to_imm(su, static_cast<SaAmfPresenceStateT>(l_val)); @@ -843,7 +861,8 @@ void avd_data_update_req_evh(AVD_CL_CB * done: avsv_dnd_msg_free(n2d_msg); evt->info.avnd_msg = NULL; - TRACE_LEAVE(); + + TRACE_LEAVE2("su_cnt_admin_oper: %u", node->su_cnt_admin_oper); } /***************************************************************************** diff --git a/osaf/services/saf/amf/amfd/node.cc b/osaf/services/saf/amf/amfd/node.cc --- a/osaf/services/saf/amf/amfd/node.cc +++ b/osaf/services/saf/amf/amfd/node.cc @@ -1057,7 +1057,7 @@ void avd_node_admin_lock_unlock_shutdown * * @param node */ -static void node_sus_termstate_set(AVD_AVND *node, bool term_state) +void node_sus_termstate_set(AVD_AVND *node, bool term_state) { AVD_SU *su; diff --git a/osaf/services/saf/amf/amfd/nodegroup.cc b/osaf/services/saf/amf/amfd/nodegroup.cc --- a/osaf/services/saf/amf/amfd/nodegroup.cc +++ b/osaf/services/saf/amf/amfd/nodegroup.cc @@ -23,6 +23,7 @@ #include <cluster.h> #include <imm.h> #include <set> +#include <list> AmfDb<std::string, AVD_AMF_NG> *nodegroup_db = 0; static AVD_AMF_NG *ng_create(SaNameT *dn, const SaImmAttrValuesT_2 **attributes); @@ -722,6 +723,130 @@ void ng_complete_admin_op(AVD_AMF_NG *ng node->admin_ng = NULL; } } + + +static bool suRank(const AVD_AVND* a, const AVD_AVND* b) +{ + if (a->list_of_su && b->list_of_su) { + TRACE("Node %s and %s has SUs", a->name.value, b->name.value); + return a->list_of_su->saAmfSURank < b->list_of_su->saAmfSURank; + } else { + TRACE("Node %s or %s has no SUs", a->name.value, b->name.value); + return false; + } +} + +/** + * Sends msg to instantiate SUs on the node as part of unlock instantiation + * + * @param node + */ +uint32_t ng_node_admin_unlock_instantiation(AVD_AMF_NG *ng) +{ + std::list<AVD_AVND*> ng_nodes; // to be sorted by su rank for the whole node group + AVD_SU *su; + AVD_AVND *node; + uint32_t rc = NCSCC_RC_SUCCESS; + + TRACE_ENTER2("'%s'", ng->name.value); + + for (std::set<std::string>::const_iterator iter = ng->saAmfNGNodeList.begin(); + iter != ng->saAmfNGNodeList.end(); ++iter) { + node = avd_node_get(*iter); + node_admin_state_set(node, SA_AMF_ADMIN_LOCKED); + node_sus_termstate_set(node, false); + + if (node->node_info.member == false) { + LOG_NO("'%s' UNLOCK_INSTANTIATION: CLM node is not member", node->name.value); + continue; + } + if (node->saAmfNodeOperState == SA_AMF_OPERATIONAL_DISABLED) { + LOG_NO("'%s' UNLOCK_INSTANTIATION: AMF node oper state disabled", node->name.value); + continue; + } + node->su_cnt_admin_oper = 0; + node->admin_ng = ng; + + ng_nodes.push_back(node); + } + + // list of nodegroup nodes sorted in suRank order + ng_nodes.sort(suRank); + + for (std::list<AVD_AVND*>::iterator it = ng_nodes.begin(); it != ng_nodes.end(); it++) { + node = *it; + /* instantiate the SUs on this Node */ + su = node->list_of_su; + while (su != NULL) { + if ((su->saAmfSUAdminState != SA_AMF_ADMIN_LOCKED_INSTANTIATION) && + (su->sg_of_su->saAmfSGAdminState != SA_AMF_ADMIN_LOCKED_INSTANTIATION) && + (su->saAmfSUPresenceState == SA_AMF_PRESENCE_UNINSTANTIATED) && + (su->saAmfSUOperState == SA_AMF_OPERATIONAL_ENABLED)) { + + if (su->saAmfSUPreInstantiable == true) { + if (su->sg_of_su->saAmfSGNumPrefInserviceSUs > + (sg_instantiated_su_count(su->sg_of_su) + + su->sg_of_su->try_inst_counter)) { + if (avd_snd_presence_msg(avd_cb, su, false) == NCSCC_RC_SUCCESS) { + node->su_cnt_admin_oper++; + su->sg_of_su->try_inst_counter++; + } else { + rc = NCSCC_RC_FAILURE; + LOG_WA("Failed Instantiation '%s'", su->name.value); + } + } + } + } + su = su->avnd_list_su_next; + } + + node_reset_su_try_inst_counter(node); + + if (node->su_cnt_admin_oper > 0) + node->admin_ng->node_oper_list.insert(Amf::to_string(&node->name)); + } + + TRACE_LEAVE2("%u", rc); + return rc; +} + +/** + * Sends msg to terminate all SUs on the node as part of lock instantiation + * + * @param node + */ +uint32_t ng_node_admin_lock_instantiation(AVD_AVND *node) +{ + AVD_SU *su; + uint32_t rc = NCSCC_RC_SUCCESS; + + TRACE_ENTER2("%s", node->name.value); + + /* terminate all the SUs on this Node */ + su = node->list_of_su; + while (su != NULL) { + if ((su->saAmfSUPreInstantiable == true) && + (su->saAmfSUPresenceState != SA_AMF_PRESENCE_UNINSTANTIATED) && + (su->saAmfSUPresenceState != SA_AMF_PRESENCE_INSTANTIATION_FAILED) && + (su->saAmfSUPresenceState != SA_AMF_PRESENCE_TERMINATION_FAILED)) { + + if (avd_snd_presence_msg(avd_cb, su, true) == NCSCC_RC_SUCCESS) { + node->su_cnt_admin_oper++; + } else { + rc = NCSCC_RC_FAILURE; + LOG_WA("Failed Termination '%s'", su->name.value); + } + } + su = su->avnd_list_su_next; + } + + if (node->su_cnt_admin_oper > 0) + node->admin_ng->node_oper_list.insert(Amf::to_string(&node->name)); + + TRACE_LEAVE2("rc: %u, node_oper_list size %u", rc, node->admin_ng->oper_list_size()); + return rc; +} + /** * @brief Handles node level funtionality during nodegroup lock * or shutdown operation. For each SU hosted on this node, @@ -811,6 +936,7 @@ void ng_unlock(AVD_AMF_NG *ng) } TRACE_LEAVE2("node_oper_list size:%u",ng->oper_list_size()); } + /** * Handle admin operations on SaAmfNodeGroup objects. * @@ -829,6 +955,110 @@ static void ng_admin_op_cb(SaImmOiHandle TRACE_ENTER2("'%s', inv:'%llu', op:'%llu'",ng_name->value,invocation,op_id); switch(op_id) { + case SA_AMF_ADMIN_LOCK_INSTANTIATION: + rc = check_ng_stability(ng); + if (rc != SA_AIS_OK) { + report_admin_op_error(avd_cb->immOiHandle, invocation, + SA_AIS_ERR_TRY_AGAIN, NULL, + "Some entity is unstable, Operation cannot " + "be performed on '%s'" + "Check syslog for entity details", ng_name->value); + goto done; + } + if (ng->saAmfNGAdminState == SA_AMF_ADMIN_LOCKED_INSTANTIATION) { + report_admin_op_error(avd_cb->immOiHandle, invocation, SA_AIS_ERR_NO_OP, NULL, + "'%s' Invalid Admin Operation LOCK INSTANTIATION in state %s", + ng->name.value, avd_adm_state_name[ng->saAmfNGAdminState]); + goto done; + } + if (ng->saAmfNGAdminState != SA_AMF_ADMIN_LOCKED) { + report_admin_op_error(avd_cb->immOiHandle, invocation, SA_AIS_ERR_BAD_OPERATION, NULL, + "'%s' Invalid Admin Operation LOCK_INSTANTIATION in state %s", + ng->name.value, avd_adm_state_name[ng->saAmfNGAdminState]); + goto done; + } + rc = check_red_model_service_outage(ng); + if (rc != SA_AIS_OK) { + report_admin_op_error(avd_cb->immOiHandle, invocation, + SA_AIS_ERR_NOT_SUPPORTED, NULL, + "SUs of unsupported red models hosted on '%s'" + "Check syslog for entity details", ng_name->value); + goto done; + } + ng->admin_ng_pend_cbk.invocation = invocation; + ng->admin_ng_pend_cbk.admin_oper = static_cast<SaAmfAdminOperationIdT>(op_id); + ng->node_oper_list.clear(); + + avd_ng_admin_state_set(ng, SA_AMF_ADMIN_LOCKED_INSTANTIATION); + for (std::set<std::string>::const_iterator iter = ng->saAmfNGNodeList.begin(); + iter != ng->saAmfNGNodeList.end(); ++iter) { + AVD_AVND *node = avd_node_get(*iter); + node->su_cnt_admin_oper = 0; + node->admin_ng = ng; + node_sus_termstate_set(node, true); + node_admin_state_set(node, SA_AMF_ADMIN_LOCKED_INSTANTIATION); + + if (node->node_info.member == false) { + LOG_NO("'%s' LOCK_INSTANTIATION: CLM node is not member", node->name.value); + continue; + } + + if (node->saAmfNodeOperState == SA_AMF_OPERATIONAL_DISABLED) { + LOG_NO("'%s' LOCK_INSTANTIATION: AMF node oper state disabled", node->name.value); + continue; + } + } + + for (std::set<std::string>::const_iterator iter = ng->saAmfNGNodeList.begin(); + iter != ng->saAmfNGNodeList.end(); ++iter) { + AVD_AVND *node = avd_node_get(*iter); + ng_node_admin_lock_instantiation(node); + } + + if (ng->node_oper_list.empty()) + ng_complete_admin_op(ng, SA_AIS_OK); + break; + case SA_AMF_ADMIN_UNLOCK_INSTANTIATION: + rc = check_ng_stability(ng); + if (rc != SA_AIS_OK) { + report_admin_op_error(avd_cb->immOiHandle, invocation, + SA_AIS_ERR_TRY_AGAIN, NULL, + "Some entity is unstable, Operation cannot " + "be performed on '%s'" + "Check syslog for entity details", ng_name->value); + goto done; + } + if (ng->saAmfNGAdminState == SA_AMF_ADMIN_LOCKED) { + report_admin_op_error(avd_cb->immOiHandle, invocation, SA_AIS_ERR_NO_OP, NULL, + "'%s' Already in LOCKED state", ng->name.value); + goto done; + } + + if (ng->saAmfNGAdminState != SA_AMF_ADMIN_LOCKED_INSTANTIATION) { + report_admin_op_error(avd_cb->immOiHandle, invocation, SA_AIS_ERR_BAD_OPERATION, NULL, + "'%s' Invalid Admin Operation UNLOCK_INSTANTIATION in state %s", + ng->name.value, avd_adm_state_name[ng->saAmfNGAdminState]); + goto done; + } + rc = check_red_model_service_outage(ng); + if (rc != SA_AIS_OK) { + report_admin_op_error(avd_cb->immOiHandle, invocation, + SA_AIS_ERR_NOT_SUPPORTED, NULL, + "SUs of unsupported red models hosted on '%s'" + "Check syslog for entity details", ng_name->value); + goto done; + } + + ng->admin_ng_pend_cbk.invocation = invocation; + ng->admin_ng_pend_cbk.admin_oper = static_cast<SaAmfAdminOperationIdT>(op_id); + ng->node_oper_list.clear(); + + avd_ng_admin_state_set(ng, SA_AMF_ADMIN_LOCKED); + ng_node_admin_unlock_instantiation(ng); + + if (ng->node_oper_list.empty()) + ng_complete_admin_op(ng, SA_AIS_OK); + break; case SA_AMF_ADMIN_LOCK: rc = check_ng_stability(ng); if (rc != SA_AIS_OK) { ------------------------------------------------------------------------------ One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel