On 28-Apr-15 4:39 PM, Hans Nordeback wrote:
  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);
+
Since nodes simultaneously hosts SUs from different SGs, nodes may host a high rank SUs from one SG and a low rank SU from other SG. So while instantiating all SUs of a node a lower rank SU may get instantiated first then a higher ranked SU hosted on some other node of same nodegroup. I have gone ahead and modified version 1 of your patch itself (see attached modified.patch). This can be applied on top of the version1 and takes care of instantiating the SUs on the nodes of nodegroup honoring SU ranks in the SG. Patch also incorporates some other comments also.
We can use this patch on top of version 1 ad the final patch if you are ok.

Thanks,
Praveen

+       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) {

diff --git a/osaf/services/saf/amf/amfd/include/sg.h 
b/osaf/services/saf/amf/amfd/include/sg.h
--- a/osaf/services/saf/amf/amfd/include/sg.h
+++ b/osaf/services/saf/amf/amfd/include/sg.h
@@ -552,6 +552,7 @@ extern bool sg_is_tolerance_timer_runnin
 extern void avd_sg_adjust_config(AVD_SG *sg);
 extern uint32_t sg_instantiated_su_count(const AVD_SG *sg);
 extern bool sg_stable_after_lock_in_or_unlock_in(AVD_SG *sg);
+extern void process_su_si_response_for_ng(AVD_SU *su, SaAisErrorT res);
 
 
 #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
@@ -784,6 +784,8 @@ void avd_data_update_req_evh(AVD_CL_CB *
                                                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));
+                                       } else if (su->su_on_node->admin_ng != 
NULL) {
+                                               
process_su_si_response_for_ng(su, SA_AIS_OK);
                                        }
 
                                        if (l_val == 
SA_AMF_PRESENCE_TERMINATION_FAILED) {
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
@@ -828,6 +828,75 @@ static void node_sus_termstate_set(AVD_A
 }
 
 /**
+ * perform unlock-instantiation on NG with honoring saAmfSURank. 
+ * 
+ * @param cb
+ * @param ng
+ */
+static void ng_admin_unlock_inst(AVD_AMF_NG *ng)
+{
+       uint32_t su_try_inst;
+       std::set<std::string> tmp_sg_list;
+       TRACE_ENTER2("%s", ng->name.value);
+
+       for (std::set<std::string>::const_iterator iter = 
ng->saAmfNGNodeList.begin();
+                       iter != ng->saAmfNGNodeList.end(); ++iter) {
+               AVD_AVND *node = avd_node_get(*iter);
+               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;
+               }
+               for (AVD_SU *node_su = node->list_of_su; node_su != NULL;  
node_su = node_su->avnd_list_su_next) {
+                       /*Instantiate only those SUs in this SG which are 
hosted on the Nodes of NG.
+                          Also honor saAmfSURank while instantating.
+                        */
+                       AVD_SG *sg = node_su->sg_of_su;
+
+                       std::set<std::string>::const_iterator iter1 ;
+                       iter1 = tmp_sg_list.find(Amf::to_string(&sg->name));
+                       if (iter1 != tmp_sg_list.end())
+                               continue;
+
+                       AVD_SU *su =  sg->list_of_su;
+                       for (su_try_inst = 0; su != NULL; su = 
su->sg_list_su_next) {
+                               //Continue if this SU is not hosted on the Node 
of NG.
+                               if 
(node_in_nodegroup(Amf::to_string(&su->su_on_node->name), ng) == false)
+                                       continue;
+
+                               if ((su->saAmfSUAdminState != 
SA_AMF_ADMIN_LOCKED_INSTANTIATION) &&
+                                       (node->saAmfNodeAdminState != 
SA_AMF_ADMIN_LOCKED_INSTANTIATION) &&
+                                               (su->saAmfSUOperState == 
SA_AMF_OPERATIONAL_ENABLED) &&
+                                               (su->saAmfSUPresenceState == 
SA_AMF_PRESENCE_UNINSTANTIATED)) {
+                                       if ((su->saAmfSUPreInstantiable == 
false) ||
+                                                       (node->node_state != 
AVD_AVND_STATE_PRESENT))
+                                               continue;
+
+                                       if (sg->saAmfSGNumPrefInserviceSUs > 
su_try_inst) {
+                                               if 
(avd_snd_presence_msg(avd_cb, su, false) != NCSCC_RC_SUCCESS) {
+                                                       LOG_NO("Failed to send 
Instantiation of '%s'", su->name.value);
+                                               } else {
+                                                       
su->su_on_node->su_cnt_admin_oper++;
+                                                       su_try_inst++;
+                                               }
+                                       }
+                               }
+                       }
+                       tmp_sg_list.insert(Amf::to_string(&sg->name));
+               }
+               TRACE("node:'%s', su_cnt_admin_oper:%u",
+                               node->name.value, node->su_cnt_admin_oper);
+               if (node->su_cnt_admin_oper > 0)
+                       ng->node_oper_list.insert(Amf::to_string(&node->name));
+       }
+       TRACE("node_oper_list size:%u",ng->oper_list_size());
+       TRACE_LEAVE();
+}
+
+/**
  * Handle admin operations on SaAmfNodeGroup objects.
  *
  * @param immoi_handle
@@ -887,26 +956,25 @@ static void ng_admin_op_cb(SaImmOiHandle
                        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);
-                               
avd_saImmOiAdminOperationResult(avd_cb->immOiHandle, invocation, SA_AIS_OK);
-                               goto done;
-                       }
-
-                       if (node->saAmfNodeOperState == 
SA_AMF_OPERATIONAL_DISABLED) {
-                               LOG_NO("'%s' LOCK_INSTANTIATION: AMF node oper 
state disabled", node->name.value);
-                               
avd_saImmOiAdminOperationResult(avd_cb->immOiHandle, invocation, SA_AIS_OK);
-                               goto done;
-                       }
                }
-
                for (std::set<std::string>::const_iterator iter = 
ng->saAmfNGNodeList.begin();
                     iter != ng->saAmfNGNodeList.end(); ++iter) {
                        AVD_AVND *node = avd_node_get(*iter);
+                       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;
+                       }
                        avd_node_admin_lock_instantiation(node);
+                       TRACE("node:'%s', su_cnt_admin_oper:%u",
+                                       node->name.value, 
node->su_cnt_admin_oper);
+                       if (node->su_cnt_admin_oper > 0)
+                               
ng->node_oper_list.insert(Amf::to_string(&node->name));
                }
-
+               TRACE("node_oper_list size:%u",ng->oper_list_size());
                if (ng->node_oper_list.empty())
                        ng_complete_admin_op(ng, SA_AIS_OK);
                break;
@@ -949,30 +1017,14 @@ node_sus_termstate_set(node, true);
                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, false);  
-                       if (node->node_info.member == false) {
-                               LOG_NO("'%s' UNLOCK_INSTANTIATION: CLM node is 
not member", node->name.value);
-                               
avd_saImmOiAdminOperationResult(avd_cb->immOiHandle, invocation, SA_AIS_OK);
-                               goto done;
-                       }
-
-                       if (node->saAmfNodeOperState == 
SA_AMF_OPERATIONAL_DISABLED) {
-                               LOG_NO("'%s' UNLOCK_INSTANTIATION: AMF node 
oper state disabled", node->name.value);
-                               
avd_saImmOiAdminOperationResult(avd_cb->immOiHandle, invocation, SA_AIS_OK);
-                               goto done;
-                       }
-                }
-
-                for (std::set<std::string>::const_iterator iter = 
ng->saAmfNGNodeList.begin();
-                    iter != ng->saAmfNGNodeList.end(); ++iter) {
-                       AVD_AVND *node = avd_node_get(*iter);
-
-                       /* now do the unlock_instantiation of the node */
-                       node_admin_unlock_instantiation(node);
-                }
-
-                if (ng->node_oper_list.empty())
-                        ng_complete_admin_op(ng, SA_AIS_OK);
+                       node_admin_state_set(node, SA_AMF_ADMIN_LOCKED);
+               }
+               ng_admin_unlock_inst(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);    
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
@@ -329,7 +329,7 @@ static void node_complete_admin_op(AVD_A
  * @param[in]   ptr to SU (AVD_SU). 
  * @param[in]   res(SaAisErrorT). 
  */
-static void process_su_si_response_for_ng(AVD_SU *su, SaAisErrorT res)
+void process_su_si_response_for_ng(AVD_SU *su, SaAisErrorT res)
 {
        TRACE_ENTER2("'%s'",su->name.value);
        AVD_AMF_NG *ng = su->su_on_node->admin_ng;
@@ -377,6 +377,24 @@ static void process_su_si_response_for_n
                        avd_ng_admin_state_set(ng, SA_AMF_ADMIN_LOCKED);
                }
        }
