osaf/services/saf/smfsv/smfd/SmfUpgradeStep.cc   |  191 ++++++++++++++++++----
 osaf/services/saf/smfsv/smfd/SmfUpgradeStep.hh   |   14 +
 osaf/services/saf/smfsv/smfd/smfd_campaign_oi.cc |   79 +--------
 3 files changed, 176 insertions(+), 108 deletions(-)


When rebootAffectedNodes is enabled and sw bundles list it's own plmExecEnv 
nodes for specific sw bundles, the specified nodes are rebooted.

diff --git a/osaf/services/saf/smfsv/smfd/SmfUpgradeStep.cc 
b/osaf/services/saf/smfsv/smfd/SmfUpgradeStep.cc
--- a/osaf/services/saf/smfsv/smfd/SmfUpgradeStep.cc
+++ b/osaf/services/saf/smfsv/smfd/SmfUpgradeStep.cc
@@ -534,6 +534,15 @@ SmfUpgradeStep::getSwNodeList()
 }
 
 
//------------------------------------------------------------------------------
+// getSsAffectedNodeList()
+//------------------------------------------------------------------------------
+const std::list<std::string> & 
+SmfUpgradeStep::getSsAffectedNodeList() 
+{
+       return m_ssAffectedNodeList;
+}
+
+//------------------------------------------------------------------------------
 // setStepType()
 
//------------------------------------------------------------------------------
 void 
