osaf/services/saf/smfsv/smfd/SmfUpgradeStep.cc |  51 ++++++++++++++++---------
 1 files changed, 33 insertions(+), 18 deletions(-)


If a node group for admin operation already exist when create is done the
existing group shall be deleted so that the new group can be created

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
@@ -3537,24 +3537,39 @@ bool SmfAdminOperation::createNodeGroup(
 
        // ------------------------------------
        // Create the node group
-       m_errno = immutil_saImmOmCcbObjectCreate_2(
-           m_ccbHandle,
-           className,
-           &nodeGroupParentDn,
-           attrValues);
-
-       if (m_errno != SA_AIS_OK) {
-               LOG_NO("%s: saImmOmCcbObjectCreate_2() '%s' Fail %s",
-                       __FUNCTION__, nGnodeName, saf_error(m_errno));
-               rc = false;
-       } else {
-               m_errno = saImmOmCcbApply(m_ccbHandle);
-               if (m_errno != SA_AIS_OK) {
-               LOG_NO("%s: saImmOmCcbApply() Fail '%s'",
-                       __FUNCTION__, saf_error(m_errno));
-                       rc = false;
-               }
-       }
+        while (true) {
+                m_errno = immutil_saImmOmCcbObjectCreate_2(
+                    m_ccbHandle,
+                    className,
+                    &nodeGroupParentDn,
+                    attrValues);
+
+                if (m_errno == SA_AIS_ERR_EXIST) {
+                        // A node group with the same name already exist
+                        // May happen if delete after usage has failed
+                        bool rc = deleteNodeGroup();
+                        if (rc == false) {
+                                LOG_NO("%s: deleteNodeGroup() Fail",
+                                       __FUNCTION__);
+                                break;
+                        }
+                        continue;
+                }
+                if (m_errno != SA_AIS_OK) {
+                        LOG_NO("%s: saImmOmCcbObjectCreate_2() '%s' Fail %s",
+                                __FUNCTION__, nGnodeName, saf_error(m_errno));
+                        rc = false;
+                        break;
+                } else {
+                        m_errno = saImmOmCcbApply(m_ccbHandle);
+                        if (m_errno != SA_AIS_OK) {
+                        LOG_NO("%s: saImmOmCcbApply() Fail '%s'",
+                                __FUNCTION__, saf_error(m_errno));
+                                rc = false;
+                        }
+                        break;
+                }
+        }
 
        if (nodeName != NULL)
                free(nodeName);

------------------------------------------------------------------------------
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to