+       if (ng->saAmfNGAdminState == SA_AMF_ADMIN_LOCKED_INSTANTIATION) {
+               if ((su->saAmfSUPresenceState == 
SA_AMF_PRESENCE_UNINSTANTIATED) ||
+                       (su->saAmfSUPresenceState == 
SA_AMF_PRESENCE_TERMINATION_FAILED)) {
+                               su->su_on_node->su_cnt_admin_oper--;
+                               TRACE("node:'%s', su_cnt_admin_oper:%u",
+                                               
su->su_on_node->name.value,su->su_on_node->su_cnt_admin_oper);
+               }
+       } 
+       if ((ng->saAmfNGAdminState == SA_AMF_ADMIN_LOCKED) && 
+                       (ng->admin_ng_pend_cbk.admin_oper == 
SA_AMF_ADMIN_UNLOCK_INSTANTIATION)) {
+               if ((su->saAmfSUPresenceState == SA_AMF_PRESENCE_INSTANTIATED) 
||
+                               (su->saAmfSUPresenceState == 
SA_AMF_PRESENCE_TERMINATION_FAILED) ||
+                               (su->saAmfSUPresenceState == 
SA_AMF_PRESENCE_INSTANTIATION_FAILED)) {
+                               su->su_on_node->su_cnt_admin_oper--;
+                               TRACE("node:'%s', su_cnt_admin_oper:%u", 
+                                               
su->su_on_node->name.value,su->su_on_node->su_cnt_admin_oper);
+               }
+       }
        /*If no futher SU is undergoing assignment changes, erase node from
           nodgroup operation tracking list.*/
        if (node->su_cnt_admin_oper == 0) {
------------------------------------------------------------------------------
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

Reply via email to