osaf/services/saf/amf/amfd/comp.cc      |  57 ++++++++++++++++++------
 osaf/services/saf/amf/amfd/include/su.h |   3 +
 osaf/services/saf/amf/amfd/ndproc.cc    |  73 +++++++++++++++++++++++++-------
 osaf/services/saf/amf/amfd/sgproc.cc    |  45 ++++++++++++++++++--
 osaf/services/saf/amf/amfd/su.cc        |  30 +++++++++++++-
 5 files changed, 171 insertions(+), 37 deletions(-)


AMF currently support admin restart operation on a restartable
component(for which saAmfDisableRestart=false).

Patch supports it on a non-restartable component.
Patch for #315 contains changes in amfnd and amfd which are common
for all the three tickets viz. #315, #334 and #1455.

TODO: To take care of controller role change when operation in
progress.

diff --git a/osaf/services/saf/amf/amfd/comp.cc 
b/osaf/services/saf/amf/amfd/comp.cc
--- a/osaf/services/saf/amf/amfd/comp.cc
+++ b/osaf/services/saf/amf/amfd/comp.cc
@@ -783,13 +783,14 @@ static void comp_admin_op_cb(SaImmOiHand
        switch (opId) {
                /* Valid B.04 AMF comp admin operations */
        case SA_AMF_ADMIN_RESTART:
-               if (comp->comp_info.comp_restart == true) {
-                       report_admin_op_error(immOiHandle, invocation, 
SA_AIS_ERR_NOT_SUPPORTED, NULL,
-                                       "Component Restart disabled '%s'", 
objectName->value);
-               }
-               else if (comp->admin_pend_cbk.invocation != 0) {
+               if (comp->admin_pend_cbk.invocation != 0) {
                        report_admin_op_error(immOiHandle, invocation, 
SA_AIS_ERR_TRY_AGAIN, NULL,
                                        "Component undergoing admin operation 
'%s'", objectName->value);
+               } else if ((comp->su->sg_of_su->sg_ncs_spec == true) &&
+                               (comp->su->sg_of_su->sg_redundancy_model == 
SA_AMF_2N_REDUNDANCY_MODEL)) {
+                        report_admin_op_error(immOiHandle, invocation, 
SA_AIS_ERR_BAD_OPERATION, NULL,
+                                        "Not allowed on comp of middleware 2N 
SU : %s, op_id: %llu",
+                                        objectName->value, opId);
                }
                else if (comp->su->pend_cbk.invocation != 0) {
                        report_admin_op_error(immOiHandle, invocation, 
SA_AIS_ERR_TRY_AGAIN, NULL,
@@ -803,16 +804,42 @@ static void comp_admin_op_cb(SaImmOiHand
                        report_admin_op_error(immOiHandle, invocation, 
SA_AIS_ERR_BAD_OPERATION, NULL,
                                        "Component not instantiated '%s'", 
objectName->value);
                }
-               else {
-                       /* prepare the admin op req message and queue it */
-                       if (avd_admin_op_msg_snd(&comp->comp_info.name, 
AVSV_SA_AMF_COMP,
-                               static_cast<SaAmfAdminOperationIdT>(opId), 
comp->su->su_on_node) == NCSCC_RC_SUCCESS) {
-                               comp->admin_pend_cbk.admin_oper = 
static_cast<SaAmfAdminOperationIdT>(opId);
-                               comp->admin_pend_cbk.invocation = invocation;
-                       }
-                       else {
-                               report_admin_op_error(immOiHandle, invocation, 
SA_AIS_ERR_TIMEOUT, NULL,
-                                               "Admin op request send failed 
'%s'", objectName->value);
+               else if (comp->saAmfCompOperState == 
SA_AMF_OPERATIONAL_DISABLED) {
+                       report_admin_op_error(immOiHandle, invocation, 
SA_AIS_ERR_BAD_OPERATION, NULL,
+                                       "Component disabled, first repair su or 
check node status'%s'", objectName->value);
+               } else {
+                       comp->admin_pend_cbk.admin_oper = 
static_cast<SaAmfAdminOperationIdT>(opId);
+                       comp->admin_pend_cbk.invocation = invocation;
+
+                       if ((comp->comp_info.comp_restart == true) &&
+                                       (is_comp_assigned_any_csi(comp) == 
true)) {
+                               /* Atleast one non-restartable 
(saAmfCompDisableRestart or
+                                  saAmfCtDefDisableRestart is true) comp is 
assigned. 
+                                  First gracefully  switch-over its 
assignments to comp in 
+                                  other SU. At present assignment of whole SU 
will be gracefully
+                                  reassigned.
+                                  Thus PI applications modeled on NWay and 
Nway Active model
+                                  this is spec deviation.
+                                */
+                               if (comp->su->saAmfSUPreInstantiable == true) {
+                                       TRACE("surestart flag in '%s' is set to 
true",comp->su->name.value);
+                                       comp->su->surestart = true;
+                               }
+                               
comp->su->set_readiness_state(SA_AMF_READINESS_OUT_OF_SERVICE);
+                               comp->su->sg_of_su->su_fault(avd_cb, comp->su);
+                       } else {
+                               /* For a non restartable comp, amfd has no role 
in reassignment.
+                                   AMFND will take care of reassignment.*/
+
+                               /* prepare the admin op req message and queue 
it */
+                               if (avd_admin_op_msg_snd(&comp->comp_info.name, 
AVSV_SA_AMF_COMP,
+                                                       
static_cast<SaAmfAdminOperationIdT>(opId),
+                                                       comp->su->su_on_node) 
!= NCSCC_RC_SUCCESS) {
+                                       report_admin_op_error(immOiHandle, 
invocation, SA_AIS_ERR_TIMEOUT, NULL,
+                                                       "Admin op request send 
failed '%s'", objectName->value);
+                                       comp->admin_pend_cbk.admin_oper = 
static_cast<SaAmfAdminOperationIdT>(0);
+                                       comp->admin_pend_cbk.invocation = 0;
+                               }
                        }
                }
                break;
diff --git a/osaf/services/saf/amf/amfd/include/su.h 
b/osaf/services/saf/amf/amfd/include/su.h
--- a/osaf/services/saf/amf/amfd/include/su.h
+++ b/osaf/services/saf/amf/amfd/include/su.h
@@ -138,6 +138,9 @@ class AVD_SU {
        bool any_susi_fsm_in_unasgn();
        bool any_susi_fsm_in_modify();
        SaAisErrorT check_su_stability();
+       bool su_any_comp_undergoing_restart_admin_op();
+       AVD_COMP *su_get_comp_undergoing_restart_admin_op();
+
  private:
        void initialize();
        void send_attribute_update(AVSV_AMF_SU_ATTR_ID attrib_id);
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
@@ -286,28 +286,69 @@ void avd_oper_req_evh(AVD_CL_CB *cb, AVD
  */
 static void comp_admin_op_report_to_imm(AVD_COMP *comp, SaAmfPresenceStateT 
pres)
 {
-       AVD_CL_CB *cb = (AVD_CL_CB *)avd_cb;
-       TRACE_ENTER2("%u", pres);
-
-       if (comp->admin_pend_cbk.admin_oper == SA_AMF_ADMIN_RESTART) {
+       TRACE_ENTER2("%s", avd_pres_state_name[pres]);
+       SaAisErrorT rc = SA_AIS_OK;
+       
+       if (comp->admin_pend_cbk.admin_oper != SA_AMF_ADMIN_RESTART) {
+               TRACE_LEAVE2("(%llu)", comp->admin_pend_cbk.invocation);
+               return;
+       } 
+       if (comp->comp_info.comp_restart == false) {
                if ((comp->saAmfCompPresenceState == 
SA_AMF_PRESENCE_INSTANTIATED) &&
-                  (pres != SA_AMF_PRESENCE_RESTARTING)) {
-                       report_admin_op_error(cb->immOiHandle, 
comp->admin_pend_cbk.invocation,
-                                       SA_AIS_ERR_BAD_OPERATION, 
&comp->admin_pend_cbk,
-                                       "Couldn't restart Comp '%s'", 
comp->comp_info.name.value);
-               }
+                               (pres != SA_AMF_PRESENCE_RESTARTING))
+                       rc = SA_AIS_ERR_BAD_OPERATION; 
                else if (comp->saAmfCompPresenceState == 
SA_AMF_PRESENCE_RESTARTING) {
                        if (pres == SA_AMF_PRESENCE_INSTANTIATED)
-                               
avd_saImmOiAdminOperationResult(cb->immOiHandle,comp->admin_pend_cbk.invocation,
 SA_AIS_OK);
+                               rc = SA_AIS_OK;
                        else
-                               report_admin_op_error(cb->immOiHandle, 
comp->admin_pend_cbk.invocation,
-                                               SA_AIS_ERR_REPAIR_PENDING, 
&comp->admin_pend_cbk,
-                                               "Couldn't restart Comp '%s'", 
comp->comp_info.name.value);
-
-                       comp->admin_pend_cbk.admin_oper = 
static_cast<SaAmfAdminOperationIdT>(0);
-                       comp->admin_pend_cbk.invocation = 0;
+                               rc = SA_AIS_ERR_REPAIR_PENDING; 
+               } else if (pres == SA_AMF_PRESENCE_RESTARTING) {
+                       TRACE("Valid state transition is taking place, wait for 
final transition.");
+                       goto done;
+               }
+       } else {
+               if ((comp->saAmfCompPresenceState == 
SA_AMF_PRESENCE_INSTANTIATED) &&
+                               (pres != SA_AMF_PRESENCE_TERMINATING))
+                       rc = SA_AIS_ERR_BAD_OPERATION;
+               else if ((comp->saAmfCompPresenceState == 
SA_AMF_PRESENCE_TERMINATING) &&
+                               (pres != SA_AMF_PRESENCE_UNINSTANTIATED))
+                       rc = SA_AIS_ERR_BAD_OPERATION;
+               else if ((comp->saAmfCompPresenceState == 
SA_AMF_PRESENCE_UNINSTANTIATED) &&
+                               (pres != SA_AMF_PRESENCE_INSTANTIATING))
+                       rc = SA_AIS_ERR_BAD_OPERATION;
+               else if (comp->saAmfCompPresenceState == 
SA_AMF_PRESENCE_INSTANTIATING) {
+                       if (pres == SA_AMF_PRESENCE_INSTANTIATED)
+                               rc = SA_AIS_OK;
+                       else
+                               rc = SA_AIS_ERR_REPAIR_PENDING; 
+               } else if ((pres == SA_AMF_PRESENCE_TERMINATING) ||
+                               (pres == SA_AMF_PRESENCE_UNINSTANTIATED) ||
+                               (pres == SA_AMF_PRESENCE_INSTANTIATING)) {
+                       if ((comp->su->saAmfSUPreInstantiable == false) &&
+                                       (pres == 
SA_AMF_PRESENCE_UNINSTANTIATED)) {
+                               /*
+                                  All assignment are deleted. For a 
non-restartable comp in NPI
+                                  SU, there will not be instantiation as a 
part of comp restart
+                                  admin operation.
+                                */
+                               rc = SA_AIS_OK;
+                       } else {
+                               TRACE("Valid state transition is taking place, 
wait for final transition.");
+                               goto done;
+                       }
                }
        }
+
+       if (rc == SA_AIS_OK) {
+               
avd_saImmOiAdminOperationResult(avd_cb->immOiHandle,comp->admin_pend_cbk.invocation,
 rc);
+       } else {
+               report_admin_op_error(avd_cb->immOiHandle, 
comp->admin_pend_cbk.invocation,
+                               rc, &comp->admin_pend_cbk, "Couldn't restart 
Comp '%s'",
+                               comp->comp_info.name.value);
+       }
+       comp->admin_pend_cbk.admin_oper = 
static_cast<SaAmfAdminOperationIdT>(0);
+       comp->admin_pend_cbk.invocation = 0;
+done:
        TRACE_LEAVE2("(%llu)", comp->admin_pend_cbk.invocation);
 }
 
diff --git a/osaf/services/saf/amf/amfd/sgproc.cc 
b/osaf/services/saf/amf/amfd/sgproc.cc
--- a/osaf/services/saf/amf/amfd/sgproc.cc
+++ b/osaf/services/saf/amf/amfd/sgproc.cc
@@ -622,7 +622,6 @@ void avd_su_oper_state_evh(AVD_CL_CB *cb
        AVD_DND_MSG *n2d_msg = evt->info.avnd_msg;
        AVD_AVND *node;
        AVD_SU *su;
-       SaAmfReadinessStateT old_state;
        bool node_reboot_req = true;
 
        TRACE_ENTER2("id:%u, node:%x, '%s' state:%u", 
n2d_msg->msg_info.n2d_opr_state.msg_id,
@@ -856,8 +855,6 @@ void avd_su_oper_state_evh(AVD_CL_CB *cb
                                }
                        }
                } else {        /* if(su->sg_of_su->sg_ncs_spec == true) */
-                       old_state = su->saAmfSuReadinessState;
-
                        /* If oper state of Uninstantiated SU got ENABLED so 
try to instantiate it 
                           after evaluating SG. */
                        if (su->saAmfSUPresenceState == 
SA_AMF_PRESENCE_UNINSTANTIATED) {
@@ -867,7 +864,7 @@ void avd_su_oper_state_evh(AVD_CL_CB *cb
 
                        if (su->is_in_service() == true) {
                                
su->set_readiness_state(SA_AMF_READINESS_IN_SERVICE);
-                               if ((cb->init_state == AVD_APP_STATE) && 
(old_state == SA_AMF_READINESS_OUT_OF_SERVICE)) {
+                               if (cb->init_state == AVD_APP_STATE) {
                                        /* An application SU has become in 
service call SG FSM */
                                        if (su->sg_of_su->su_insvc(cb, su) == 
NCSCC_RC_FAILURE) {
                                                /* Bad situation. Free the 
message and return since
@@ -898,6 +895,42 @@ static void susi_assign_msg_dump(const c
 }
 
 
+void process_su_si_response_for_comp(AVD_SU *su)
+{
+       TRACE_ENTER();
+       if (su->list_of_susi != NULL) {
+               TRACE_LEAVE();
+               return;
+       }
+       AVD_COMP *comp = su->su_get_comp_undergoing_restart_admin_op();
+       AVD_COMP_TYPE *comptype = 
comptype_db->find(Amf::to_string(&comp->saAmfCompType));
+       osafassert(comptype);
+       if ((comp->su->saAmfSUPreInstantiable == true) &&
+                       (comptype->saAmfCtCompCategory != SA_AMF_COMP_SA_AWARE) 
&&
+                       (comp->saAmfCompPresenceState == 
SA_AMF_PRESENCE_UNINSTANTIATED)) {
+                        /*
+                           All assignment are deleted. For a non-restartable 
NPI comp in PI SU,
+                           there will be instantiation only when assignments 
are given.
+                         */
+               comp_complete_admin_op(comp, SA_AIS_OK);
+               TRACE("surestart flag is set falsefor 
'%s'",comp->su->name.value);
+               comp->su->surestart = false;            
+               comp->su->set_readiness_state(SA_AMF_READINESS_IN_SERVICE);
+               comp->su->sg_of_su->su_insvc(avd_cb, su);
+               TRACE_LEAVE();
+               return;
+       }
+       uint32_t rc = avd_admin_op_msg_snd(&comp->comp_info.name, 
AVSV_SA_AMF_COMP,
+                       SA_AMF_ADMIN_RESTART, comp->su->su_on_node);
+       if (rc != NCSCC_RC_SUCCESS) {
+               report_admin_op_error(avd_cb->immOiHandle, 
comp->admin_pend_cbk.invocation,
+                               SA_AIS_ERR_TIMEOUT, NULL,
+                               "Admin op request send failed '%s'", 
comp->comp_info.name.value);
+               comp->admin_pend_cbk.admin_oper = 
static_cast<SaAmfAdminOperationIdT>(0);
+               comp->admin_pend_cbk.invocation = 0;
+       }
+       TRACE_LEAVE();
+}
 /*****************************************************************************
  * Function: avd_su_si_assign_func
  *
@@ -914,7 +947,7 @@ static void susi_assign_msg_dump(const c
  * NOTES: None.
  *
  * 
- **************************************************************************/
+ *************************************************************************/
 
 void avd_su_si_assign_evh(AVD_CL_CB *cb, AVD_EVT *evt)
 {
@@ -1385,6 +1418,8 @@ void avd_su_si_assign_evh(AVD_CL_CB *cb,
                                        
su->su_on_node->name.value,su->su_on_node->su_cnt_admin_oper);
                        }
                        process_su_si_response_for_ng(su, SA_AIS_OK);
+               } else if (su->su_any_comp_undergoing_restart_admin_op() == 
true) { 
+                       process_su_si_response_for_comp(su);
                } else {
                        if (n2d_msg->msg_info.n2d_su_si_assign.error == 
NCSCC_RC_SUCCESS) {
                                if ((su->sg_of_su->sg_redundancy_model == 
SA_AMF_N_WAY_REDUNDANCY_MODEL) && 
diff --git a/osaf/services/saf/amf/amfd/su.cc b/osaf/services/saf/amf/amfd/su.cc
--- a/osaf/services/saf/amf/amfd/su.cc
+++ b/osaf/services/saf/amf/amfd/su.cc
@@ -767,10 +767,20 @@ void AVD_SU::set_pres_state(SaAmfPresenc
        avd_saImmOiRtObjectUpdate(&name, "saAmfSUPresenceState",
                SA_IMM_ATTR_SAUINT32T, &saAmfSUPresenceState);
        m_AVSV_SEND_CKPT_UPDT_ASYNC_UPDT(avd_cb, this, AVSV_CKPT_SU_PRES_STATE);
-       if ((saAmfSUPresenceState == SA_AMF_PRESENCE_UNINSTANTIATED) && 
(surestart == true)) {
+       if ((saAmfSUPresenceState == SA_AMF_PRESENCE_INSTANTIATED) && 
(surestart == true)) {
                TRACE("setting surestart flag to false");
                surestart = false;
        }
+       //Section 3.2.1.4 Readiness State: presence state affects readiness 
state of  a PI SU.
+       if (saAmfSUPreInstantiable == true) {
+               if (((saAmfSUPresenceState == SA_AMF_PRESENCE_INSTANTIATED) ||
+                               (saAmfSUPresenceState == 
SA_AMF_PRESENCE_RESTARTING)) &&
+                               (is_in_service() == true))
+                       set_readiness_state(SA_AMF_READINESS_IN_SERVICE);       
+               else {
+                       set_readiness_state(SA_AMF_READINESS_OUT_OF_SERVICE);   
+               } 
+       }       
        TRACE_LEAVE();
 }
 
@@ -2174,3 +2184,21 @@ SaAisErrorT AVD_SU::check_su_stability()
 done:
        return rc;
 }
+
+bool AVD_SU::su_any_comp_undergoing_restart_admin_op()
+{
+       for (AVD_COMP *comp = list_of_comp; comp; comp = comp->su_comp_next) {
+               if (comp->admin_pend_cbk.admin_oper == SA_AMF_ADMIN_RESTART)
+                       return true;
+        }
+       return false;
+}
+
+AVD_COMP *AVD_SU::su_get_comp_undergoing_restart_admin_op()
+{ 
+       for (AVD_COMP *comp = list_of_comp; comp; comp = comp->su_comp_next) {
+               if (comp->admin_pend_cbk.admin_oper == SA_AMF_ADMIN_RESTART)
+                       return comp;
+       }
+       return NULL;
+}

------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to