I will refloat the patch after incorporating comments. Thanks, Praveen On 24-Jun-13 4:33 PM, Hans Feldt wrote: > Hi, > > See inline. > > Thanks, > Hans > > > On 7 June 2013 08:39, <[email protected]> wrote: >> osaf/services/saf/avsv/avd/avd_sg.cc | 16 +++- >> osaf/services/saf/avsv/avd/avd_sgtype.cc | 114 >> +++++++++++++++++++++++++++- >> osaf/services/saf/avsv/avd/include/avd_sg.h | 3 +- >> 3 files changed, 128 insertions(+), 5 deletions(-) >> >> >> The patch allows ccb modify operation on attribute saAmfSGDefAutoRepair of >> class SaAmfSGType and saAmfSgAutoRepair of class SaAmfSG. >> >> diff --git a/osaf/services/saf/avsv/avd/avd_sg.cc >> b/osaf/services/saf/avsv/avd/avd_sg.cc >> --- a/osaf/services/saf/avsv/avd/avd_sg.cc >> +++ b/osaf/services/saf/avsv/avd/avd_sg.cc >> @@ -293,7 +293,10 @@ static AVD_SG *sg_create(const SaNameT * >> >> if >> (immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfSGAutoRepair"), >> attributes, 0, &sg->saAmfSGAutoRepair) != SA_AIS_OK) { >> sg->saAmfSGAutoRepair = sgt->saAmfSgtDefAutoRepair; >> + sg->sgautorepair_conf = false; > with same reasoning as in previous reply, change name to > "saAmfSgtDefAutoRepair_configured" > >> } >> + else >> + sg->sgautorepair_conf = true; >> >> if >> (immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfSGAutoAdjust"), >> attributes, 0, &sg->saAmfSGAutoAdjust) != SA_AIS_OK) { >> sg->saAmfSGAutoAdjust = sgt->saAmfSgtDefAutoAdjust; >> @@ -527,6 +530,12 @@ static SaAisErrorT ccb_completed_modify_ >> rc = SA_AIS_ERR_BAD_OPERATION; >> goto done; >> } else if (!strcmp(attribute->attrName, >> "saAmfSGAutoRepair")) { >> + uint32_t sg_autorepair = *((SaUint32T >> *)attribute->attrValues[0]); >> + if (sg_autorepair > SA_TRUE) { >> + LOG_ER("Invalid saAmfSGAutoRepair >> SG:'%s'", avd_sg->name.value); >> + 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")) { >> @@ -744,10 +753,13 @@ static void ccb_apply_modify_hdlr(CcbUti >> sg_nd_attribute_update(sg, >> saAmfSGCompRestartProb_ID); >> sg_nd_attribute_update(sg, >> saAmfSGCompRestartMax_ID); >> } else if (!strcmp(attribute->attrName, >> "saAmfSGAutoRepair")) { >> - if (value_is_deleted) >> + if (value_is_deleted) { >> sg->saAmfSGAutoRepair = >> sg_type->saAmfSgtDefAutoRepair; >> - else >> + sg->sgautorepair_conf = false; >> + } else { >> sg->saAmfSGAutoRepair = >> static_cast<SaBoolT>(*((SaUint32T *)value)); >> + sg->sgautorepair_conf = true; >> + } >> } else if (!strcmp(attribute->attrName, >> "saAmfSGAutoAdjust")) { >> if (value_is_deleted) >> sg->saAmfSGAutoAdjust = >> sg_type->saAmfSgtDefAutoAdjust; >> diff --git a/osaf/services/saf/avsv/avd/avd_sgtype.cc >> b/osaf/services/saf/avsv/avd/avd_sgtype.cc >> --- a/osaf/services/saf/avsv/avd/avd_sgtype.cc >> +++ b/osaf/services/saf/avsv/avd/avd_sgtype.cc >> @@ -28,6 +28,8 @@ >> #include <avd_proc.h> >> >> static NCS_PATRICIA_TREE sgtype_db; >> +static void sgtype_ccb_apply_modify_hdlr(struct CcbUtilOperationData >> *opdata); >> +static SaAisErrorT sgtype_ccb_completed_modify_hdlr(CcbUtilOperationData_t >> *opdata); >> >> void avd_sgtype_add_sg(AVD_SG *sg) >> { >> @@ -221,7 +223,10 @@ static AVD_AMF_SG_TYPE *sgtype_create(Sa >> >> if >> (immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfSgtDefAutoRepair"), >> attributes, 0, &sgt->saAmfSgtDefAutoRepair) != SA_AIS_OK) { >> sgt->saAmfSgtDefAutoRepair = SA_TRUE; >> + sgt->sgdefautorepair_conf = false; >> } >> + else >> + sgt->sgdefautorepair_conf = true; >> >> if >> (immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfSgtDefAutoAdjust"), >> attributes, 0, &sgt->saAmfSgtDefAutoAdjust) != SA_AIS_OK) { >> sgt->saAmfSgtDefAutoAdjust = SA_FALSE; >> @@ -336,8 +341,7 @@ static SaAisErrorT sgtype_ccb_completed_ >> rc = SA_AIS_OK; >> break; >> case CCBUTIL_MODIFY: >> - LOG_ER("Modification of SaAmfSGType not supported"); >> - goto done; >> + rc = sgtype_ccb_completed_modify_hdlr(opdata); >> break; >> case CCBUTIL_DELETE: >> sgt = avd_sgtype_get(&opdata->objectName); >> @@ -390,6 +394,9 @@ static void sgtype_ccb_apply_cb(CcbUtilO >> osafassert(sgt); >> sgtype_add_to_model(sgt); >> break; >> + case CCBUTIL_MODIFY: >> + sgtype_ccb_apply_modify_hdlr(opdata); >> + break; >> case CCBUTIL_DELETE: >> >> sgtype_delete(static_cast<AVD_AMF_SG_TYPE*>(opdata->userData)); >> break; >> @@ -411,3 +418,106 @@ void avd_sgtype_constructor(void) >> avd_class_impl_set(const_cast<SaImmClassNameT>("SaAmfSGBaseType"), >> NULL, NULL, avd_imm_default_OK_completed_cb, NULL); >> } >> >> +/** >> + * This routine validates modify CCB operations on SaAmfSGType objects. >> + * @param Ccb Util Oper Data >> + * @return >> + */ >> + >> +static SaAisErrorT sgtype_ccb_completed_modify_hdlr(CcbUtilOperationData_t >> *opdata) >> +{ >> + SaAisErrorT rc = SA_AIS_OK; >> + const SaImmAttrModificationT_2 *attr_mod; >> + int i = 0; >> + AVD_AMF_SG_TYPE *sgt; >> + >> + sgt = avd_sgtype_get(&opdata->objectName); > define and initialize in one go > >> + >> + TRACE_ENTER2("CCB ID %llu, '%s'", opdata->ccbId, >> opdata->objectName.value); >> + while ((attr_mod = opdata->param.modify.attrMods[i++]) != NULL) { >> + >> + if ((attr_mod->modType == SA_IMM_ATTR_VALUES_DELETE) || >> (attr_mod->modAttr.attrValues == NULL)) >> + continue; >> + >> + if (!strcmp(attr_mod->modAttr.attrName, >> "saAmfSgtDefAutoRepair")) { >> + AVD_SG *sg = sgt->list_of_sg; > move down > >> + uint32_t sgt_autorepair = *((SaUint32T >> *)attr_mod->modAttr.attrValues[0]); >> + >> + if (sgt_autorepair > SA_TRUE) { >> + LOG_ER("invalid saAmfSgtDefAutoRepair >> in:'%s'", sgt->name.value); >> + rc = SA_AIS_ERR_BAD_OPERATION; >> + goto done; >> + } >> + >> + while (sg != NULL) { > use for loop > >> + if (sg->sgautorepair_conf) { >> + sg = sg->sg_list_sg_type_next; > remove with for loop > >> + continue; >> + } >> + if (sg->saAmfSGAdminState != >> SA_AMF_ADMIN_LOCKED_INSTANTIATION) { >> + >> + rc = SA_AIS_ERR_BAD_OPERATION; >> + LOG_WA("SG state is not in Lock-in >> state:'%s'",sg->name.value); >> + goto done; >> + } >> + sg = sg->sg_list_sg_type_next; >> + } >> + } else { >> + LOG_ER("Modification of attribute is Not >> Supported:'%s' ", attr_mod->modAttr.attrName); >> + rc = SA_AIS_ERR_BAD_OPERATION; >> + goto done; >> + } >> + } >> + >> +done: >> + return rc; >> +} >> +/** >> + * This function handles modify operations on SaAmfSGType objects. >> + * @param ptr to opdata >> + */ >> +static void sgtype_ccb_apply_modify_hdlr(struct CcbUtilOperationData >> *opdata) >> +{ >> + const SaImmAttrModificationT_2 *attr_mod; >> + int i = 0; >> + AVD_AMF_SG_TYPE *sgt; >> + AVD_SG *sg; > move down > >> + bool value_is_deleted; >> + SaBoolT old_value; >> + >> + TRACE_ENTER2("CCB ID %llu, '%s'", opdata->ccbId, >> opdata->objectName.value); >> + >> + sgt = avd_sgtype_get(&opdata->objectName); >> + >> + while ((attr_mod = opdata->param.modify.attrMods[i++]) != NULL) { >> + if ((attr_mod->modType == SA_IMM_ATTR_VALUES_DELETE) || >> (attr_mod->modAttr.attrValues == NULL)) >> + /* Attribute value is deleted, revert to default >> value */ >> + value_is_deleted = true; >> + else >> + /* Attribute value is modified */ >> + value_is_deleted = false; >> + >> + if (!strcmp(attr_mod->modAttr.attrName, >> "saAmfSgtDefAutoRepair")) { >> + old_value = sgt->saAmfSgtDefAutoRepair; >> + if (value_is_deleted) { >> + sgt->saAmfSgtDefAutoRepair = >> static_cast<SaBoolT>(true); >> + sgt->sgdefautorepair_conf = false; >> + } else { >> + sgt->saAmfSgtDefAutoRepair = >> static_cast<SaBoolT>(*((SaUint32T *)attr_mod->modAttr.attrValues[0])); >> + sgt->sgdefautorepair_conf = true; >> + } >> + /* Modify saAmfSGAutoRepair for SGs which had >> inherited saAmfSgtDefAutoRepair.*/ >> + if (old_value != sgt->saAmfSgtDefAutoRepair) { >> + sg = sgt->list_of_sg; >> + while (sg != NULL) { > use for loop > >> + if (!sg->sgautorepair_conf) >> + sg->saAmfSGAutoRepair = >> static_cast<SaBoolT>(sgt->saAmfSgtDefAutoRepair); >> + sg = sg->sg_list_sg_type_next; >> + } >> + } >> + } >> + } >> + >> + TRACE_LEAVE(); >> +} >> + >> diff --git a/osaf/services/saf/avsv/avd/include/avd_sg.h >> b/osaf/services/saf/avsv/avd/include/avd_sg.h >> --- a/osaf/services/saf/avsv/avd/include/avd_sg.h >> +++ b/osaf/services/saf/avsv/avd/include/avd_sg.h >> @@ -69,6 +69,7 @@ typedef struct avd_sg_tag { >> * Checkpointing - Sent as a one time >> update. >> */ >> >> + bool sgautorepair_conf; /* True when user configures >> saAmfSGAutoRepair else false */ >> /******************** B.04 model >> *************************************************/ >> SaNameT saAmfSGType; /* Network order. */ >> SaNameT saAmfSGSuHostNodeGroup; /* Network order. */ >> @@ -242,7 +243,7 @@ typedef struct avd_sg_tag { >> typedef struct avd_amf_sg_type_tag { >> NCS_PATRICIA_NODE tree_node; /* key will be sg type name */ >> SaNameT name; >> - >> + bool sgdefautorepair_conf; /* True when user configures >> saAmfSGDefAutoRepair else false */ >> /******************** B.04 model >> *************************************************/ >> SaNameT *saAmfSGtValidSuTypes; /* array of DNs, size in >> number_su_type */ >> SaAmfRedundancyModelT saAmfSgtRedundancyModel; >> >> ------------------------------------------------------------------------------ >> How ServiceNow helps IT people transform IT departments: >> 1. A cloud service to automate IT design, transition and operations >> 2. Dashboards that offer high-level views of enterprise services >> 3. A single system of record for all IT processes >> http://p.sf.net/sfu/servicenow-d2d-j >> _______________________________________________ >> Opensaf-devel mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/opensaf-devel
------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev _______________________________________________ Opensaf-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/opensaf-devel
