Re: [devel] [PATCH 1 of 1] amfd: support si-swap admin op for NplusM model [#2259]

2017-02-27 Thread Gary Lee
Hi

Ack (legacy tests run).

Thanks
Gary

On 21/2/17, 9:57 pm, "praveen.malv...@oracle.com"  
wrote:

 src/amf/amfd/sg.cc |   12 +++-
 src/amf/amfd/sg.h  |4 +
 src/amf/amfd/sg_npm_fsm.cc |  145 
-
 src/amf/amfd/su.cc |   11 +++
 src/amf/amfd/su.h  |2 +
 5 files changed, 144 insertions(+), 30 deletions(-)


This version works for the case when all SIs which are active in the
designated SU (where SI to be swaped is active) have their standbys on same 
SU
including the designated SI.

TODO: consider the case when active SIs of designated SU have their 
standbys on different SUs.

diff --git a/src/amf/amfd/sg.cc b/src/amf/amfd/sg.cc
--- a/src/amf/amfd/sg.cc
+++ b/src/amf/amfd/sg.cc
@@ -2,6 +2,7 @@
  *
  * (C) Copyright 2008 The OpenSAF Foundation
  * (C) Copyright 2017 Ericsson AB - All Rights Reserved.
+ * Copyright (C) 2017, Oracle and/or its affiliates. All rights reserved.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of 
MERCHANTABILITY
@@ -2274,4 +2275,13 @@ bool AVD_SG::any_assignment_assigned() {
return pending;
 }
 
-
+/*
+ * @brief  Checks if si_equal_distribution is configured for the SG.
+ * @return true/false. 
+*/
+bool AVD_SG::is_equal() const {
+  return(((sg_redundancy_model == SA_AMF_NPM_REDUNDANCY_MODEL) ||
+ (sg_redundancy_model == SA_AMF_N_WAY_REDUNDANCY_MODEL) ||
+ (sg_redundancy_model == SA_AMF_N_WAY_ACTIVE_REDUNDANCY_MODEL)) &&
+ (equal_ranked_su == true) && (saAmfSGAutoAdjust == SA_TRUE));
+}
diff --git a/src/amf/amfd/sg.h b/src/amf/amfd/sg.h
--- a/src/amf/amfd/sg.h
+++ b/src/amf/amfd/sg.h
@@ -2,6 +2,7 @@
  *
  * (C) Copyright 2008 The OpenSAF Foundation
  * (C) Copyright 2017 Ericsson AB - All Rights Reserved.
+ * Copyright (C) 2017, Oracle and/or its affiliates. All rights reserved.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of 
MERCHANTABILITY
@@ -429,6 +430,8 @@ public:
//Runtime calculates value of saAmfSGNumCurrNonInstantiatedSpareSUs;
uint32_t curr_non_instantiated_spare_sus() const;
bool is_middleware() const {return sg_ncs_spec ? true : false;}
+   //Checks if si_equal_distribution is configured for the SG.
+   bool is_equal() const;
 
 private:
// disallow copy and assign, TODO(hafe) add common macro for this
@@ -514,6 +517,7 @@ public:
struct avd_su_si_rel_tag *susi, AVSV_SUSI_ACT act, 
SaAmfHAStateT state);
 void node_fail_si_oper(AVD_CL_CB *cb, AVD_SU *su);
void ng_admin(AVD_SU *su, AVD_AMF_NG *ng);
+   SaAisErrorT si_swap(AVD_SI *si, SaInvocationT invocation);
 
 private:
 uint32_t su_fault_su_oper(AVD_CL_CB *cb, AVD_SU *su);
diff --git a/src/amf/amfd/sg_npm_fsm.cc b/src/amf/amfd/sg_npm_fsm.cc
--- a/src/amf/amfd/sg_npm_fsm.cc
+++ b/src/amf/amfd/sg_npm_fsm.cc
@@ -1,6 +1,7 @@
 /*  -*- OpenSAF  -*-
  *
  * (C) Copyright 2008 The OpenSAF Foundation
+ * Copyright (C) 2017, Oracle and/or its affiliates. All rights reserved.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of 
MERCHANTABILITY
@@ -170,7 +171,10 @@ static uint32_t avd_sg_npm_su_chk_snd(AV
}
}
 
+   /*Do not send delete for a susi of s_su if other sisu of same si is in 
q_su.
+ In this case s_su can become active for this SI.*/
for (i_susi = s_su->list_of_susi; i_susi != AVD_SU_SI_REL_NULL; i_susi 
= i_susi->su_next) {
+   
if ((i_susi->si->list_of_sisu != i_susi) && 
(i_susi->si->list_of_sisu->su == q_su))
continue;
 
@@ -964,34 +968,6 @@ uint32_t SG_NPM::si_assign(AVD_CL_CB *cb
return NCSCC_RC_SUCCESS;
 }
 

-/*
- * Function: avd_sg_npm_siswitch_func
- *
- * Purpose:  This function is called when a operator does a SI switch on
- * a SI that belongs to N+M redundancy model SG. 
- * This will trigger a role change action as described in the SG FSM 
design.
- *
- * Input: cb - the AVD control block
- *si - The pointer to the SI that needs to be switched.
- *
- *
- * Returns: NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE.
- *
- * NOTES: This is a N+M redundancy model specific function. The initial 
- * functionality of N+M SI switch is same as 2N switch so it just calls 
that
- * function.
 

[devel] [PATCH 1 of 1] amfd: support si-swap admin op for NplusM model [#2259]

2017-02-21 Thread praveen . malviya
 src/amf/amfd/sg.cc |   12 +++-
 src/amf/amfd/sg.h  |4 +
 src/amf/amfd/sg_npm_fsm.cc |  145 -
 src/amf/amfd/su.cc |   11 +++
 src/amf/amfd/su.h  |2 +
 5 files changed, 144 insertions(+), 30 deletions(-)


This version works for the case when all SIs which are active in the
designated SU (where SI to be swaped is active) have their standbys on same SU
including the designated SI.

TODO: consider the case when active SIs of designated SU have their standbys on 
different SUs.

diff --git a/src/amf/amfd/sg.cc b/src/amf/amfd/sg.cc
--- a/src/amf/amfd/sg.cc
+++ b/src/amf/amfd/sg.cc
@@ -2,6 +2,7 @@
  *
  * (C) Copyright 2008 The OpenSAF Foundation
  * (C) Copyright 2017 Ericsson AB - All Rights Reserved.
+ * Copyright (C) 2017, Oracle and/or its affiliates. All rights reserved.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
@@ -2274,4 +2275,13 @@ bool AVD_SG::any_assignment_assigned() {
return pending;
 }
 
-
+/*
+ * @brief  Checks if si_equal_distribution is configured for the SG.
+ * @return true/false. 
+*/
+bool AVD_SG::is_equal() const {
+  return(((sg_redundancy_model == SA_AMF_NPM_REDUNDANCY_MODEL) ||
+ (sg_redundancy_model == SA_AMF_N_WAY_REDUNDANCY_MODEL) ||
+ (sg_redundancy_model == SA_AMF_N_WAY_ACTIVE_REDUNDANCY_MODEL)) &&
+ (equal_ranked_su == true) && (saAmfSGAutoAdjust == SA_TRUE));
+}
diff --git a/src/amf/amfd/sg.h b/src/amf/amfd/sg.h
--- a/src/amf/amfd/sg.h
+++ b/src/amf/amfd/sg.h
@@ -2,6 +2,7 @@
  *
  * (C) Copyright 2008 The OpenSAF Foundation
  * (C) Copyright 2017 Ericsson AB - All Rights Reserved.
+ * Copyright (C) 2017, Oracle and/or its affiliates. All rights reserved.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
@@ -429,6 +430,8 @@ public:
//Runtime calculates value of saAmfSGNumCurrNonInstantiatedSpareSUs;
uint32_t curr_non_instantiated_spare_sus() const;
bool is_middleware() const {return sg_ncs_spec ? true : false;}
+   //Checks if si_equal_distribution is configured for the SG.
+   bool is_equal() const;
 
 private:
// disallow copy and assign, TODO(hafe) add common macro for this
@@ -514,6 +517,7 @@ public:
struct avd_su_si_rel_tag *susi, AVSV_SUSI_ACT act, 
SaAmfHAStateT state);
 void node_fail_si_oper(AVD_CL_CB *cb, AVD_SU *su);
void ng_admin(AVD_SU *su, AVD_AMF_NG *ng);
+   SaAisErrorT si_swap(AVD_SI *si, SaInvocationT invocation);
 
 private:
 uint32_t su_fault_su_oper(AVD_CL_CB *cb, AVD_SU *su);
diff --git a/src/amf/amfd/sg_npm_fsm.cc b/src/amf/amfd/sg_npm_fsm.cc
--- a/src/amf/amfd/sg_npm_fsm.cc
+++ b/src/amf/amfd/sg_npm_fsm.cc
@@ -1,6 +1,7 @@
 /*  -*- OpenSAF  -*-
  *
  * (C) Copyright 2008 The OpenSAF Foundation
+ * Copyright (C) 2017, Oracle and/or its affiliates. All rights reserved.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
@@ -170,7 +171,10 @@ static uint32_t avd_sg_npm_su_chk_snd(AV
}
}
 
+   /*Do not send delete for a susi of s_su if other sisu of same si is in 
q_su.
+ In this case s_su can become active for this SI.*/
for (i_susi = s_su->list_of_susi; i_susi != AVD_SU_SI_REL_NULL; i_susi 
= i_susi->su_next) {
+   
if ((i_susi->si->list_of_sisu != i_susi) && 
(i_susi->si->list_of_sisu->su == q_su))
continue;
 
@@ -964,34 +968,6 @@ uint32_t SG_NPM::si_assign(AVD_CL_CB *cb
return NCSCC_RC_SUCCESS;
 }
 
-/*
- * Function: avd_sg_npm_siswitch_func
- *
- * Purpose:  This function is called when a operator does a SI switch on
- * a SI that belongs to N+M redundancy model SG. 
- * This will trigger a role change action as described in the SG FSM design.
- *
- * Input: cb - the AVD control block
- *si - The pointer to the SI that needs to be switched.
- *
- *
- * Returns: NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE.
- *
- * NOTES: This is a N+M redundancy model specific function. The initial 
- * functionality of N+M SI switch is same as 2N switch so it just calls that
- * function.
- *
- * 
- **/
-
-uint32_t avd_sg_npm_siswitch_func(AVD_CL_CB *cb, AVD_SI *si)
-{
-   TRACE_ENTER2("%u", si->sg_of_si->sg_fsm_state);
-   osafassert(0);
-// return avd_sg_2n_siswitch_func(cb, si);
-   return 0;
-}
-
  /*
  * Function: su_fault_su_oper
  *
@@ -1847,6 +1823,7 @@ uint32_t SG_NPM::susi_sucss_sg_reln(AVD_