osaf/services/saf/amf/amfd/su.cc | 444 ++++++++++++++------------ osaf/services/saf/amf/amfd/sutcomptype.cc | 25 +- osaf/services/saf/amf/amfd/sutype.cc | 65 ++- osaf/services/saf/amf/amfd/svctype.cc | 44 +- osaf/services/saf/amf/amfd/svctypecstypes.cc | 39 +- 5 files changed, 329 insertions(+), 288 deletions(-)
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 @@ -36,7 +36,7 @@ void AVD_SU::initialize() { saAmfSURank = 0; - saAmfSUHostNodeOrNodeGroup.length = 0; + saAmfSUHostNodeOrNodeGroup = ""; saAmfSUFailover = false; saAmfSUFailover_configured = false; saAmfSUPreInstantiable = SA_FALSE; @@ -57,10 +57,9 @@ list_of_comp = {}; su_type = nullptr; su_list_su_type_next = nullptr; - name.length = 0; - saAmfSUType.length = 0; - saAmfSUMaintenanceCampaign.length = 0; - saAmfSUHostedByNode.length = 0; + saAmfSUType = ""; + saAmfSUMaintenanceCampaign = ""; + saAmfSUHostedByNode = ""; pend_cbk.invocation = 0; pend_cbk.admin_oper = (SaAmfAdminOperationIdT)0; surestart = false; @@ -70,10 +69,10 @@ initialize(); } -AVD_SU::AVD_SU(const SaNameT *dn) { +AVD_SU::AVD_SU(const std::string& dn) : + name(dn) +{ initialize(); - memcpy(name.value, dn->value, sizeof(name.value)); - name.length = dn->length; } /** @@ -81,7 +80,7 @@ * to node director. */ void AVD_SU::remove_from_model() { - TRACE_ENTER2("'%s'", name.value); + TRACE_ENTER2("'%s'", name.c_str()); /* All the components under this SU should have been deleted * by now, just do the sanity check to confirm it is done @@ -92,7 +91,7 @@ m_AVSV_SEND_CKPT_UPDT_ASYNC_RMV(avd_cb, this, AVSV_CKPT_AVD_SU_CONFIG); avd_node_remove_su(this); avd_sutype_remove_su(this); - su_db->erase(Amf::to_string(&name)); + su_db->erase(name); avd_sg_remove_su(this); TRACE_LEAVE(); @@ -179,27 +178,30 @@ * * @return int */ -static int is_config_valid(const SaNameT *dn, const SaImmAttrValuesT_2 **attributes, +static int is_config_valid(const std::string& dn, const SaImmAttrValuesT_2 **attributes, const CcbUtilOperationData_t *opdata) { SaAisErrorT rc; - SaNameT saAmfSUType, sg_name; - SaNameT saAmfSUHostNodeOrNodeGroup = {0}, saAmfSGSuHostNodeGroup = {0}; + std::string sg_name; + std::string su_host_node_or_nodegroup; + std::string sg_su_host_nodegroup; + SaNameT saAmfSUHostNodeOrNodeGroup = {0}; + SaNameT saAmfSUType; SaBoolT abool; SaAmfAdminStateT admstate; - char *parent; + std::string::size_type pos; SaUint32T saAmfSutIsExternal; AVD_SUTYPE *sut = nullptr; CcbUtilOperationData_t *tmp; AVD_SG *sg; - if ((parent = strchr((char*)dn->value, ',')) == nullptr) { - report_ccb_validation_error(opdata, "No parent to '%s' ", dn->value); + if ((pos = dn.find(',')) == std::string::npos) { + report_ccb_validation_error(opdata, "No parent to '%s' ", dn.c_str()); return 0; } - if (strncmp(++parent, "safSg=", 6) != 0) { - report_ccb_validation_error(opdata, "Wrong parent '%s' to '%s' ", parent, dn->value); + if (dn.compare(pos + 1, 6, "safSg=") != 0) { + report_ccb_validation_error(opdata, "Wrong parent '%s' to '%s' ", dn.substr(pos + 1).c_str(), dn.c_str()); return 0; } @@ -228,34 +230,35 @@ /* Validate that a configured node or node group exist */ if (immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfSUHostNodeOrNodeGroup"), attributes, 0, &saAmfSUHostNodeOrNodeGroup) == SA_AIS_OK) { - if (strncmp((char*)saAmfSUHostNodeOrNodeGroup.value, "safAmfNode=", 11) == 0) { - if (avd_node_get(&saAmfSUHostNodeOrNodeGroup) == nullptr) { + su_host_node_or_nodegroup = Amf::to_string(&saAmfSUHostNodeOrNodeGroup); + if (su_host_node_or_nodegroup.compare(0, 11, "safAmfNode=") == 0) { + if (avd_node_get(su_host_node_or_nodegroup) == nullptr) { if (opdata == nullptr) { report_ccb_validation_error(opdata, "'%s' does not exist in model", - saAmfSUHostNodeOrNodeGroup.value); + su_host_node_or_nodegroup.c_str()); return 0; } if (ccbutil_getCcbOpDataByDN(opdata->ccbId, &saAmfSUHostNodeOrNodeGroup) == nullptr) { report_ccb_validation_error(opdata, "'%s' does not exist in existing model or in CCB", - saAmfSUHostNodeOrNodeGroup.value); + su_host_node_or_nodegroup.c_str()); return 0; } } } else { - if (avd_ng_get(&saAmfSUHostNodeOrNodeGroup) == nullptr) { + if (avd_ng_get(su_host_node_or_nodegroup) == nullptr) { if (opdata == nullptr) { report_ccb_validation_error(opdata, "'%s' does not exist in model", - saAmfSUHostNodeOrNodeGroup.value); + su_host_node_or_nodegroup.c_str()); return 0; } if (ccbutil_getCcbOpDataByDN(opdata->ccbId, &saAmfSUHostNodeOrNodeGroup) == nullptr) { report_ccb_validation_error(opdata, "'%s' does not exist in existing model or in CCB", - saAmfSUHostNodeOrNodeGroup.value); + su_host_node_or_nodegroup.c_str()); return 0; } } @@ -263,32 +266,36 @@ } /* Get value of saAmfSGSuHostNodeGroup */ - avsv_sanamet_init(dn, &sg_name, "safSg"); - sg = sg_db->find(Amf::to_string(&sg_name)); + avsv_sanamet_init(dn, sg_name, "safSg"); + sg = sg_db->find(sg_name); if (sg) { - saAmfSGSuHostNodeGroup = sg->saAmfSGSuHostNodeGroup; + sg_su_host_nodegroup = sg->saAmfSGSuHostNodeGroup; } else { if (opdata == nullptr) { - report_ccb_validation_error(opdata, "SG '%s' does not exist in model", sg_name.value); + report_ccb_validation_error(opdata, "SG '%s' does not exist in model", sg_name.c_str()); return 0; } - if ((tmp = ccbutil_getCcbOpDataByDN(opdata->ccbId, &sg_name)) == nullptr) { + const SaNameTWrapper sg_namet(sg_name); + if ((tmp = ccbutil_getCcbOpDataByDN(opdata->ccbId, sg_namet)) == nullptr) { report_ccb_validation_error(opdata, "SG '%s' does not exist in existing model or in CCB", - sg_name.value); + sg_name.c_str()); return 0; } + SaNameT saAmfSGSuHostNodeGroup = {0}; (void) immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfSGSuHostNodeGroup"), tmp->param.create.attrValues, 0, &saAmfSGSuHostNodeGroup); + sg_su_host_nodegroup = Amf::to_string(&saAmfSGSuHostNodeGroup); } /* If its a local SU, node or nodegroup must be configured */ - if (!saAmfSutIsExternal && - (strstr((char *)saAmfSUHostNodeOrNodeGroup.value, "safAmfNode=") == nullptr) && - (strstr((char *)saAmfSUHostNodeOrNodeGroup.value, "safAmfNodeGroup=") == nullptr) && - (strstr((char *)saAmfSGSuHostNodeGroup.value, "safAmfNodeGroup=") == nullptr)) { - report_ccb_validation_error(opdata, "node or node group configuration is missing for '%s'", dn->value); + if (!saAmfSutIsExternal && + su_host_node_or_nodegroup.find("safAmfNode=") == std::string::npos && + su_host_node_or_nodegroup.find("safAmfNodeGroup=") == std::string::npos && + sg_su_host_nodegroup.find("safAmfNodeGroup=") == std::string::npos ) { + + report_ccb_validation_error(opdata, "node or node group configuration is missing for '%s'", dn.c_str()); return 0; } @@ -297,10 +304,11 @@ * service unit". */ if (saAmfSutIsExternal && - ((strstr((char *)saAmfSUHostNodeOrNodeGroup.value, "safAmfNode=") != nullptr) || - (strstr((char *)saAmfSUHostNodeOrNodeGroup.value, "safAmfNodeGroup=") != nullptr) || - (strstr((char *)saAmfSGSuHostNodeGroup.value, "safAmfNodeGroup=") != nullptr))) { - report_ccb_validation_error(opdata, "node or node group configured for external SU '%s'", dn->value); + (su_host_node_or_nodegroup.find("safAmfNode=") != std::string::npos || + su_host_node_or_nodegroup.find("safAmfNodeGroup=") != std::string::npos || + sg_su_host_nodegroup.find("safAmfNodeGroup=") != std::string::npos)) { + + report_ccb_validation_error(opdata, "node or node group configured for external SU '%s'", dn.c_str()); return 0; } @@ -311,28 +319,28 @@ * configured for a service unit, it must be a member of the node group for the service * group, if configured." */ - if ((strstr((char *)saAmfSUHostNodeOrNodeGroup.value, "safAmfNodeGroup=") != nullptr) && - (strstr((char *)saAmfSGSuHostNodeGroup.value, "safAmfNodeGroup=") != nullptr)) { + if (su_host_node_or_nodegroup.find("safAmfNodeGroup=") != std::string::npos && + sg_su_host_nodegroup.find("safAmfNodeGroup=") != std::string::npos) { AVD_AMF_NG *ng_of_su, *ng_of_sg; - ng_of_su = avd_ng_get(&saAmfSUHostNodeOrNodeGroup); + ng_of_su = avd_ng_get(su_host_node_or_nodegroup); if (ng_of_su == nullptr) { report_ccb_validation_error(opdata, "Invalid saAmfSUHostNodeOrNodeGroup '%s' for '%s'", - saAmfSUHostNodeOrNodeGroup.value, dn->value); + su_host_node_or_nodegroup.c_str(), dn.c_str()); return 0; } - ng_of_sg = avd_ng_get(&saAmfSGSuHostNodeGroup); + ng_of_sg = avd_ng_get(sg_su_host_nodegroup); if (ng_of_su == nullptr) { report_ccb_validation_error(opdata, "Invalid saAmfSGSuHostNodeGroup '%s' for '%s'", - saAmfSGSuHostNodeGroup.value, dn->value); + sg_su_host_nodegroup.c_str(), dn.c_str()); return 0; } if (ng_of_su->number_nodes() > ng_of_sg->number_nodes()) { report_ccb_validation_error(opdata, "SU node group '%s' contains more nodes than the SG node group '%s'", - saAmfSUHostNodeOrNodeGroup.value, saAmfSGSuHostNodeGroup.value); + su_host_node_or_nodegroup.c_str(), sg_su_host_nodegroup.c_str()); return 0; } @@ -340,7 +348,7 @@ ng_of_su->saAmfNGNodeList.begin(), ng_of_su->saAmfNGNodeList.end()) == false) { report_ccb_validation_error(opdata, "SU node group '%s' is not a subset of the SG node group '%s'", - saAmfSUHostNodeOrNodeGroup.value, saAmfSGSuHostNodeGroup.value); + su_host_node_or_nodegroup.c_str(), sg_su_host_nodegroup.c_str()); return 0; } @@ -350,13 +358,13 @@ if ((immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfSUFailover"), attributes, 0, &abool) == SA_AIS_OK) && (abool > SA_TRUE)) { - report_ccb_validation_error(opdata, "Invalid saAmfSUFailover %u for '%s'", abool, dn->value); + report_ccb_validation_error(opdata, "Invalid saAmfSUFailover %u for '%s'", abool, dn.c_str()); return 0; } if ((immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfSUAdminState"), attributes, 0, &admstate) == SA_AIS_OK) && !avd_admin_state_is_valid(admstate, opdata)) { - report_ccb_validation_error(opdata, "Invalid saAmfSUAdminState %u for '%s'", admstate, dn->value); + report_ccb_validation_error(opdata, "Invalid saAmfSUAdminState %u for '%s'", admstate, dn.c_str()); return 0; } @@ -371,26 +379,28 @@ * * @return AVD_SU* */ -static AVD_SU *su_create(const SaNameT *dn, const SaImmAttrValuesT_2 **attributes) +static AVD_SU *su_create(const std::string& dn, const SaImmAttrValuesT_2 **attributes) { int rc = -1; AVD_SU *su; AVD_SUTYPE *sut; SaAisErrorT error; + SaNameT temp_name; - TRACE_ENTER2("'%s'", dn->value); + TRACE_ENTER2("'%s'", dn.c_str()); /* ** If called at new active at failover, the object is found in the DB ** but needs to get configuration attributes initialized. */ - if ((su = su_db->find(Amf::to_string(dn))) == nullptr) { + if ((su = su_db->find(dn)) == nullptr) { su = new AVD_SU(dn); } else TRACE("already created, refreshing config..."); - error = immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfSUType"), attributes, 0, &su->saAmfSUType); + error = immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfSUType"), attributes, 0, &temp_name); osafassert(error == SA_AIS_OK); + su->saAmfSUType = Amf::to_string(&temp_name); if (immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfSURank"), attributes, 0, &su->saAmfSURank) != SA_AIS_OK) { /* Empty, assign default value (highest number => lowest rank) */ @@ -400,15 +410,31 @@ /* If 0 (zero), treat as lowest possible rank. Should be a positive integer */ if (su->saAmfSURank == 0) { su->saAmfSURank = ~0U; - TRACE("'%s' saAmfSURank auto-changed to lowest", su->name.value); + TRACE("'%s' saAmfSURank auto-changed to lowest", su->name.c_str()); } - (void) immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfSUHostedByNode"), attributes, 0, &su->saAmfSUHostedByNode); + error = immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfSUHostedByNode"), attributes, 0, &temp_name); + if (error == SA_AIS_OK) { + su->saAmfSUHostedByNode = Amf::to_string(&temp_name); + TRACE("saAmfSUHostedByNode set to %s", su->saAmfSUHostedByNode.c_str()); + } else { + su->saAmfSUHostedByNode = ""; + TRACE("saAmfSUHostedByNode set to blank"); + } - (void) immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfSUHostNodeOrNodeGroup"), attributes, 0, &su->saAmfSUHostNodeOrNodeGroup); + + error = immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfSUHostNodeOrNodeGroup"), attributes, 0, &temp_name); + if (error == SA_AIS_OK) { + su->saAmfSUHostNodeOrNodeGroup = Amf::to_string(&temp_name); + TRACE("saAmfSUHostNodeOrNodeGroup set to %s", su->saAmfSUHostNodeOrNodeGroup.c_str()); + } else { + su->saAmfSUHostNodeOrNodeGroup = ""; + TRACE("saAmfSUHostNodeOrNodeGroup set to blank"); + } - if ((sut = sutype_db->find(Amf::to_string(&su->saAmfSUType))) == nullptr) { - LOG_ER("saAmfSUType '%s' does not exist", su->saAmfSUType.value); + + if ((sut = sutype_db->find(su->saAmfSUType)) == nullptr) { + LOG_ER("saAmfSUType '%s' does not exist", su->saAmfSUType.c_str()); goto done; } @@ -419,7 +445,8 @@ else su->saAmfSUFailover_configured = true; - (void)immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfSUMaintenanceCampaign"), attributes, 0, &su->saAmfSUMaintenanceCampaign); + (void)immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfSUMaintenanceCampaign"), attributes, 0, &temp_name); + su->saAmfSUMaintenanceCampaign = Amf::to_string(&temp_name); if (immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfSUAdminState"), attributes, 0, &su->saAmfSUAdminState) != SA_AIS_OK) su->saAmfSUAdminState = SA_AMF_ADMIN_UNLOCKED; @@ -452,20 +479,19 @@ std::vector<AVD_SU*>::const_iterator su_iter; std::vector<AVD_SU*> *su_list = nullptr; - TRACE_ENTER2("'%s'", su->name.value); + TRACE_ENTER2("'%s'", su->name.c_str()); /* If node is configured in SU we are done */ - if (strstr((char *)su->saAmfSUHostNodeOrNodeGroup.value, "safAmfNode=") != nullptr) { - node = avd_node_get(&su->saAmfSUHostNodeOrNodeGroup); + if (su->saAmfSUHostNodeOrNodeGroup.find("safAmfNode=") != std::string::npos) { + node = avd_node_get(su->saAmfSUHostNodeOrNodeGroup); goto done; } /* A node group configured in the SU is prioritized before the same in SG */ - if (strstr((char *)su->saAmfSUHostNodeOrNodeGroup.value, "safAmfNodeGroup=") != nullptr) - ng = avd_ng_get(&su->saAmfSUHostNodeOrNodeGroup); - else { - if (strstr((char *)su->sg_of_su->saAmfSGSuHostNodeGroup.value, "safAmfNodeGroup=") != nullptr) - ng = avd_ng_get(&su->sg_of_su->saAmfSGSuHostNodeGroup); + if (su->saAmfSUHostNodeOrNodeGroup.find("safAmfNodeGroup=") != std::string::npos) { + ng = avd_ng_get(su->saAmfSUHostNodeOrNodeGroup); + } else if (su->sg_of_su->saAmfSGSuHostNodeGroup.find("safAmfNodeGroup=") != std::string::npos) { + ng = avd_ng_get(su->sg_of_su->saAmfSGSuHostNodeGroup); } osafassert(ng); @@ -497,8 +523,8 @@ /* All nodes already have an SU mapped for the SG. Return a node in the node group. */ node = avd_node_get(*ng->saAmfNGNodeList.begin()); done: - memcpy(&su->saAmfSUHostedByNode, &node->name, sizeof(SaNameT)); - TRACE_LEAVE2("hosted by %s", node->name.value); + su->saAmfSUHostedByNode = node->name; + TRACE_LEAVE2("hosted by %s", node->name.c_str()); return node; } @@ -508,12 +534,12 @@ */ static void su_add_to_model(AVD_SU *su) { - SaNameT dn; + std::string dn; AVD_AVND *node; bool new_su = false; unsigned int rc; - TRACE_ENTER2("%s", su->name.value); + TRACE_ENTER2("%s", su->name.c_str()); /* Check parent link to see if it has been added already */ if (su->sg_of_su != nullptr) { @@ -522,37 +548,39 @@ } /* Determine of the SU is added now, if so msg to amfnd needs to be sent */ - if (su_db->find(Amf::to_string(&su->name)) == nullptr) + if (su_db->find(su->name) == nullptr) new_su = true; - avsv_sanamet_init(&su->name, &dn, "safSg"); + avsv_sanamet_init(su->name, dn, "safSg"); /* ** Refresh the SG reference, by now it must exist. ** An SU can be created (on the standby) from the checkpointing logic. ** In that case the SG reference could now be nullptr. */ - su->sg_of_su = sg_db->find(Amf::to_string(&dn)); + su->sg_of_su = sg_db->find(dn); osafassert(su->sg_of_su); - if (su_db->find(Amf::to_string(&su->name)) == nullptr) { - rc = su_db->insert(Amf::to_string(&su->name), su); + if (su_db->find(su->name) == nullptr) { + TRACE("su_db inserted %s", su->name.c_str()); + rc = su_db->insert(su->name, su); osafassert(rc == NCSCC_RC_SUCCESS); } - su->su_type = sutype_db->find(Amf::to_string(&su->saAmfSUType)); + su->su_type = sutype_db->find(su->saAmfSUType); osafassert(su->su_type); avd_sutype_add_su(su); avd_sg_add_su(su); if (!su->su_is_external) { - if (su->saAmfSUHostedByNode.length == 0) { + if (su->saAmfSUHostedByNode.empty() == true) { /* This node has not been mapped yet, do it */ su->su_on_node = map_su_to_node(su); } else { /* Already mapped, setup the node link */ - su->su_on_node = avd_node_get(&su->saAmfSUHostedByNode); + su->su_on_node = avd_node_get(su->saAmfSUHostedByNode); } + osafassert(su->su_on_node != nullptr); avd_node_add_su(su); node = su->su_on_node; } else { @@ -587,7 +615,7 @@ avd_node_remove_su(su); avd_sg_remove_su(su); - LOG_ER("%s: avd_snd_su_msg failed %s", __FUNCTION__, su->name.value); + LOG_ER("%s: avd_snd_su_msg failed %s", __FUNCTION__, su->name.c_str()); goto done; } @@ -597,30 +625,32 @@ } done: - avd_saImmOiRtObjectUpdate(&su->name, "saAmfSUOperState", + avd_saImmOiRtObjectUpdate(su->name, "saAmfSUOperState", SA_IMM_ATTR_SAUINT32T, &su->saAmfSUOperState); - avd_saImmOiRtObjectUpdate(&su->name, "saAmfSUPreInstantiable", + avd_saImmOiRtObjectUpdate(su->name, "saAmfSUPreInstantiable", SA_IMM_ATTR_SAUINT32T, &su->saAmfSUPreInstantiable); - avd_saImmOiRtObjectUpdate(&su->name, "saAmfSUHostedByNode", - SA_IMM_ATTR_SANAMET, &su->saAmfSUHostedByNode); + const SaNameTWrapper hosted_by_node(su->saAmfSUHostedByNode); + avd_saImmOiRtObjectUpdate(su->name, "saAmfSUHostedByNode", + SA_IMM_ATTR_SANAMET, (void*)static_cast<const SaNameT*>(hosted_by_node)); - avd_saImmOiRtObjectUpdate(&su->name, "saAmfSUPresenceState", + avd_saImmOiRtObjectUpdate(su->name, "saAmfSUPresenceState", SA_IMM_ATTR_SAUINT32T, &su->saAmfSUPresenceState); - avd_saImmOiRtObjectUpdate(&su->name, "saAmfSUReadinessState", + avd_saImmOiRtObjectUpdate(su->name, "saAmfSUReadinessState", SA_IMM_ATTR_SAUINT32T, &su->saAmfSuReadinessState); TRACE_LEAVE(); } -SaAisErrorT avd_su_config_get(const SaNameT *sg_name, AVD_SG *sg) +SaAisErrorT avd_su_config_get(const std::string& sg_name, AVD_SG *sg) { SaAisErrorT error, rc; SaImmSearchHandleT searchHandle; SaImmSearchParametersT_2 searchParam; - SaNameT su_name; + char* tmp_su_name; + std::string su_name; const SaImmAttrValuesT_2 **attributes; const char *className = "SaAmfSU"; AVD_SU *su; @@ -641,7 +671,7 @@ searchParam.searchOneAttr.attrValueType = SA_IMM_ATTR_SASTRINGT; searchParam.searchOneAttr.attrValue = &className; - error = immutil_saImmOmSearchInitialize_2(avd_cb->immOmHandle, sg_name, SA_IMM_SUBTREE, + error = immutil_saImmOmSearchInitialize_o2(avd_cb->immOmHandle, sg_name.c_str(), SA_IMM_SUBTREE, SA_IMM_SEARCH_ONE_ATTR | SA_IMM_SEARCH_GET_SOME_ATTR, &searchParam, configAttributes, &searchHandle); @@ -650,21 +680,22 @@ goto done1; } - while ((rc = immutil_saImmOmSearchNext_2(searchHandle, &su_name, + while ((rc = immutil_saImmOmSearchNext_o2(searchHandle, &tmp_su_name, (SaImmAttrValuesT_2 ***)&attributes)) == SA_AIS_OK) { - if (!is_config_valid(&su_name, attributes, nullptr)) { + su_name = tmp_su_name; + if (!is_config_valid(su_name, attributes, nullptr)) { error = SA_AIS_ERR_FAILED_OPERATION; goto done2; } - if ((su = su_create(&su_name, attributes)) == nullptr) { + if ((su = su_create(su_name, attributes)) == nullptr) { error = SA_AIS_ERR_FAILED_OPERATION; goto done2; } su_add_to_model(su); - if (avd_comp_config_get(&su_name, su) != SA_AIS_OK) { + if (avd_comp_config_get(su_name, su) != SA_AIS_OK) { error = SA_AIS_ERR_FAILED_OPERATION; goto done2; } @@ -705,7 +736,7 @@ return; osafassert(pres_state <= SA_AMF_PRESENCE_TERMINATION_FAILED); - TRACE_ENTER2("'%s' %s => %s", name.value, + TRACE_ENTER2("'%s' %s => %s", name.c_str(), avd_pres_state_name[saAmfSUPresenceState], avd_pres_state_name[pres_state]); @@ -717,13 +748,13 @@ pres_state == SA_AMF_PRESENCE_RESTARTING) { saflog(LOG_NOTICE, amfSvcUsrName, "%s PresenceState %s => %s", - name.value, avd_pres_state_name[old_state], + name.c_str(), avd_pres_state_name[old_state], avd_pres_state_name[saAmfSUPresenceState]); - avd_send_su_pres_state_chg_ntf(&name, old_state, + avd_send_su_pres_state_chg_ntf(name, old_state, saAmfSUPresenceState); } - avd_saImmOiRtObjectUpdate(&name, "saAmfSUPresenceState", + avd_saImmOiRtObjectUpdate(name, "saAmfSUPresenceState", SA_IMM_ATTR_SAUINT32T, &saAmfSUPresenceState); m_AVSV_SEND_CKPT_UPDT_ASYNC_UPDT(avd_cb, this, AVSV_CKPT_SU_PRES_STATE); if ((saAmfSUPresenceState == SA_AMF_PRESENCE_INSTANTIATED) && @@ -749,20 +780,20 @@ return; osafassert(oper_state <= SA_AMF_OPERATIONAL_DISABLED); - TRACE_ENTER2("'%s' %s => %s", name.value, + TRACE_ENTER2("'%s' %s => %s", name.c_str(), avd_oper_state_name[saAmfSUOperState], avd_oper_state_name[oper_state]); - saflog(LOG_NOTICE, amfSvcUsrName, "%s OperState %s => %s", name.value, + saflog(LOG_NOTICE, amfSvcUsrName, "%s OperState %s => %s", name.c_str(), avd_oper_state_name[saAmfSUOperState], avd_oper_state_name[oper_state]); saAmfSUOperState = oper_state; - avd_send_oper_chg_ntf(&name, SA_AMF_NTFID_SU_OP_STATE, old_state, + avd_send_oper_chg_ntf(name, SA_AMF_NTFID_SU_OP_STATE, old_state, saAmfSUOperState); - avd_saImmOiRtObjectUpdate(&name, "saAmfSUOperState", + avd_saImmOiRtObjectUpdate(name, "saAmfSUOperState", SA_IMM_ATTR_SAUINT32T, &saAmfSUOperState); m_AVSV_SEND_CKPT_UPDT_ASYNC_UPDT(avd_cb, this, AVSV_CKPT_SU_OPER_STATE); @@ -779,15 +810,15 @@ return; osafassert(readiness_state <= SA_AMF_READINESS_STOPPING); - TRACE_ENTER2("'%s' %s", name.value, + TRACE_ENTER2("'%s' %s", name.c_str(), avd_readiness_state_name[readiness_state]); saflog(LOG_NOTICE, amfSvcUsrName, "%s ReadinessState %s => %s", - name.value, + name.c_str(), avd_readiness_state_name[saAmfSuReadinessState], avd_readiness_state_name[readiness_state]); saAmfSuReadinessState = readiness_state; if (get_surestart() == false) - avd_saImmOiRtObjectUpdate(&name, "saAmfSUReadinessState", + avd_saImmOiRtObjectUpdate(name, "saAmfSUReadinessState", SA_IMM_ATTR_SAUINT32T, &saAmfSuReadinessState); m_AVSV_SEND_CKPT_UPDT_ASYNC_UPDT(avd_cb, this, AVSV_CKPT_SU_READINESS_STATE); @@ -815,16 +846,16 @@ SaAmfAdminStateT old_state = saAmfSUAdminState; osafassert(admin_state <= SA_AMF_ADMIN_SHUTTING_DOWN); - TRACE_ENTER2("'%s' %s => %s", name.value, + TRACE_ENTER2("'%s' %s => %s", name.c_str(), avd_adm_state_name[old_state], avd_adm_state_name[admin_state]); - saflog(LOG_NOTICE, amfSvcUsrName, "%s AdmState %s => %s", name.value, + saflog(LOG_NOTICE, amfSvcUsrName, "%s AdmState %s => %s", name.c_str(), avd_adm_state_name[saAmfSUAdminState], avd_adm_state_name[admin_state]); saAmfSUAdminState = admin_state; - avd_saImmOiRtObjectUpdate(&name, "saAmfSUAdminState", + avd_saImmOiRtObjectUpdate(name, "saAmfSUAdminState", SA_IMM_ATTR_SAUINT32T, &saAmfSUAdminState); m_AVSV_SEND_CKPT_UPDT_ASYNC_UPDT(avd_cb, this, AVSV_CKPT_SU_ADMIN_STATE); - avd_send_admin_state_chg_ntf(&name, SA_AMF_NTFID_SU_ADMIN_STATE, + avd_send_admin_state_chg_ntf(name, SA_AMF_NTFID_SU_ADMIN_STATE, old_state, saAmfSUAdminState); TRACE_LEAVE(); } @@ -832,7 +863,7 @@ void AVD_SU::unlock(SaImmOiHandleT immoi_handle, SaInvocationT invocation) { bool is_oper_successful = true; - TRACE_ENTER2("'%s'", name.value); + TRACE_ENTER2("'%s'", name.c_str()); set_admin_state(SA_AMF_ADMIN_UNLOCKED); /* Return as cluster timer haven't expired.*/ @@ -854,7 +885,7 @@ avd_sg_app_su_inst_func(avd_cb, sg_of_su); } else - LOG_IN("SU '%s' is not in service", name.value); + LOG_IN("SU '%s' is not in service", name.c_str()); avd_sg_app_su_inst_func(avd_cb, sg_of_su); if (is_oper_successful == true) { @@ -881,7 +912,7 @@ SaAmfAdminStateT back_admin_state; bool is_oper_successful = true; - TRACE_ENTER2("'%s'", name.value); + TRACE_ENTER2("'%s'", name.c_str()); /* Change the admin state to lock and return as cluster timer haven't expired.*/ if (avd_cb->init_state == AVD_INIT_DONE) { set_readiness_state(SA_AMF_READINESS_OUT_OF_SERVICE); @@ -929,7 +960,7 @@ } void AVD_SU::shutdown(SaImmOiHandleT immoi_handle, SaInvocationT invocation) { - TRACE_ENTER2("'%s'", name.value); + TRACE_ENTER2("'%s'", name.c_str()); lock(immoi_handle, invocation, SA_AMF_ADMIN_SHUTTING_DOWN); TRACE_LEAVE(); } @@ -938,7 +969,7 @@ SaInvocationT invocation) { AVD_AVND *node = get_node_ptr(); - TRACE_ENTER2("'%s'", name.value); + TRACE_ENTER2("'%s'", name.c_str()); /* For non-preinstantiable SU lock-inst is same as lock */ if (saAmfSUPreInstantiable == false) { @@ -949,7 +980,7 @@ if (list_of_susi != nullptr) { report_admin_op_error(immoi_handle, invocation, SA_AIS_ERR_TRY_AGAIN, nullptr, - "SIs still assigned to this SU '%s'", name.value); + "SIs still assigned to this SU '%s'", name.c_str()); goto done; } @@ -957,7 +988,7 @@ (saAmfSUPresenceState == SA_AMF_PRESENCE_TERMINATING) || (saAmfSUPresenceState == SA_AMF_PRESENCE_RESTARTING)) { report_admin_op_error(immoi_handle, invocation, SA_AIS_ERR_TRY_AGAIN, nullptr, - "'%s' presence state is '%u'", name.value, saAmfSUPresenceState); + "'%s' presence state is '%u'", name.c_str(), saAmfSUPresenceState); goto done; } @@ -999,11 +1030,11 @@ SaInvocationT invocation) { AVD_AVND *node = get_node_ptr(); - TRACE_ENTER2("'%s'", name.value); + TRACE_ENTER2("'%s'", name.c_str()); if (list_of_comp.empty() == true) { report_admin_op_error(immoi_handle, invocation, SA_AIS_ERR_BAD_OPERATION, nullptr, - "There is no component configured for SU '%s'.", name.value); + "There is no component configured for SU '%s'.", name.c_str()); goto done; } @@ -1019,7 +1050,7 @@ if (saAmfSUPresenceState != SA_AMF_PRESENCE_UNINSTANTIATED) { report_admin_op_error(immoi_handle, invocation, SA_AIS_ERR_BAD_OPERATION, nullptr, - "Can't instantiate '%s', whose presence state is '%u'", name.value, + "Can't instantiate '%s', whose presence state is '%u'", name.c_str(), saAmfSUPresenceState); goto done; } @@ -1058,11 +1089,11 @@ void AVD_SU::repaired(SaImmOiHandleT immoi_handle, SaInvocationT invocation) { - TRACE_ENTER2("'%s'", name.value); + TRACE_ENTER2("'%s'", name.c_str()); if (saAmfSUOperState == SA_AMF_OPERATIONAL_ENABLED) { report_admin_op_error(immoi_handle, invocation, SA_AIS_ERR_NO_OP, nullptr, - "Admin repair request for '%s', op state already enabled", name.value); + "Admin repair request for '%s', op state already enabled", name.c_str()); goto done; } @@ -1071,19 +1102,19 @@ /* This means that node on which this su is hosted, is absent. */ report_admin_op_error(immoi_handle, invocation, SA_AIS_ERR_BAD_OPERATION, nullptr, "Admin repair request for '%s', hosting node'%s' is absent", - name.value, su_on_node->name.value); + name.c_str(), su_on_node->name.c_str()); goto done; } /* forward the admin op req to the node director */ - if (avd_admin_op_msg_snd(&name, AVSV_SA_AMF_SU, SA_AMF_ADMIN_REPAIRED, + if (avd_admin_op_msg_snd(name, AVSV_SA_AMF_SU, SA_AMF_ADMIN_REPAIRED, su_on_node) == NCSCC_RC_SUCCESS) { pend_cbk.admin_oper = SA_AMF_ADMIN_REPAIRED; pend_cbk.invocation = invocation; } else { report_admin_op_error(immoi_handle, invocation, SA_AIS_ERR_TIMEOUT, nullptr, - "Admin op request send failed '%s'", name.value); + "Admin op request send failed '%s'", name.c_str()); } done: @@ -1099,16 +1130,16 @@ */ void AVD_SU::restart(SaImmOiHandleT immoi_handle, SaInvocationT invocation) { - TRACE_ENTER2("'%s'", name.value); + TRACE_ENTER2("'%s'", name.c_str()); pend_cbk.admin_oper = SA_AMF_ADMIN_RESTART; pend_cbk.invocation = invocation; if ((su_all_comps_restartable() == true) || (is_any_non_restartable_comp_assigned() == false)) { - if (avd_admin_op_msg_snd(&name, AVSV_SA_AMF_SU, SA_AMF_ADMIN_RESTART, + if (avd_admin_op_msg_snd(name, AVSV_SA_AMF_SU, SA_AMF_ADMIN_RESTART, su_on_node) != NCSCC_RC_SUCCESS) { report_admin_op_error(immoi_handle, invocation, SA_AIS_ERR_TIMEOUT, nullptr, - "Admin op request send failed '%s'", name.value); + "Admin op request send failed '%s'", name.c_str()); pend_cbk.invocation = 0; pend_cbk.admin_oper = static_cast<SaAmfAdminOperationIdT>(0); } @@ -1169,7 +1200,7 @@ /* su's sg_fsm_state is checked below, just check other su. */ if ((su != su_ptr) && (su_ptr->pend_cbk.invocation != 0)) { report_admin_op_error(immoi_handle, invocation, SA_AIS_ERR_TRY_AGAIN, nullptr, - "Admin operation is already going on (su'%s')", su_ptr->name.value); + "Admin operation is already going on (su'%s')", su_ptr->name.c_str()); goto done; } } @@ -1177,7 +1208,7 @@ /* Avoid if any single Csi assignment is undergoing on SG. */ if (csi_assignment_validate(su->sg_of_su) == true) { report_admin_op_error(immoi_handle, invocation, SA_AIS_ERR_TRY_AGAIN, nullptr, - "Single Csi assignment undergoing on (sg'%s')", su->sg_of_su->name.value); + "Single Csi assignment undergoing on (sg'%s')", su->sg_of_su->name.c_str()); goto done; } @@ -1194,14 +1225,14 @@ and then allow lock operation to proceed. */ report_admin_op_error(immoi_handle, su->pend_cbk.invocation, SA_AIS_ERR_INTERRUPT, &su->pend_cbk, - "SU lock has been issued '%s'", su->name.value); + "SU lock has been issued '%s'", su->name.c_str()); } } /* if Tolerance timer is running for any SI's withing this SG, then return SA_AIS_ERR_TRY_AGAIN */ if (sg_is_tolerance_timer_running_for_any_si(su->sg_of_su)) { report_admin_op_error(immoi_handle, invocation, SA_AIS_ERR_TRY_AGAIN, nullptr, "Tolerance timer is running for some of the SI's in the SG '%s', " - "so differing admin opr",su->sg_of_su->name.value); + "so differing admin opr",su->sg_of_su->name.c_str()); goto done; } @@ -1241,7 +1272,7 @@ if (su->sg_of_su->sg_ncs_spec == true) { report_admin_op_error(immoi_handle, invocation, SA_AIS_ERR_BAD_OPERATION, nullptr, "Not allowed on middleware SU: %s, op_id: %llu", - su->name.value, op_id); + su->name.c_str(), op_id); goto done; } if (su->saAmfSUPresenceState == SA_AMF_PRESENCE_UNINSTANTIATED) { @@ -1263,15 +1294,15 @@ SA_AIS_ERR_TRY_AGAIN, nullptr, "Some entity is unstable, Operation cannot " "be performed on '%s'" - "Check syslog for entity details", su->name.value); + "Check syslog for entity details", su->name.c_str()); goto done; } } node = su->get_node_ptr(); if (node->admin_node_pend_cbk.admin_oper != 0) { report_admin_op_error(immoi_handle, invocation, SA_AIS_ERR_TRY_AGAIN, nullptr, - "Node'%s' hosting SU'%s', undergoing admin operation'%u'", node->name.value, - su->name.value, node->admin_node_pend_cbk.admin_oper); + "Node'%s' hosting SU'%s', undergoing admin operation'%u'", node->name.c_str(), + su->name.c_str(), node->admin_node_pend_cbk.admin_oper); goto done; } @@ -1312,7 +1343,8 @@ static SaAisErrorT su_rt_attr_cb(SaImmOiHandleT immOiHandle, const SaNameT *objectName, const SaImmAttrNameT *attributeNames) { - AVD_SU *su = su_db->find(Amf::to_string(objectName)); + const std::string obj_name(Amf::to_string(objectName)); + AVD_SU *su = su_db->find(obj_name); SaImmAttrNameT attributeName; int i = 0; SaAisErrorT rc = SA_AIS_OK; @@ -1328,13 +1360,13 @@ attributeName, SA_IMM_ATTR_SAUINT32T, &saAmfSUAssignedSIs); #endif } else if (!strcmp("saAmfSUNumCurrActiveSIs", attributeName)) { - rc = avd_saImmOiRtObjectUpdate_sync(objectName, attributeName, + rc = avd_saImmOiRtObjectUpdate_sync(obj_name, attributeName, SA_IMM_ATTR_SAUINT32T, &su->saAmfSUNumCurrActiveSIs); } else if (!strcmp("saAmfSUNumCurrStandbySIs", attributeName)) { - rc = avd_saImmOiRtObjectUpdate_sync(objectName, attributeName, + rc = avd_saImmOiRtObjectUpdate_sync(obj_name, attributeName, SA_IMM_ATTR_SAUINT32T, &su->saAmfSUNumCurrStandbySIs); } else if (!strcmp("saAmfSURestartCount", attributeName)) { - rc = avd_saImmOiRtObjectUpdate_sync(objectName, attributeName, + rc = avd_saImmOiRtObjectUpdate_sync(obj_name, attributeName, SA_IMM_ATTR_SAUINT32T, &su->saAmfSURestartCount); } else { LOG_ER("Ignoring unknown attribute '%s'", attributeName); @@ -1393,12 +1425,12 @@ */ if (su->sg_of_su->sg_fsm_state != AVD_SG_FSM_STABLE) { rc = SA_AIS_ERR_TRY_AGAIN; - report_ccb_validation_error(opdata, "'%s' is not stable",su->sg_of_su->name.value); + report_ccb_validation_error(opdata, "'%s' is not stable",su->sg_of_su->name.c_str()); goto done; } if (su_failover > SA_TRUE) { - report_ccb_validation_error(opdata, "Invalid saAmfSUFailover SU:'%s'", su->name.value); + report_ccb_validation_error(opdata, "Invalid saAmfSUFailover SU:'%s'", su->name.c_str()); rc = SA_AIS_ERR_BAD_OPERATION; goto done; } @@ -1407,9 +1439,9 @@ continue; AVD_SU *su = su_db->find(Amf::to_string(&opdata->objectName)); - if (su->saAmfSUMaintenanceCampaign.length > 0) { + if (su->saAmfSUMaintenanceCampaign.length() > 0) { report_ccb_validation_error(opdata, "saAmfSUMaintenanceCampaign already set for %s", - su->name.value); + su->name.c_str()); rc = SA_AIS_ERR_BAD_OPERATION; goto done; } @@ -1511,48 +1543,50 @@ * @param opdata * @return true if so */ -static bool node_admin_state_is_valid_for_su_create(const SaNameT *su_dn, +static bool node_admin_state_is_valid_for_su_create(const std::string& su_dn, const SaImmAttrValuesT_2 **attributes, const CcbUtilOperationData_t *opdata) { - TRACE_ENTER2("%s", su_dn->value); - SaNameT node_name = {0}; - (void) immutil_getAttr("saAmfSUHostNodeOrNodeGroup", attributes, 0, &node_name); - if (node_name.length == 0) { + TRACE_ENTER2("%s", su_dn.c_str()); + SaNameT tmp_node_name = {0}; + (void) immutil_getAttr("saAmfSUHostNodeOrNodeGroup", attributes, 0, &tmp_node_name); + const std::string node_name(Amf::to_string(&tmp_node_name)); + + if (node_name.empty() == true) { // attribute empty but this is probably not an error, just trace TRACE("Create '%s', saAmfSUHostNodeOrNodeGroup not configured", - su_dn->value); + su_dn.c_str()); TRACE_LEAVE(); return false; } - if (strncmp((char*)node_name.value, "safAmfNode=", 11) != 0) { + if (node_name.compare(0, 11, "safAmfNode=") != 0) { // attribute non empty but does not contain a node DN, not OK amflog(SA_LOG_SEV_NOTICE, "Create '%s', saAmfSUHostNodeOrNodeGroup not configured with a node (%s)", - su_dn->value, node_name.value); + su_dn.c_str(), node_name.c_str()); TRACE_LEAVE(); return false; } - const AVD_AVND *node = avd_node_get(&node_name); + const AVD_AVND *node = avd_node_get(node_name); if (node == nullptr) { - if (opdata == nullptr || ccbutil_getCcbOpDataByDN(opdata->ccbId, &node_name) == nullptr) { + if (opdata == nullptr || ccbutil_getCcbOpDataByDN(opdata->ccbId, &tmp_node_name) == nullptr) { // node must exist in the current model, or created in the same CCB amflog(SA_LOG_SEV_WARNING, "Create '%s', configured with a non existing node (%s)", - su_dn->value, node_name.value); + su_dn.c_str(), node_name.c_str()); TRACE_LEAVE(); return false; } else { // check admin state of the new node SaAmfAdminStateT admin_state; - const CcbUtilOperationData_t *t_opdata = ccbutil_getCcbOpDataByDN(opdata->ccbId, &node_name); + const CcbUtilOperationData_t *t_opdata = ccbutil_getCcbOpDataByDN(opdata->ccbId, &tmp_node_name); immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfNodeAdminState"), t_opdata->param.create.attrValues, 0, &admin_state); if (admin_state != SA_AMF_ADMIN_LOCKED_INSTANTIATION) { TRACE("Create '%s', configured node '%s' is not locked instantiation", - su_dn->value, node_name.value); + su_dn.c_str(), node_name.c_str()); TRACE_LEAVE(); return false; } @@ -1562,7 +1596,7 @@ // configured with a node DN, accept only locked-in state if (node->saAmfNodeAdminState != SA_AMF_ADMIN_LOCKED_INSTANTIATION) { TRACE("Create '%s', configured node '%s' is not locked instantiation", - su_dn->value, node_name.value); + su_dn.c_str(), node_name.c_str()); TRACE_LEAVE(); return false; } @@ -1581,21 +1615,22 @@ * @param opdata * @return true if so */ -static bool sg_admin_state_is_valid_for_su_create(const SaNameT *su_dn, +static bool sg_admin_state_is_valid_for_su_create(const std::string& su_dn, const SaImmAttrValuesT_2 **attributes, const CcbUtilOperationData_t *opdata) { - SaNameT sg_name = {0}; + std::string sg_name; SaAmfAdminStateT admin_state; - avsv_sanamet_init(su_dn, &sg_name, "safSg"); - const AVD_SG *sg = sg_db->find(Amf::to_string(&sg_name)); + avsv_sanamet_init(su_dn, sg_name, "safSg"); + const AVD_SG *sg = sg_db->find(sg_name); if (sg != nullptr) { admin_state = sg->saAmfSGAdminState; } else { + const SaNameTWrapper tmp_sg_name(sg_name); // SG does not exist in current model, check CCB const CcbUtilOperationData_t *tmp = - ccbutil_getCcbOpDataByDN(opdata->ccbId, &sg_name); + ccbutil_getCcbOpDataByDN(opdata->ccbId, tmp_sg_name); osafassert(tmp != nullptr); // already validated (void) immutil_getAttr("saAmfSGAdminState", @@ -1604,7 +1639,7 @@ if (admin_state != SA_AMF_ADMIN_LOCKED_INSTANTIATION) { TRACE("'%s' created UNLOCKED but '%s' is not locked instantiation", - su_dn->value, sg_name.value); + su_dn.c_str(), sg_name.c_str()); return false; } @@ -1619,7 +1654,7 @@ * * @return bool */ -static bool is_ccb_create_config_valid(const SaNameT *dn, +static bool is_ccb_create_config_valid(const std::string& dn, const SaImmAttrValuesT_2 **attributes, const CcbUtilOperationData_t *opdata) { @@ -1629,7 +1664,7 @@ assert(opdata != nullptr); // must be called in CCB context bool is_mw_su = false; - if (strstr((char *)dn->value, "safApp=OpenSAF") != nullptr) + if (strstr((char *)dn.c_str(), "safApp=OpenSAF") != nullptr) is_mw_su = true; rc = immutil_getAttr("saAmfSUAdminState", attributes, 0, &admstate); @@ -1661,7 +1696,7 @@ if (admstate != SA_AMF_ADMIN_UNLOCKED) { report_ccb_validation_error(opdata, "'%s' created with invalid saAmfSUAdminState (%u)", - dn->value, admstate); + dn.c_str(), admstate); return false; } @@ -1672,7 +1707,7 @@ return true; amflog(SA_LOG_SEV_NOTICE, "CCB %d creation of '%s' failed", - opdata->ccbId, dn->value); + opdata->ccbId, dn.c_str()); report_ccb_validation_error(opdata, "SG or node not configured properly to allow creation of UNLOCKED SU"); @@ -1682,13 +1717,13 @@ static SaAisErrorT su_ccb_completed_cb(CcbUtilOperationData_t *opdata) { SaAisErrorT rc = SA_AIS_ERR_BAD_OPERATION; - - TRACE_ENTER2("CCB ID %llu, '%s'", opdata->ccbId, opdata->objectName.value); + const std::string obj_name(Amf::to_string(&opdata->objectName)); + TRACE_ENTER2("CCB ID %llu, '%s'", opdata->ccbId, obj_name.c_str()); switch (opdata->operationType) { case CCBUTIL_CREATE: - if (is_config_valid(&opdata->objectName, opdata->param.create.attrValues, opdata) && - is_ccb_create_config_valid(&opdata->objectName, opdata->param.create.attrValues, opdata)) + if (is_config_valid(obj_name, opdata->param.create.attrValues, opdata) && + is_ccb_create_config_valid(obj_name, opdata->param.create.attrValues, opdata)) rc = SA_AIS_OK; break; case CCBUTIL_MODIFY: @@ -1755,21 +1790,22 @@ } } else if (!strcmp(attr_mod->modAttr.attrName, "saAmfSUMaintenanceCampaign")) { if (value_is_deleted) { - su->saAmfSUMaintenanceCampaign.length = 0; - TRACE("saAmfSUMaintenanceCampaign cleared for '%s'", su->name.value); + su->saAmfSUMaintenanceCampaign = ""; + TRACE("saAmfSUMaintenanceCampaign cleared for '%s'", su->name.c_str()); } else { - osafassert(su->saAmfSUMaintenanceCampaign.length == 0); - su->saAmfSUMaintenanceCampaign = *((SaNameT *)attr_mod->modAttr.attrValues[0]); + osafassert(su->saAmfSUMaintenanceCampaign.empty() == true); + su->saAmfSUMaintenanceCampaign = Amf::to_string( + reinterpret_cast<SaNameT*>(attr_mod->modAttr.attrValues[0])); TRACE("saAmfSUMaintenanceCampaign set to '%s' for '%s'", - su->saAmfSUMaintenanceCampaign.value, su->name.value); + su->saAmfSUMaintenanceCampaign.c_str(), su->name.c_str()); } } else if (!strcmp(attr_mod->modAttr.attrName, "saAmfSUType")) { AVD_SUTYPE *sut; SaNameT sutype_name = *(SaNameT*) attr_mod->modAttr.attrValues[0]; - TRACE("Modified saAmfSUType from '%s' to '%s'", su->saAmfSUType.value, sutype_name.value); + TRACE("Modified saAmfSUType from '%s' to '%s'", su->saAmfSUType.c_str(), sutype_name.value); sut = sutype_db->find(Amf::to_string(&sutype_name)); avd_sutype_remove_su(su); - su->saAmfSUType = sutype_name; + su->saAmfSUType = Amf::to_string(&sutype_name); su->su_type = sut; avd_sutype_add_su(su); if (su->saAmfSUPreInstantiable) { @@ -1800,7 +1836,7 @@ AVSV_PARAM_INFO param; AVD_SG *sg = su->sg_of_su; - TRACE_ENTER2("'%s'", su->name.value); + TRACE_ENTER2("'%s'", su->name.c_str()); if (avd_cb->avail_state_avd != SA_AMF_HA_ACTIVE) { su->remove_from_model(); @@ -1816,7 +1852,8 @@ memset(((uint8_t *)¶m), '\0', sizeof(AVSV_PARAM_INFO)); param.class_id = AVSV_SA_AMF_SU; param.act = AVSV_OBJ_OPR_DEL; - param.name = su->name; + const SaNameTWrapper tmp_su_name(su->name); + param.name = tmp_su_name; avd_snd_op_req_msg(avd_cb, su_node_ptr, ¶m); } @@ -1857,7 +1894,7 @@ switch (opdata->operationType) { case CCBUTIL_CREATE: - su = su_create(&opdata->objectName, opdata->param.create.attrValues); + su = su_create(Amf::to_string(&opdata->objectName), opdata->param.create.attrValues); osafassert(su); su_add_to_model(su); break; @@ -1878,7 +1915,7 @@ void AVD_SU::inc_curr_act_si() { saAmfSUNumCurrActiveSIs++; osafassert(saAmfSUNumCurrActiveSIs <= sg_of_su->saAmfSGMaxActiveSIsperSU); - TRACE("%s saAmfSUNumCurrActiveSIs=%u", name.value, + TRACE("%s saAmfSUNumCurrActiveSIs=%u", name.c_str(), saAmfSUNumCurrActiveSIs); m_AVSV_SEND_CKPT_UPDT_ASYNC_UPDT(avd_cb, this, AVSV_CKPT_SU_SI_CURR_ACTIVE); } @@ -1886,7 +1923,7 @@ void AVD_SU::dec_curr_act_si() { osafassert(saAmfSUNumCurrActiveSIs > 0); saAmfSUNumCurrActiveSIs--; - TRACE("%s saAmfSUNumCurrActiveSIs=%u", name.value, + TRACE("%s saAmfSUNumCurrActiveSIs=%u", name.c_str(), saAmfSUNumCurrActiveSIs); m_AVSV_SEND_CKPT_UPDT_ASYNC_UPDT(avd_cb, this, AVSV_CKPT_SU_SI_CURR_ACTIVE); } @@ -1894,7 +1931,7 @@ void AVD_SU::inc_curr_stdby_si() { saAmfSUNumCurrStandbySIs++; osafassert(saAmfSUNumCurrStandbySIs <= sg_of_su->saAmfSGMaxStandbySIsperSU); - TRACE("%s saAmfSUNumCurrStandbySIs=%u", name.value, + TRACE("%s saAmfSUNumCurrStandbySIs=%u", name.c_str(), saAmfSUNumCurrStandbySIs); m_AVSV_SEND_CKPT_UPDT_ASYNC_UPDT(avd_cb, this, AVSV_CKPT_SU_SI_CURR_STBY); } @@ -1902,7 +1939,7 @@ void AVD_SU::dec_curr_stdby_si() { osafassert(saAmfSUNumCurrStandbySIs > 0); saAmfSUNumCurrStandbySIs--; - TRACE("%s saAmfSUNumCurrStandbySIs=%u", name.value, + TRACE("%s saAmfSUNumCurrStandbySIs=%u", name.c_str(), saAmfSUNumCurrStandbySIs); m_AVSV_SEND_CKPT_UPDT_ASYNC_UPDT(avd_cb, this, AVSV_CKPT_SU_SI_CURR_STBY); } @@ -1933,7 +1970,8 @@ param.class_id = AVSV_SA_AMF_SU; param.act = AVSV_OBJ_OPR_MOD; - param.name = name; + const SaNameTWrapper temp_name(name); + param.name = temp_name; switch (attrib_id) { case saAmfSUFailOver_ID: @@ -1955,7 +1993,7 @@ (su_node_ptr->node_state == AVD_AVND_STATE_NO_CONFIG) || (su_node_ptr->node_state == AVD_AVND_STATE_NCS_INIT))) { if (avd_snd_op_req_msg(avd_cb, su_node_ptr, ¶m) != NCSCC_RC_SUCCESS) { - LOG_ER("%s:failed for %s",__FUNCTION__, su_node_ptr->name.value); + LOG_ER("%s:failed for %s",__FUNCTION__, su_node_ptr->name.c_str()); } } @@ -1965,7 +2003,7 @@ void AVD_SU::set_su_failover(bool value) { saAmfSUFailover = value; TRACE("Modified saAmfSUFailover to '%u' for '%s'", - saAmfSUFailover, name.value); + saAmfSUFailover, name.c_str()); send_attribute_update(saAmfSUFailOver_ID); } @@ -1974,7 +2012,7 @@ * */ void AVD_SU::delete_all_susis(void) { - TRACE_ENTER2("'%s'", name.value); + TRACE_ENTER2("'%s'", name.c_str()); while (list_of_susi != nullptr) { avd_compcsi_delete(avd_cb, list_of_susi, false); @@ -1991,7 +2029,7 @@ void AVD_SU::set_all_susis_assigned_quiesced(void) { AVD_SU_SI_REL *susi = list_of_susi; - TRACE_ENTER2("'%s'", name.value); + TRACE_ENTER2("'%s'", name.c_str()); for (; susi != nullptr; susi = susi->su_next) { if (susi->fsm != AVD_SU_SI_STATE_UNASGN) { @@ -2011,7 +2049,7 @@ void AVD_SU::set_all_susis_assigned(void) { AVD_SU_SI_REL *susi = list_of_susi; - TRACE_ENTER2("'%s'", name.value); + TRACE_ENTER2("'%s'", name.c_str()); for (; susi != nullptr; susi = susi->su_next) { if (susi->fsm != AVD_SU_SI_STATE_UNASGN) { @@ -2026,13 +2064,13 @@ void AVD_SU::set_term_state(bool state) { term_state = state; - TRACE("%s term_state %u", name.value, term_state); + TRACE("%s term_state %u", name.c_str(), term_state); m_AVSV_SEND_CKPT_UPDT_ASYNC_UPDT(avd_cb, this, AVSV_CKPT_SU_TERM_STATE); } void AVD_SU::set_su_switch(SaToggleState state) { su_switch = state; - TRACE("%s su_switch %u", name.value, su_switch); + TRACE("%s su_switch %u", name.c_str(), su_switch); m_AVSV_SEND_CKPT_UPDT_ASYNC_UPDT(avd_cb, this, AVSV_CKPT_SU_SWITCH); } @@ -2102,9 +2140,9 @@ void AVD_SU::set_saAmfSUPreInstantiable(bool value) { saAmfSUPreInstantiable = static_cast<SaBoolT>(value); - avd_saImmOiRtObjectUpdate(&name, "saAmfSUPreInstantiable", + avd_saImmOiRtObjectUpdate(name, "saAmfSUPreInstantiable", SA_IMM_ATTR_SAUINT32T, &saAmfSUPreInstantiable); - TRACE("%s saAmfSUPreInstantiable %u", name.value, value); + TRACE("%s saAmfSUPreInstantiable %u", name.c_str(), value); } /** @@ -2119,13 +2157,13 @@ * @param cstype * @return */ -AVD_COMP *AVD_SU::find_unassigned_comp_that_provides_cstype(const SaNameT *cstype) { +AVD_COMP *AVD_SU::find_unassigned_comp_that_provides_cstype(const std::string& cstype) { AVD_COMP *l_comp = nullptr; auto iter = list_of_comp.begin(); for (; iter != list_of_comp.end(); ++iter) { l_comp = *iter; bool npi_is_assigned = false; - AVD_COMP_TYPE *comptype = comptype_db->find(Amf::to_string(&l_comp->saAmfCompType)); + AVD_COMP_TYPE *comptype = comptype_db->find(l_comp->saAmfCompType); osafassert(comptype); if ((comptype->saAmfCtCompCategory == SA_AMF_COMP_LOCAL) && is_comp_assigned_any_csi(l_comp)) npi_is_assigned = true; @@ -2260,20 +2298,20 @@ SaAisErrorT rc = SA_AIS_OK; if (pend_cbk.admin_oper != 0) { - LOG_NO("'%s' undergoing admin operation", name.value); + LOG_NO("'%s' undergoing admin operation", name.c_str()); rc = SA_AIS_ERR_TRY_AGAIN; goto done; } if ((saAmfSUPresenceState == SA_AMF_PRESENCE_INSTANTIATING) || (saAmfSUPresenceState == SA_AMF_PRESENCE_TERMINATING) || (saAmfSUPresenceState == SA_AMF_PRESENCE_RESTARTING)) { - LOG_NO("'%s' has presence state '%u'", name.value,saAmfSUPresenceState); + LOG_NO("'%s' has presence state '%u'", name.c_str(),saAmfSUPresenceState); rc = SA_AIS_ERR_TRY_AGAIN; goto done; } if ((saAmfSUPresenceState == SA_AMF_PRESENCE_INSTANTIATION_FAILED) || (saAmfSUPresenceState == SA_AMF_PRESENCE_TERMINATION_FAILED)) { - LOG_NO("'%s' is in repair pending state", name.value); + LOG_NO("'%s' is in repair pending state", name.c_str()); rc = SA_AIS_ERR_BAD_OPERATION; goto done; } @@ -2348,7 +2386,7 @@ bool AVD_SU::all_pi_comps_restartable() { for (const auto& comp : list_of_comp) { - AVD_COMP_TYPE *comptype = comptype_db->find(Amf::to_string(&comp->saAmfCompType)); + AVD_COMP_TYPE *comptype = comptype_db->find(comp->saAmfCompType); if ((comp->comp_info.comp_restart == true) && ((comptype->saAmfCtCompCategory == SA_AMF_COMP_SA_AWARE) || (IS_COMP_PROXIED_PI(comptype->saAmfCtCompCategory)))) @@ -2365,7 +2403,7 @@ bool AVD_SU::all_pi_comps_nonrestartable() { for (const auto& comp : list_of_comp) { - AVD_COMP_TYPE *comptype = comptype_db->find(Amf::to_string(&comp->saAmfCompType)); + AVD_COMP_TYPE *comptype = comptype_db->find(comp->saAmfCompType); if ((comp->comp_info.comp_restart == false) && ((comptype->saAmfCtCompCategory == SA_AMF_COMP_SA_AWARE) || (IS_COMP_PROXIED_PI(comptype->saAmfCtCompCategory)))) @@ -2396,7 +2434,7 @@ void AVD_SU::set_surestart(bool value) { surestart = value; - TRACE("surestart flag set to '%u' for '%s'",surestart, name.value); + TRACE("surestart flag set to '%u' for '%s'",surestart, name.c_str()); } bool AVD_SU::get_surestart() const diff --git a/osaf/services/saf/amf/amfd/sutcomptype.cc b/osaf/services/saf/amf/amfd/sutcomptype.cc --- a/osaf/services/saf/amf/amfd/sutcomptype.cc +++ b/osaf/services/saf/amf/amfd/sutcomptype.cc @@ -28,20 +28,19 @@ static void sutcomptype_db_add(AVD_SUTCOMP_TYPE *sutcomptype) { - unsigned int rc = sutcomptype_db->insert(Amf::to_string(&sutcomptype->name),sutcomptype); + unsigned int rc = sutcomptype_db->insert(sutcomptype->name,sutcomptype); osafassert(rc == NCSCC_RC_SUCCESS); } -static AVD_SUTCOMP_TYPE *sutcomptype_create(SaNameT *dn, const SaImmAttrValuesT_2 **attributes) +static AVD_SUTCOMP_TYPE *sutcomptype_create(const std::string& dn, const SaImmAttrValuesT_2 **attributes) { AVD_SUTCOMP_TYPE *sutcomptype; - TRACE_ENTER2("'%s'", dn->value); + TRACE_ENTER2("'%s'", dn.c_str()); sutcomptype = new AVD_SUTCOMP_TYPE(); - memcpy(sutcomptype->name.value, dn->value, dn->length); - sutcomptype->name.length = dn->length; + sutcomptype->name = dn; if (immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfSutMaxNumComponents"), attributes, 0, &sutcomptype->saAmfSutMaxNumComponents) != SA_AIS_OK) sutcomptype->saAmfSutMaxNumComponents = -1; /* no limit */ @@ -55,17 +54,17 @@ static void sutcomptype_delete(AVD_SUTCOMP_TYPE *sutcomptype) { - sutcomptype_db->erase(Amf::to_string(&sutcomptype->name)); + sutcomptype_db->erase(sutcomptype->name); delete sutcomptype; } -static int is_config_valid(const SaNameT *dn, const SaImmAttrValuesT_2 **attributes, CcbUtilOperationData_t *opdata) +static int is_config_valid(const std::string& dn, const SaImmAttrValuesT_2 **attributes, CcbUtilOperationData_t *opdata) { // TODO return 1; } -SaAisErrorT avd_sutcomptype_config_get(SaNameT *sutype_name, AVD_SUTYPE *sut) +SaAisErrorT avd_sutcomptype_config_get(const std::string& sutype_name, AVD_SUTYPE *sut) { AVD_SUTCOMP_TYPE *sutcomptype; SaAisErrorT error; @@ -81,7 +80,7 @@ searchParam.searchOneAttr.attrValueType = SA_IMM_ATTR_SASTRINGT; searchParam.searchOneAttr.attrValue = &className; - error = immutil_saImmOmSearchInitialize_2(avd_cb->immOmHandle, sutype_name, SA_IMM_SUBTREE, + error = immutil_saImmOmSearchInitialize_o2(avd_cb->immOmHandle, sutype_name.c_str(), SA_IMM_SUBTREE, SA_IMM_SEARCH_ONE_ATTR | SA_IMM_SEARCH_GET_ALL_ATTR, &searchParam, nullptr, &searchHandle); @@ -91,10 +90,10 @@ } while (immutil_saImmOmSearchNext_2(searchHandle, &dn, (SaImmAttrValuesT_2 ***)&attributes) == SA_AIS_OK) { - if (!is_config_valid(&dn, attributes, nullptr)) + if (!is_config_valid(Amf::to_string(&dn), attributes, nullptr)) goto done2; if ((sutcomptype = sutcomptype_db->find(Amf::to_string(&dn))) == nullptr) { - if ((sutcomptype = sutcomptype_create(&dn, attributes)) == nullptr) { + if ((sutcomptype = sutcomptype_create(Amf::to_string(&dn), attributes)) == nullptr) { error = SA_AIS_ERR_FAILED_OPERATION; goto done2; } @@ -121,7 +120,7 @@ switch (opdata->operationType) { case CCBUTIL_CREATE: - if (is_config_valid(&opdata->objectName, opdata->param.create.attrValues, opdata)) + if (is_config_valid(Amf::to_string(&opdata->objectName), opdata->param.create.attrValues, opdata)) rc = SA_AIS_OK; break; case CCBUTIL_MODIFY: @@ -150,7 +149,7 @@ switch (opdata->operationType) { case CCBUTIL_CREATE: - sutcomptype = sutcomptype_create(&opdata->objectName, opdata->param.create.attrValues); + sutcomptype = sutcomptype_create(Amf::to_string(&opdata->objectName), opdata->param.create.attrValues); osafassert(sutcomptype); sutcomptype_db_add(sutcomptype); break; diff --git a/osaf/services/saf/amf/amfd/sutype.cc b/osaf/services/saf/amf/amfd/sutype.cc --- a/osaf/services/saf/amf/amfd/sutype.cc +++ b/osaf/services/saf/amf/amfd/sutype.cc @@ -32,12 +32,12 @@ AmfDb<std::string, AVD_SUTYPE> *sutype_db = nullptr; // -AVD_SUTYPE::AVD_SUTYPE(const SaNameT *dn) { - memcpy(&name.value, dn->value, dn->length); - name.length = dn->length; +AVD_SUTYPE::AVD_SUTYPE(const std::string& dn) : + name(dn) +{ } -static AVD_SUTYPE *sutype_new(const SaNameT *dn) +static AVD_SUTYPE *sutype_new(const std::string& dn) { AVD_SUTYPE *sutype = new AVD_SUTYPE(dn); @@ -47,18 +47,17 @@ static void sutype_delete(AVD_SUTYPE **sutype) { osafassert(true == (*sutype)->list_of_su.empty()); - delete [] (*sutype)->saAmfSutProvidesSvcTypes; delete *sutype; *sutype = nullptr; } static void sutype_db_add(AVD_SUTYPE *sutype) { - unsigned int rc = sutype_db->insert(Amf::to_string(&sutype->name),sutype); + unsigned int rc = sutype_db->insert(sutype->name,sutype); osafassert(rc == NCSCC_RC_SUCCESS); } -static AVD_SUTYPE *sutype_create(const SaNameT *dn, const SaImmAttrValuesT_2 **attributes) +static AVD_SUTYPE *sutype_create(const std::string& dn, const SaImmAttrValuesT_2 **attributes) { const SaImmAttrValuesT_2 *attr; AVD_SUTYPE *sutype; @@ -66,7 +65,7 @@ unsigned i = 0; SaAisErrorT error; - TRACE_ENTER2("'%s'", dn->value); + TRACE_ENTER2("'%s'", dn.c_str()); if ((sutype = sutype_new(dn)) == nullptr) { LOG_ER("avd_sutype_new failed"); @@ -87,14 +86,16 @@ osafassert(attr->attrValuesNumber > 0); sutype->number_svc_types = attr->attrValuesNumber; - sutype->saAmfSutProvidesSvcTypes = new SaNameT[sutype->number_svc_types]; + osafassert(sutype->saAmfSutProvidesSvcTypes.empty() == true); for (i = 0; i < sutype->number_svc_types; i++) { - if (immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfSutProvidesSvcTypes"), attributes, i, &sutype->saAmfSutProvidesSvcTypes[i]) != SA_AIS_OK) { - LOG_ER("Get saAmfSutProvidesSvcTypes FAILED for '%s'", dn->value); + SaNameT svc_type; + if (immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfSutProvidesSvcTypes"), attributes, i, &svc_type) != SA_AIS_OK) { + LOG_ER("Get saAmfSutProvidesSvcTypes FAILED for '%s'", dn.c_str()); osafassert(0); } - TRACE("%s", sutype->saAmfSutProvidesSvcTypes[i].value); + sutype->saAmfSutProvidesSvcTypes.push_back(Amf::to_string(&svc_type)); + TRACE("%s", sutype->saAmfSutProvidesSvcTypes.back().c_str()); } rc = 0; @@ -107,23 +108,21 @@ return sutype; } -static int is_config_valid(const SaNameT *dn, const SaImmAttrValuesT_2 **attributes, CcbUtilOperationData_t *opdata) +static int is_config_valid(const std::string& dn, const SaImmAttrValuesT_2 **attributes, CcbUtilOperationData_t *opdata) { SaAisErrorT rc; SaBoolT abool; /* int i = 0; */ - char *parent; + std::string::size_type pos; - if ((parent = strchr((char*)dn->value, ',')) == nullptr) { - report_ccb_validation_error(opdata, "No parent to '%s' ", dn->value); + if ((pos = dn.find(',')) == std::string::npos) { + report_ccb_validation_error(opdata, "No parent to '%s' ", dn.c_str()); return 0; } - parent++; - /* Should be children to the SU Base type */ - if (strncmp(parent, "safSuType=", 10) != 0) { - report_ccb_validation_error(opdata, "Wrong parent '%s' to '%s' ", parent, dn->value); + if (dn.compare(pos + 1, 10, "safSuType=") != 0) { + report_ccb_validation_error(opdata, "Wrong parent '%s' to '%s' ", dn.substr(pos +1).c_str(), dn.c_str()); return 0; } #if 0 @@ -152,7 +151,7 @@ if ((immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfSutDefSUFailover"), attributes, 0, &abool) == SA_AIS_OK) && (abool > SA_TRUE)) { - report_ccb_validation_error(opdata, "Invalid saAmfSutDefSUFailover %u for '%s'", abool, dn->value); + report_ccb_validation_error(opdata, "Invalid saAmfSutDefSUFailover %u for '%s'", abool, dn.c_str()); return 0; } @@ -161,7 +160,7 @@ if ((immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfSutIsExternal"), attributes, 0, &abool) == SA_AIS_OK) && (abool > SA_TRUE)) { - report_ccb_validation_error(opdata, "Invalid saAmfSutIsExternal %u for '%s'", abool, dn->value); + report_ccb_validation_error(opdata, "Invalid saAmfSutIsExternal %u for '%s'", abool, dn.c_str()); return 0; } @@ -194,12 +193,13 @@ } while (immutil_saImmOmSearchNext_2(searchHandle, &dn, (SaImmAttrValuesT_2 ***)&attributes) == SA_AIS_OK) { - if (!is_config_valid(&dn, attributes, nullptr)) + const std::string temp_dn(Amf::to_string(&dn)); + if (!is_config_valid(temp_dn, attributes, nullptr)) goto done2; - if (( sut = sutype_db->find(Amf::to_string(&dn))) == nullptr) { + if (( sut = sutype_db->find(temp_dn)) == nullptr) { - if ((sut = sutype_create(&dn, attributes)) == nullptr) { + if ((sut = sutype_create(temp_dn, attributes)) == nullptr) { error = SA_AIS_ERR_FAILED_OPERATION; goto done2; } @@ -207,7 +207,7 @@ sutype_db_add(sut); } - if (avd_sutcomptype_config_get(&dn, sut) != SA_AIS_OK) { + if (avd_sutcomptype_config_get(temp_dn, sut) != SA_AIS_OK) { error = SA_AIS_ERR_FAILED_OPERATION; goto done2; } @@ -265,7 +265,7 @@ switch (opdata->operationType) { case CCBUTIL_CREATE: - sut = sutype_create(&opdata->objectName, opdata->param.create.attrValues); + sut = sutype_create(Amf::to_string(&opdata->objectName), opdata->param.create.attrValues); osafassert(sut); sutype_db_add(sut); break; @@ -274,7 +274,7 @@ break; case CCBUTIL_DELETE: sut = sutype_db->find(Amf::to_string(&opdata->objectName)); - sutype_db->erase(Amf::to_string(&sut->name)); + sutype_db->erase(sut->name); sutype_delete(&sut); break; default: @@ -310,7 +310,7 @@ uint32_t sut_failover = *((SaUint32T *)attr_mod->modAttr.attrValues[0]); if (sut_failover > SA_TRUE) { - report_ccb_validation_error(opdata, "invalid saAmfSutDefSUFailover in:'%s'", sut->name.value); + report_ccb_validation_error(opdata, "invalid saAmfSutDefSUFailover in:'%s'", sut->name.c_str()); rc = SA_AIS_ERR_BAD_OPERATION; goto done; } @@ -353,7 +353,7 @@ switch (opdata->operationType) { case CCBUTIL_CREATE: - if (is_config_valid(&opdata->objectName, opdata->param.create.attrValues, opdata)) + if (is_config_valid(Amf::to_string(&opdata->objectName), opdata->param.create.attrValues, opdata)) rc = SA_AIS_OK; break; case CCBUTIL_MODIFY: @@ -367,7 +367,8 @@ */ for (const auto& su : sut->list_of_su) { - t_opData = ccbutil_getCcbOpDataByDN(opdata->ccbId, &su->name); + const SaNameTWrapper su_name(su->name); + t_opData = ccbutil_getCcbOpDataByDN(opdata->ccbId, su_name); if ((t_opData == nullptr) || (t_opData->operationType != CCBUTIL_DELETE)) { su_exist = true; break; @@ -375,7 +376,7 @@ } if (su_exist == true) { - report_ccb_validation_error(opdata, "SaAmfSUType '%s'is in use",sut->name.value); + report_ccb_validation_error(opdata, "SaAmfSUType '%s'is in use",sut->name.c_str()); goto done; } rc = SA_AIS_OK; diff --git a/osaf/services/saf/amf/amfd/svctype.cc b/osaf/services/saf/amf/amfd/svctype.cc --- a/osaf/services/saf/amf/amfd/svctype.cc +++ b/osaf/services/saf/amf/amfd/svctype.cc @@ -44,14 +44,14 @@ static void svctype_db_add(AVD_SVC_TYPE *svct) { - unsigned int rc = svctype_db->insert(Amf::to_string(&svct->name),svct); + unsigned int rc = svctype_db->insert(svct->name,svct); osafassert (rc == NCSCC_RC_SUCCESS); } static void svctype_delete(AVD_SVC_TYPE *svc_type) { - svctype_db->erase(Amf::to_string(&svc_type->name)); + svctype_db->erase(svc_type->name); if (svc_type->saAmfSvcDefActiveWeight != nullptr) { unsigned int i = 0; @@ -74,18 +74,18 @@ } // -AVD_SVC_TYPE::AVD_SVC_TYPE(const SaNameT *dn) { - memcpy(&name.value, dn->value, dn->length); - name.length = dn->length; +AVD_SVC_TYPE::AVD_SVC_TYPE(const std::string& dn) : + name(dn) +{ } -static AVD_SVC_TYPE *svctype_create(const SaNameT *dn, const SaImmAttrValuesT_2 **attributes) +static AVD_SVC_TYPE *svctype_create(const std::string& dn, const SaImmAttrValuesT_2 **attributes) { unsigned int i; AVD_SVC_TYPE *svct; SaUint32T attrValuesNumber; - TRACE_ENTER2("'%s'", dn->value); + TRACE_ENTER2("'%s'", dn.c_str()); svct = new AVD_SVC_TYPE(dn); @@ -116,18 +116,18 @@ return svct; } -static int is_config_valid(const SaNameT *dn, const SaImmAttrValuesT_2 **attributes, CcbUtilOperationData_t *opdata) +static int is_config_valid(const std::string& dn, const SaImmAttrValuesT_2 **attributes, CcbUtilOperationData_t *opdata) { - char *parent; + std::string::size_type pos; - if ((parent = strchr((char*)dn->value, ',')) == nullptr) { - report_ccb_validation_error(opdata, "No parent to '%s' ", dn->value); + if ((pos = dn.find(',')) == std::string::npos) { + report_ccb_validation_error(opdata, "No parent to '%s' ", dn.c_str()); return 0; } /* Should be children to the SvcBasetype */ - if (strncmp(++parent, "safSvcType=", 11) != 0) { - report_ccb_validation_error(opdata, "Wrong parent '%s' to '%s' ", parent, dn->value); + if (dn.compare(pos + 1, 11, "safSvcType=") != 0) { + report_ccb_validation_error(opdata, "Wrong parent '%s' to '%s' ", dn.substr(pos +1).c_str(), dn.c_str()); return 0; } @@ -146,7 +146,7 @@ switch (opdata->operationType) { case CCBUTIL_CREATE: - if (is_config_valid(&opdata->objectName, opdata->param.create.attrValues, opdata)) + if (is_config_valid(Amf::to_string(&opdata->objectName), opdata->param.create.attrValues, opdata)) rc = SA_AIS_OK; break; case CCBUTIL_MODIFY: @@ -159,7 +159,8 @@ * each of the SI in the svc_type list in the current CCB */ for (const auto& si : svc_type->list_of_si) { - t_opData = ccbutil_getCcbOpDataByDN(opdata->ccbId, &si->name); + const SaNameTWrapper si_name(si->name); + t_opData = ccbutil_getCcbOpDataByDN(opdata->ccbId, si_name); if ((t_opData == nullptr) || (t_opData->operationType != CCBUTIL_DELETE)) { si_exist = true; break; @@ -167,7 +168,7 @@ } if (si_exist == true) { - report_ccb_validation_error(opdata, "SaAmfSvcType '%s' is in use",svc_type->name.value); + report_ccb_validation_error(opdata, "SaAmfSvcType '%s' is in use",svc_type->name.c_str()); goto done; } opdata->userData = svc_type; @@ -190,7 +191,7 @@ switch (opdata->operationType) { case CCBUTIL_CREATE: - svc_type = svctype_create(&opdata->objectName, opdata->param.create.attrValues); + svc_type = svctype_create(Amf::to_string(&opdata->objectName), opdata->param.create.attrValues); osafassert(svc_type); svctype_db_add(svc_type); break; @@ -239,17 +240,18 @@ } while (immutil_saImmOmSearchNext_2(searchHandle, &dn, (SaImmAttrValuesT_2 ***)&attributes) == SA_AIS_OK) { - if (!is_config_valid(&dn, attributes, nullptr)) + const std::string temp_dn(Amf::to_string(&dn)); + if (!is_config_valid(temp_dn, attributes, nullptr)) goto done2; - if ((svc_type = svctype_db->find(Amf::to_string(&dn))) == nullptr) { - if ((svc_type = svctype_create(&dn, attributes)) == nullptr) + if ((svc_type = svctype_db->find(temp_dn)) == nullptr) { + if ((svc_type = svctype_create(temp_dn, attributes)) == nullptr) goto done2; svctype_db_add(svc_type); } - if (avd_svctypecstypes_config_get(&dn) != SA_AIS_OK) + if (avd_svctypecstypes_config_get(temp_dn) != SA_AIS_OK) goto done2; } diff --git a/osaf/services/saf/amf/amfd/svctypecstypes.cc b/osaf/services/saf/amf/amfd/svctypecstypes.cc --- a/osaf/services/saf/amf/amfd/svctypecstypes.cc +++ b/osaf/services/saf/amf/amfd/svctypecstypes.cc @@ -26,21 +26,21 @@ AmfDb<std::string, AVD_SVC_TYPE_CS_TYPE> *svctypecstypes_db = nullptr; static void svctypecstype_db_add(AVD_SVC_TYPE_CS_TYPE *svctypecstype) { - uint32_t rc = svctypecstypes_db->insert(Amf::to_string(&svctypecstype->name),svctypecstype); + uint32_t rc = svctypecstypes_db->insert(svctypecstype->name,svctypecstype); osafassert(rc == NCSCC_RC_SUCCESS); } // -AVD_SVC_TYPE_CS_TYPE::AVD_SVC_TYPE_CS_TYPE(const SaNameT *dn) { - memcpy(&name.value, dn->value, dn->length); - name.length = dn->length; +AVD_SVC_TYPE_CS_TYPE::AVD_SVC_TYPE_CS_TYPE(const std::string& dn) : + name(dn) +{ } -static AVD_SVC_TYPE_CS_TYPE *svctypecstypes_create(SaNameT *dn, const SaImmAttrValuesT_2 **attributes) +static AVD_SVC_TYPE_CS_TYPE *svctypecstypes_create(const std::string& dn, const SaImmAttrValuesT_2 **attributes) { AVD_SVC_TYPE_CS_TYPE *svctypecstype; - TRACE_ENTER2("'%s'", dn->value); + TRACE_ENTER2("'%s'", dn.c_str()); svctypecstype = new AVD_SVC_TYPE_CS_TYPE(dn); @@ -60,7 +60,7 @@ * * @return SaAisErrorT */ -SaAisErrorT avd_svctypecstypes_config_get(SaNameT *svctype_name) +SaAisErrorT avd_svctypecstypes_config_get(const std::string& svctype_name) { AVD_SVC_TYPE_CS_TYPE *svctypecstype; SaAisErrorT error; @@ -74,7 +74,7 @@ searchParam.searchOneAttr.attrValueType = SA_IMM_ATTR_SASTRINGT; searchParam.searchOneAttr.attrValue = &className; - error = immutil_saImmOmSearchInitialize_2(avd_cb->immOmHandle, svctype_name, SA_IMM_SUBTREE, + error = immutil_saImmOmSearchInitialize_o2(avd_cb->immOmHandle, svctype_name.c_str(), SA_IMM_SUBTREE, SA_IMM_SEARCH_ONE_ATTR | SA_IMM_SEARCH_GET_ALL_ATTR, &searchParam, nullptr, &searchHandle); @@ -86,7 +86,7 @@ while (immutil_saImmOmSearchNext_2(searchHandle, &dn, (SaImmAttrValuesT_2 ***)&attributes) == SA_AIS_OK) { if ((svctypecstype = svctypecstypes_db->find(Amf::to_string(&dn)))== nullptr) { - if ((svctypecstype = svctypecstypes_create(&dn, attributes)) == nullptr) { + if ((svctypecstype = svctypecstypes_create(Amf::to_string(&dn), attributes)) == nullptr) { error = SA_AIS_ERR_FAILED_OPERATION; goto done2; } @@ -117,26 +117,27 @@ switch (opdata->operationType) { case CCBUTIL_CREATE: { - SaNameT cstype_dn; - const SaNameT *dn = &opdata->objectName; + std::string cstype_dn; + const std::string dn = Amf::to_string(&opdata->objectName); - if (get_child_dn_from_ass_dn(dn, &cstype_dn) != 0) { - report_ccb_validation_error(opdata, "malformed DN '%s'", dn->value); + if (get_child_dn_from_ass_dn(dn, cstype_dn) != 0) { + report_ccb_validation_error(opdata, "malformed DN '%s'", dn.c_str()); goto done; } - if (cstype_db->find(Amf::to_string(&cstype_dn)) == nullptr) { - if (cstype_db->find(Amf::to_string(&cstype_dn)) == nullptr) { + if (cstype_db->find(cstype_dn) == nullptr) { + if (cstype_db->find(cstype_dn) == nullptr) { if (opdata == nullptr) { report_ccb_validation_error(opdata, - "SaAmfCSType object '%s' does not exist", cstype_dn.value); + "SaAmfCSType object '%s' does not exist", cstype_dn.c_str()); goto done; } - if (ccbutil_getCcbOpDataByDN(opdata->ccbId, &cstype_dn) == nullptr) { + const SaNameTWrapper type_cstype_dn(cstype_dn); + if (ccbutil_getCcbOpDataByDN(opdata->ccbId, type_cstype_dn) == nullptr) { report_ccb_validation_error(opdata, "SaAmfCSType object '%s' does not exist in model or in CCB", - cstype_dn.value); + cstype_dn.c_str()); goto done; } } @@ -176,7 +177,7 @@ switch (opdata->operationType) { case CCBUTIL_CREATE: - svctypecstype = svctypecstypes_create(&opdata->objectName, opdata->param.create.attrValues); + svctypecstype = svctypecstypes_create(Amf::to_string(&opdata->objectName), opdata->param.create.attrValues); osafassert(svctypecstype); svctypecstype_db_add(svctypecstype); break; ------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel