osaf/services/saf/amf/amfd/sg.cc | 99 +++++++++++++++++++++++++++++++++++++-- 1 files changed, 94 insertions(+), 5 deletions(-)
The SG configuration attribute saAmfSGSuHostNodeGroup cannot be changed. If an application starts off with a node group such as "SCs" it cannot get out of it without complex model changes. The validation in sg.cc by design disallow the change. In this patch the validation is changed to allow change of node group to another group that is a superset of the old one. diff --git a/osaf/services/saf/amf/amfd/sg.cc b/osaf/services/saf/amf/amfd/sg.cc --- a/osaf/services/saf/amf/amfd/sg.cc +++ b/osaf/services/saf/amf/amfd/sg.cc @@ -481,6 +481,87 @@ done1: return error; } +/** + * Check if the node represented by nodename is a member of node group ng + * @param nodename + * @param ng + * @return + */ +static bool node_in_ng(const SaNameT *nodename, const AVD_AMF_NG *ng) +{ + for (unsigned i = 0; i < ng->number_nodes; i++) { + if (strncmp((char*)nodename->value, + (char*)ng->saAmfNGNodeList[i].value, SA_MAX_NAME_LENGTH) == 0) + return true; + } + + return false; +} + +/** + * Check if the node group represented by ngname is a subset of the node group + * represented by supername + * @param ngname + * @param supername + * @return true/false + */ +static bool ng_is_subset(const SaNameT *ngname, const AVD_AMF_NG *superng) +{ + const AVD_AMF_NG *ng = avd_ng_get(ngname); + const SaNameT *nodename; + + if (superng->number_nodes < ng->number_nodes) + return false; + + for (unsigned i = 0; i < ng->number_nodes; i++) { + nodename = &ng->saAmfNGNodeList[i]; + + if (node_in_ng(nodename, superng) == false) + return false; + } + + return true; +} + +/** + * Validate if the change in node group value is OK, report to IMM otherwise + * @param sg + * @param ng_name + * @param opdata + * @return true/false + */ +static bool ng_change_is_valid(const AVD_SG *sg, const SaNameT *ng_name, + const CcbUtilOperationData_t *opdata) +{ + if (sg->saAmfSGSuHostNodeGroup.length > 0) { + // A node group is currently configured for SG. A user wants + // to change it. Validate that the old node group is subset + // of the new one. + + const AVD_AMF_NG *ng = avd_ng_get(ng_name); + if (ng == NULL) { + report_ccb_validation_error(opdata, + "Node Group '%s' not found", ng_name->value); + return false; + } + + if (ng_is_subset(&sg->saAmfSGSuHostNodeGroup, ng) == false) { + report_ccb_validation_error(opdata, + "'%s' is not a subset of '%s'", + sg->saAmfSGSuHostNodeGroup.value, ng_name->value); + return false; + } + } else { + // a node group is currently not configured for this SG + // don't allow configuring it now, why? + report_ccb_validation_error(opdata, + "Attribute saAmfSGSuHostNodeGroup cannot be modified"); + return false; + } + + return true; +} + static SaAisErrorT ccb_completed_modify_hdlr(const CcbUtilOperationData_t *opdata) { SaAisErrorT rc = SA_AIS_OK; @@ -529,11 +610,10 @@ static SaAisErrorT ccb_completed_modify_ } } else if (!strcmp(attribute->attrName, "saAmfSGSuHostNodeGroup")) { - report_ccb_validation_error(opdata, - "%s: Attribute saAmfSGSuHostNodeGroup cannot be modified", - __FUNCTION__); - rc = SA_AIS_ERR_BAD_OPERATION; - goto done; + if (ng_change_is_valid(sg, (SaNameT *)value, opdata) == false) { + rc = SA_AIS_ERR_BAD_OPERATION; + goto done; + } } else if (!strcmp(attribute->attrName, "saAmfSGAutoAdjust")) { } else if (!strcmp(attribute->attrName, "saAmfSGNumPrefActiveSUs")) { } else if (!strcmp(attribute->attrName, "saAmfSGNumPrefStandbySUs")) { @@ -610,6 +690,11 @@ static SaAisErrorT ccb_completed_modify_ rc = SA_AIS_ERR_BAD_OPERATION; goto done; } + } else if (!strcmp(attribute->attrName, "saAmfSGSuHostNodeGroup")) { + if (ng_change_is_valid(sg, (SaNameT *)value, opdata) == false) { + rc = SA_AIS_ERR_BAD_OPERATION; + goto done; + } } else { report_ccb_validation_error(opdata, "%s: Attribute '%s' cannot be modified when SG is unlocked", @@ -863,6 +948,8 @@ static void ccb_apply_modify_hdlr(CcbUti sg->saAmfSGSuRestartMax = *((SaUint32T *)value); TRACE("Modified saAmfSGSuRestartMax is '%u'", sg->saAmfSGSuRestartMax); sg_nd_attribute_update(sg, saAmfSGSuRestartMax_ID); + } else if (!strcmp(attribute->attrName, "saAmfSGSuHostNodeGroup")) { + sg->saAmfSGSuHostNodeGroup = *((SaNameT *)value); } else { osafassert(0); } @@ -937,6 +1024,8 @@ static void ccb_apply_modify_hdlr(CcbUti sg->saAmfSGAutoRepair_configured = true; } TRACE("Modified saAmfSGAutoRepair is '%u'", sg->saAmfSGAutoRepair); + } else if (!strcmp(attribute->attrName, "saAmfSGSuHostNodeGroup")) { + sg->saAmfSGSuHostNodeGroup = *((SaNameT *)value); } else { osafassert(0); } ------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel