ack, code review only. Minor comments below. The AMF Prog. Ref needs updates too.
/Thanks HansN On 11/03/2016 10:37 AM, [email protected] wrote: > osaf/services/saf/amf/amfd/imm.cc | 63 > ++++++++++++++++++++++++++++++++ > osaf/services/saf/amf/amfd/include/imm.h | 7 +++ > osaf/services/saf/amf/amfd/su.cc | 31 ++++++++++++--- > 3 files changed, 95 insertions(+), 6 deletions(-) > > > diff --git a/osaf/services/saf/amf/amfd/imm.cc > b/osaf/services/saf/amf/amfd/imm.cc > --- a/osaf/services/saf/amf/amfd/imm.cc > +++ b/osaf/services/saf/amf/amfd/imm.cc > @@ -1635,6 +1635,69 @@ SaAisErrorT avd_saImmOiRtObjectUpdate_sy > } > > /** > + * IM object update, BLOCKING. It updates multivalue attributes. > + * @param dn > + * @param attributeName > + * @param attrValueType > + * @param attrValues > + * @param assigned_si > + */ > +SaAisErrorT avd_saImmOiRtObjectUpdate_multival_sync(const std::string& dn, > SaImmAttrNameT attributeName, > + SaImmValueTypeT attrValueType, SaImmAttrValueT *attrValues, > uint32_t assigned_si, > + SaImmAttrModificationTypeT modifyType) > +{ > + SaAisErrorT rc; > + SaImmAttrModificationT_2 attrMod; > + const SaImmAttrModificationT_2 *attrMods[] = {&attrMod, nullptr}; > + > + TRACE_ENTER2("'%s' %s", dn.c_str(), attributeName); > + > + attrMod.modType = modifyType; > + attrMod.modAttr.attrName = attributeName; > + attrMod.modAttr.attrValuesNumber = assigned_si; > + attrMod.modAttr.attrValueType = attrValueType; > + attrMod.modAttr.attrValues = attrValues; > + > + rc = saImmOiRtObjectUpdate_o3(avd_cb->immOiHandle, dn.c_str(), > attrMods); > + if (rc != SA_AIS_OK) { > + LOG_WA("saImmOiRtObjectUpdate of '%s' %s failed with %u", > + dn.c_str(), attributeName, rc); > + } > + return rc; > +} > + > + > +/** > + * IM object update, BLOCKING. It replaces the attr values to null. > + * @param dn > + * @param attributeName > + * @param attrValueType > + * @param value > + */ > +SaAisErrorT avd_saImmOiRtObjectUpdate_replace_sync(const std::string& dn, > SaImmAttrNameT attributeName, > + SaImmValueTypeT attrValueType, void *value, > + SaImmAttrModificationTypeT modifyType) > +{ > + SaAisErrorT rc; > + SaImmAttrModificationT_2 attrMod; > + const SaImmAttrModificationT_2 *attrMods[] = {&attrMod, nullptr}; > + > + TRACE_ENTER2("'%s' %s", dn.c_str(), attributeName); > + > + attrMod.modType = SA_IMM_ATTR_VALUES_REPLACE; > + attrMod.modAttr.attrName = attributeName; > + attrMod.modAttr.attrValuesNumber = 0; > + attrMod.modAttr.attrValueType = attrValueType; > + > + rc = saImmOiRtObjectUpdate_o3(avd_cb->immOiHandle, dn.c_str(), > attrMods); > + if (rc != SA_AIS_OK) { > + LOG_WA("saImmOiRtObjectUpdate of '%s' %s failed with %u", > + dn.c_str(), attributeName, rc); > + } > + return rc; > +} > + > +/** > * @brief As of now standby AMFD will maintain immjobs for object of few > classes. > * This function checks if immjobs for this object can be > maintained at standby. > * > diff --git a/osaf/services/saf/amf/amfd/include/imm.h > b/osaf/services/saf/amf/amfd/include/imm.h > --- a/osaf/services/saf/amf/amfd/include/imm.h > +++ b/osaf/services/saf/amf/amfd/include/imm.h > @@ -153,6 +153,13 @@ extern unsigned int avd_imm_config_get(v > extern SaAisErrorT avd_saImmOiRtObjectUpdate_sync(const std::string& dn, > SaImmAttrNameT attributeName, SaImmValueTypeT attrValueType, > void *value, > SaImmAttrModificationTypeT modifyType = > SA_IMM_ATTR_VALUES_REPLACE); > +extern SaAisErrorT avd_saImmOiRtObjectUpdate_multival_sync(const > std::string& dn, > + SaImmAttrNameT attributeName, SaImmValueTypeT attrValueType, > SaImmAttrValueT *value, > + uint32_t assigned_si, > + SaImmAttrModificationTypeT modifyType = > SA_IMM_ATTR_VALUES_REPLACE); > +extern SaAisErrorT avd_saImmOiRtObjectUpdate_replace_sync(const std::string& > dn, > + SaImmAttrNameT attributeName, SaImmValueTypeT attrValueType, > void *value, > + SaImmAttrModificationTypeT modifyType = > SA_IMM_ATTR_VALUES_REPLACE); > extern void avd_saImmOiRtObjectUpdate(const std::string& dn, const > std::string& attributeName, > SaImmValueTypeT attrValueType, void* value); > extern void avd_saImmOiRtObjectCreate(const std::string& lassName, > diff --git a/osaf/services/saf/amf/amfd/su.cc > b/osaf/services/saf/amf/amfd/su.cc > --- a/osaf/services/saf/amf/amfd/su.cc > +++ b/osaf/services/saf/amf/amfd/su.cc > @@ -1390,12 +1390,31 @@ static SaAisErrorT su_rt_attr_cb(SaImmOi > > while ((attributeName = attributeNames[i++]) != nullptr) { > if (!strcmp("saAmfSUAssignedSIs", attributeName)) { > -#if 0 > - /* TODO */ > - SaUint32T saAmfSUAssignedSIs = > su->saAmfSUNumCurrActiveSIs + su->saAmfSUNumCurrStandbySIs; > - avd_saImmOiRtObjectUpdate_sync(immOiHandle, objectName, > - attributeName, SA_IMM_ATTR_SAUINT32T, > &saAmfSUAssignedSIs); > -#endif > + if (su->list_of_susi != nullptr) { > + uint32_t assigned_si = > su->saAmfSUNumCurrActiveSIs + su->saAmfSUNumCurrStandbySIs; > + int size = (sizeof(SaImmAttrValueT *) * > (assigned_si)); > + SaImmAttrValueT *attrValues = (void > **)malloc(size); > + SaNameT *siName = (SaNameT > *)malloc(sizeof(SaNameT) * assigned_si); [HansN] use new instead of malloc. Avoid C-style casts. > + SaImmAttrValueT *temp = attrValues; > + int j = 0; > + for (AVD_SU_SI_REL *susi = su->list_of_susi; > susi != nullptr; susi = susi->su_next) { > + > osaf_extended_name_alloc(susi->si->name.c_str(), (siName + j)); > + attrValues[j] = (void *)(siName + j); > + j = j + 1; > + } > + rc = > avd_saImmOiRtObjectUpdate_multival_sync(obj_name, attributeName, > + SA_IMM_ATTR_SANAMET, temp, > assigned_si); > + for (AVD_SU_SI_REL *susi = su->list_of_susi; > susi != nullptr; susi = susi->su_next) { > + j = 0; > + osaf_extended_name_free(siName + j); > + } > + free(siName); [HansN] use delete instead of free. > + } else { > + SaNameT siName; > + memset(((uint8_t *)&siName), '\0', > sizeof(siName)); > + rc = > avd_saImmOiRtObjectUpdate_replace_sync(obj_name, attributeName, > + SA_IMM_ATTR_SANAMET, nullptr); > + } > } else if (!strcmp("saAmfSUNumCurrActiveSIs", attributeName)) { > rc = avd_saImmOiRtObjectUpdate_sync(obj_name, > attributeName, > SA_IMM_ATTR_SAUINT32T, > &su->saAmfSUNumCurrActiveSIs); ------------------------------------------------------------------------------ _______________________________________________ Opensaf-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/opensaf-devel