@@ -1235,7 +1244,10 @@ bool SmfUpgradeStep::calculateSingleStep
 
        if (i_plmExecEnvList.empty()) {
                TRACE("No <plmExecEnv> was specified, use  m_swNodeList");
-               o_nodelist = m_swNodeList;
+                std::list<std::string>::iterator it;
+               for (it = m_swNodeList.begin(); it != m_swNodeList.end(); it++) 
{
+                        o_nodelist.push_back(*it);
+                }
        } else {
                TRACE("<plmExecEnv> was specified, get the AMF nodes from the 
provided plmExecEnvList");
                std::list<SmfPlmExecEnv>::const_iterator ee;
@@ -1440,6 +1452,24 @@ SmfUpgradeStep::calculateStepType()
                                 //  *If SMF execute on the controller 
included, swap controllers
                                 //  *Otherwise , node reboot step is selected.
 
+                                //Find out which nodes are affected for each 
bundle, plmExecEnv overrides calc nodes.
+                                //This list is the total set of nodes for the 
single step procedure
+                                //This will be used to calc if all controllers 
are included and as a list of nodes
+                                //to reboot in case of any bundle needs reboot 
to install/reboot
+                                std::list < SmfBundleRef >::const_iterator 
bundleit;
+                                //Find out which nodes was addressed for 
removal
+                                for (bundleit = m_swRemoveList.begin(); 
bundleit != m_swRemoveList.end(); ++bundleit) {
+                                        if 
(!calculateSingleStepNodes(bundleit->getPlmExecEnvList(), 
m_ssAffectedNodeList)) {
+                                                LOG_NO("Fail to calculate 
nodes for bundle [%s]", bundleit->getBundleDn().c_str());
+                                        }
+                                }
+                                //Find out which nodes was addressed for 
installation
+                                for (bundleit = m_swAddList.begin(); bundleit 
!= m_swAddList.end(); ++bundleit) {
+                                        if 
(!calculateSingleStepNodes(bundleit->getPlmExecEnvList(), 
m_ssAffectedNodeList)) {
+                                                LOG_NO("Fail to calculate 
nodes for bundle [%s]", bundleit->getBundleDn().c_str());
+                                        }
+                                }
+
                                 bool allControllersAffected = false; //Assume 
all controllers is not within the single step list of nodes
                                 int noOfAffectedControllers = 0;
                                 std::string matchingController;
@@ -1452,6 +1482,16 @@ SmfUpgradeStep::calculateStepType()
                                         goto selectStepType;
                                 }
 
+                                //Read if cluster controllers are defined.
+                                //They are defined if the feature to reboot 
affected nodes only in a
+                                //single step procedures is wanted. This is a 
single step procedure.
+                                if (false == readSmfClusterControllers()) {
+                                        //In case of failure to read, continue 
anyway. The only impact is that
+                                        //the cluster will be rebooted instead 
of affected nodes only. The campaign
+                                        //will however not fail because of 
this.
+                                        LOG_NO("Fail to read the id of the 
cluster controllers, continue. Cluster reboot will be choosen");
+                                }
+
                                 if (smfd_cb->smfClusterControllers[0] != NULL) 
{  //Controller is configured
 
                                         //Count the number of controllers 
configured
@@ -1463,7 +1503,8 @@ SmfUpgradeStep::calculateStepType()
                                         }
 
                                         std::string clmNode; //CLM nodes are 
expected in attribute smfClusterControllers.
-                                        std::list <std::string> nodeList = 
this->getSwNodeList();
+                                        // std::list <std::string> nodeList = 
this->getSwNodeList();
+                                        std::list <std::string> nodeList = 
this->getSsAffectedNodeList();
                                         std::list < std::string 
>::const_iterator nodeit = nodeList.begin();
                                         std::string smfClusterController;
 
@@ -1847,32 +1888,22 @@ SmfUpgradeStep::callActivationCmd()
                   not bound to a particular node, so the
                   "i_node" will be empty. */
 
-               std::list<SmfPlmExecEnv> plmExecEnvList; //The resulting PLM 
env list
+                //Find out which nodes are affected for each bundle, 
plmExecEnv overrides calc nodes
+                std::list < SmfBundleRef >::const_iterator bundleit;
+                std::list<std::string> swNodeList;  //The total list of nodes
 
-               //Find out which nodes was addressed for installation and 
removal
-               for (bundleit = m_swRemoveList.begin(); bundleit != 
m_swRemoveList.end(); ++bundleit) {
-                       std::list<SmfPlmExecEnv> tmp = 
bundleit->getPlmExecEnvList();
-                       std::list<SmfPlmExecEnv>::iterator it;
-                       for (it = tmp.begin(); it != tmp.end(); ++it) {
-                               plmExecEnvList.push_back(*it);
-                       }
-               }
-
-               for (bundleit = m_swAddList.begin(); bundleit != 
m_swAddList.end(); ++bundleit) {
-                       std::list<SmfPlmExecEnv> tmp = 
bundleit->getPlmExecEnvList();
-                       std::list<SmfPlmExecEnv>::iterator it;
-                       for (it = tmp.begin(); it != tmp.end(); ++it) {
-                               plmExecEnvList.push_back(*it);
-                       }
-               }
-
-               //Translate the PLM exec env to AMF nodes
-               //Duplicates are removed in the calculateSingleStepNodes method
-               std::list<std::string> swNodeList;
-               if (!calculateSingleStepNodes(plmExecEnvList, swNodeList)) {
-                       result = false;
-                       goto done;                                      
-               }
+                //Find out which nodes was addressed for removal
+                for (bundleit = m_swRemoveList.begin(); bundleit != 
m_swRemoveList.end(); ++bundleit) {
+                        if 
(!calculateSingleStepNodes(bundleit->getPlmExecEnvList(), swNodeList)) {
+                                LOG_NO("Fail to calculate nodes for bundle 
[%s]", bundleit->getBundleDn().c_str());
+                        }
+                }
+                //Find out which nodes was addressed for installation
+                for (bundleit = m_swAddList.begin(); bundleit != 
m_swAddList.end(); ++bundleit) {
+                        if 
(!calculateSingleStepNodes(bundleit->getPlmExecEnvList(), swNodeList)) {
+                                LOG_NO("Fail to calculate nodes for bundle 
[%s]", bundleit->getBundleDn().c_str());
+                        }
+                }
 
                std::list<std::string>::const_iterator n;
                for (n = swNodeList.begin(); n != swNodeList.end(); n++) {
@@ -2230,10 +2261,14 @@ SmfUpgradeStep::nodeReboot()
        int localTimeout  = 500;                                  // 500 * 10 
ms = 5 seconds
         SmfndNodeDest nodeDest;
         std::list<std::string> nodeList;
+       std::list<std::string>::iterator listIt;
+        std::list<SmfNodeUpInfo> rebootedNodeList;
+        std::list<SmfNodeUpInfo> cmdNodeList;
+       std::list<SmfNodeUpInfo>::iterator nodeIt;
 
         //Copy the step node/nodelist into a local node list
        if (getSwNode().length() == 0) { //Single step procedure
-                nodeList = getSwNodeList();
+                nodeList = getSsAffectedNodeList();
         } else {                         //Rolling procedure
                 nodeList.push_back(getSwNode());
         }
@@ -2244,11 +2279,6 @@ SmfUpgradeStep::nodeReboot()
                return result;
        }
 
-       std::list<std::string>::iterator listIt;
-        std::list<SmfNodeUpInfo> rebootedNodeList;
-        std::list<SmfNodeUpInfo> cmdNodeList;
-       std::list<SmfNodeUpInfo>::iterator nodeIt;
-
        //Order smf node director to reboot the node
        cmd = smfd_cb->smfNodeRebootCmd;
 
@@ -2266,7 +2296,7 @@ SmfUpgradeStep::nodeReboot()
                    command execution anyway so it doesn't nodeReboot()matter 
that the timeout is really long */
                 cmdrc = smfnd_exec_remote_cmd(cmd.c_str(), &nodeDest, 
cliTimeout, localTimeout);
                 if (cmdrc != 0) {
-                        LOG_NO("Reboot command [%s] on node [%s] failed 
rc=[%x], continue", cmd.c_str(), (*listIt).c_str(), cmdrc);
+                        LOG_NO("Reboot command [%s] on node [%s] return 
rc=[%x], continue", cmd.c_str(), (*listIt).c_str(), cmdrc);
                 }
 
                 /* Save the nodename and node UP counter for later use */
@@ -2556,3 +2586,96 @@ bool SmfUpgradeStep::checkAndInvokeCallb
        }
        return true;
 }
+
+//------------------------------------------------------------------------------
+// readSmfClusterControllers()
+//------------------------------------------------------------------------------
+bool SmfUpgradeStep::readSmfClusterControllers()
+{
+        TRACE_ENTER();
+        //Read smfSSAffectedNodesEnable. If >0 (true) the cluster controller 
CLM nodes with node Id 1 and 2
+        //shall override the CLM nodes set in attribute smfClusterControllers.
+        SmfImmUtils immutil;
+        SaImmAttrValuesT_2 **attributes;
+
+        if (immutil.getObject(SMF_CONFIG_OBJECT_DN, &attributes) == false) {
+               LOG_ER("Could not get SMF config object from IMM %s", 
SMF_CONFIG_OBJECT_DN);
+               return false;
+       }
+
+       const SaUint32T *smfSSAffectedNodesEnable = 
immutil_getUint32Attr((const SaImmAttrValuesT_2 **)attributes,
+                                                                          
SMF_SS_AFFECTED_NODES_ENABLE_ATTR, 0);
+
+        if ((NULL != smfSSAffectedNodesEnable) && (*smfSSAffectedNodesEnable > 
0)) {
+                //smfSSAffectedNodesEnable is set to "true".
+                //This will override nodes set in SMF config class attr. 
smfClusterControllers
+                //Find the CLM nodes with hard coded default node Id
+                LOG_NO("smfSSAffectedNodesEnable is [true]. SMF handle nodeId 
%x and %x as controllers in SS procedures", SMF_NODE_ID_CONTROLLER_1, 
SMF_NODE_ID_CONTROLLER_2);
+                SaImmSearchHandleT immSearchHandle;
+                SaNameT objectName;
+
+                SaImmAttrNameT attributeNames[] = {
+                        (char*)"saClmNodeID",
+                        NULL
+                };
+                std::list <std::string>  controllers;
+                //If this routine is called early, it has showed the 
saClmNodeID attribute is empty
+                //If empty wait a second and retry
+                bool saClmNodeIDEmpty = true;
+                int retryCntr = 0;
+                while (true == saClmNodeIDEmpty) {
+                        if (immutil.getChildrenAndAttrBySearchHandle("", 
immSearchHandle, SA_IMM_SUBTREE, (SaImmAttrNameT*)attributeNames, "SaClmNode") 
== false) {
+                                LOG_NO("getChildrenAndAttrBySearchHandle 
fail");
+                                //The immSearchHandle is already finalized by 
getChildrenAndAttrBySearchHandle method
+                                TRACE_LEAVE();
+                                return false;
+                        }
+
+                        int ix = 0;
+                        while (immutil_saImmOmSearchNext_2(immSearchHandle, 
&objectName, &attributes) == SA_AIS_OK) {
+                                const SaUint32T *nodeId = 
immutil_getUint32Attr((const SaImmAttrValuesT_2 **)attributes, "saClmNodeID", 
0);
+                                if (nodeId == NULL) {
+                                        (void) 
immutil_saImmOmSearchFinalize(immSearchHandle);
+                                        if (retryCntr >= 10) {  //Retry 10 
times
+                                                LOG_NO("Attribute saClmNodeID 
still empty, giving up");
+                                                TRACE_LEAVE();
+                                                return false;
+                                        }
+                                        saClmNodeIDEmpty = true;  //Continue 
in: while (true == saClmNodeIDEmpty)
+                                        LOG_NO("Attribute saClmNodeID empty, 
wait and retry");
+                                        struct timespec sleepTime = { 2, 0 }; 
//Two seconds
+                                        osaf_nanosleep(&sleepTime);
+                                        retryCntr++;
+                                        break;
+                                }
+                                saClmNodeIDEmpty = false;  //Do not continue 
in: while (true == saClmNodeIDEmpty)                        }
+                                //Use the full CLM node Id as stated in the 
SaClmNode instances
+                                if ((*nodeId == SMF_NODE_ID_CONTROLLER_1) || 
(*nodeId == SMF_NODE_ID_CONTROLLER_2)) {
+                                        smfd_cb->smfClusterControllers[ix] = 
strdup(osaf_extended_name_borrow(&objectName));
+                                        LOG_NO("Cluster controller[%d] = 
%s",ix ,smfd_cb->smfClusterControllers[ix]);
+                                        ix++;
+                                        if (ix == 2) break;  //Two controllers 
found, no need to continue.
+                                }
+                        }
+                        (void) immutil_saImmOmSearchFinalize(immSearchHandle);
+                }
+        } else {
+                LOG_NO("smfSSAffectedNodesEnable is [false], SMF uses 
smfClusterControllers attr. as controllers in SS procedures");
+                //Read new smfClusterControllers values
+                char* controller;
+                for(int ix = 0; (controller = 
(char*)immutil_getStringAttr((const SaImmAttrValuesT_2 **)attributes,
+                                                                           
SMF_CLUSTER_CONTROLLERS_ATTR, ix)) != NULL; ix++) {
+                        if(ix > 1) {
+                                LOG_NO("Maximum of two cluster controllers can 
be defined, controller [%s] ignored", controller);
+                                break;
+                        }
+
+                        smfd_cb->smfClusterControllers[ix] = 
strdup(controller);
+                        LOG_NO("Cluster controller[%d] = %s",ix ,controller);
+                }
+        }
+
+        TRACE_LEAVE();
+        return true;
+}
+
diff --git a/osaf/services/saf/smfsv/smfd/SmfUpgradeStep.hh 
b/osaf/services/saf/smfsv/smfd/SmfUpgradeStep.hh
--- a/osaf/services/saf/smfsv/smfd/SmfUpgradeStep.hh
+++ b/osaf/services/saf/smfsv/smfd/SmfUpgradeStep.hh
@@ -338,6 +338,13 @@ class SmfUpgradeStep {
 /// @return   A list of DNs to AMF nodes
 ///
        const std::list<std::string>  & getSwNodeList();
+  
+///
+/// Purpose:  Get the list of affected nodes (single step)
+/// @param     
+/// @return   A list of DNs to AMF nodes
+///
+       const std::list<std::string>  & getSsAffectedNodeList();
 
 ///
 /// Purpose:  Set type of step
@@ -639,6 +646,12 @@ class SmfUpgradeStep {
        void copyDuInitStateToAu();
 
        bool checkAndInvokeCallback (const std::list < SmfCallback * > 
&callback_list, unsigned int camp_phase);
+///
+/// Purpose:  Read the possibly defined cluster controller names
+/// @param    None
+/// @return   true on success else false
+///
+       bool readSmfClusterControllers();
 
         friend class SmfStepState;
 
@@ -724,6 +737,7 @@ class SmfUpgradeStep {
        std::list < SmfImmOperation * >m_modificationList;
        std::string m_swNode;                // The node where bundles should 
be added/removed
        std::list<std::string> m_swNodeList; // Same as "m_swNode" but for 
single-step
+       std::list<std::string> m_ssAffectedNodeList; // Total list of affected 
nodes in a single-step
        SmfStepType* m_stepType;             // Type of step
         bool     m_switchOver;               // Switchover executed 
 };
diff --git a/osaf/services/saf/smfsv/smfd/smfd_campaign_oi.cc 
b/osaf/services/saf/smfsv/smfd/smfd_campaign_oi.cc
--- a/osaf/services/saf/smfsv/smfd/smfd_campaign_oi.cc
+++ b/osaf/services/saf/smfsv/smfd/smfd_campaign_oi.cc
@@ -1089,80 +1089,11 @@ uint32_t read_config_and_set_control_blo
                 cb->smfClusterControllers[ix] = NULL;
         }
 
-        //Read smfSSAffectedNodesEnable. If >0 (true) the cluster controller 
CLM nodes with node Id 1 and 2
-        //shall override the CLM nodes set in attribute smfClusterControllers.
-       const SaUint32T *smfSSAffectedNodesEnable = 
immutil_getUint32Attr((const SaImmAttrValuesT_2 **)attributes,
-                                                                           
SMF_SS_AFFECTED_NODES_ENABLE_ATTR, 0);
-
-        if ((NULL != smfSSAffectedNodesEnable) && (*smfSSAffectedNodesEnable > 
0)) {
-                //smfSSAffectedNodesEnable is set to "true".
-                //This will override nodes set in SMF config class attr. 
smfClusterControllers
-                //Find the CLM nodes with hard coded default node Id
-                LOG_NO("smfSSAffectedNodesEnable is [true]. SMF handle nodeId 
%x and %x as controllers in SS procedures", SMF_NODE_ID_CONTROLLER_1, 
SMF_NODE_ID_CONTROLLER_2);
-                SaImmAttrValuesT_2 **attributes;
-                SaImmSearchHandleT immSearchHandle;
-                SaNameT objectName;
-
-                SaImmAttrNameT attributeNames[] = {
-                        (char*)"saClmNodeID",
-                        NULL
-                };
-                std::list <std::string>  controllers;
-                //If this routine is called early, it has showed the 
saClmNodeID attribute is empty
-                //If empty wait a second and retry
-                bool saClmNodeIDEmpty = true;
-                int retryCntr = 0;
-                while (true == saClmNodeIDEmpty) {
-                        if (immutil.getChildrenAndAttrBySearchHandle("", 
immSearchHandle, SA_IMM_SUBTREE, (SaImmAttrNameT*)attributeNames, "SaClmNode") 
== false) {
-                                LOG_NO("getChildrenAndAttrBySearchHandle 
fail");
-                                //The immSearchHandle is already finalized by 
getChildrenAndAttrBySearchHandle method
-                                TRACE_LEAVE();
-                                return NCSCC_RC_FAILURE;
-                        }
-
-                        int ix = 0;
-                        while (immutil_saImmOmSearchNext_2(immSearchHandle, 
&objectName, &attributes) == SA_AIS_OK) {
-                                const SaUint32T *nodeId = 
immutil_getUint32Attr((const SaImmAttrValuesT_2 **)attributes, "saClmNodeID", 
0);
-                                if (nodeId == NULL) {
-                                        (void) 
immutil_saImmOmSearchFinalize(immSearchHandle);
-                                        if (retryCntr >= 10) {  //Retry 10 
times
-                                                LOG_NO("Attribute saClmNodeID 
still empty, giving up");
-                                                TRACE_LEAVE();
-                                                return NCSCC_RC_FAILURE;
-                                        }
-                                        saClmNodeIDEmpty = true;  //Continue 
in: while (true == saClmNodeIDEmpty)
-                                        LOG_NO("Attribute saClmNodeID empty, 
wait and retry");
-                                        struct timespec sleepTime = { 1, 0 }; 
//One second
-                                        osaf_nanosleep(&sleepTime);
-                                        retryCntr++;
-                                        break;
-                                }
-                                saClmNodeIDEmpty = false;  //Do not continue 
in: while (true == saClmNodeIDEmpty)                        }
-                                //Use the full CLM node Id as stated in the 
SaClmNode instances
-                                if ((*nodeId == SMF_NODE_ID_CONTROLLER_1) || 
(*nodeId == SMF_NODE_ID_CONTROLLER_2)) {
-                                        cb->smfClusterControllers[ix] = 
strdup(osaf_extended_name_borrow(&objectName));
-                                        LOG_NO("Cluster controller[%d] = 
%s",ix ,cb->smfClusterControllers[ix]);
-                                        ix++;
-                                        if (ix == 2) break;  //Two controllers 
found, no need to continue.
-                                }
-                        }
-                        (void) immutil_saImmOmSearchFinalize(immSearchHandle);
-                }
-        } else {
-                LOG_NO("smfSSAffectedNodesEnable is [false], SMF uses 
smfClusterControllers attr. as controllers in SS procedures");
-                //Read new smfClusterControllers values
-                char* controller;
-                for(int ix = 0; (controller = 
(char*)immutil_getStringAttr((const SaImmAttrValuesT_2 **)attributes,
-                                                                           
SMF_CLUSTER_CONTROLLERS_ATTR, ix)) != NULL; ix++) {
-                        if(ix > 1) {
-                                LOG_NO("Maximum of two cluster controllers can 
be defined, controller [%s] ignored", controller);
-                                break;
-                        }
-
-                        cb->smfClusterControllers[ix] = strdup(controller);
-                        LOG_NO("Cluster controller[%d] = %s",ix ,controller);
-                }
-        }
+        //Reading of smfSSAffectedNodesEnable and/or smfClusterControllers 
have been moved.
+        //because the CLM saClmNodeID is not filled in until the CLM-node have 
joined the cluster.
+        //If read here it is a risk SMF csiSet will timeout because of late 
CLM-node join.
+        //Read the attributes just before they shall be used in the procedure.
+        //Moved to SmfUpgradeStep.cc method calculateStepType().
 
        const SaUint32T *keepDuState = immutil_getUint32Attr((const 
SaImmAttrValuesT_2 **)attributes,
                        SMF_KEEP_DU_STATE_ATTR, 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