/* SA_AIS_ERR_BAD_OPERATION */ void saImmOmCcbObjectModify_2_04(void) { const SaImmAdminOwnerNameT adminOwnerName = (SaImmAdminOwnerNameT) __FUNCTION__; SaImmAdminOwnerHandleT ownerHandle; SaImmCcbHandleT ccbHandle; const SaNameT *objectNames[] = {&rootObj, NULL}; SaUint32T int1Value1 = __LINE__; SaUint32T* int1Values[] = {&int1Value1}; SaImmAttrValuesT_2 v1 = {"attr1", SA_IMM_ATTR_SAUINT32T, 1, (void**)int1Values}; SaImmAttrModificationT_2 attrMod = {SA_IMM_ATTR_VALUES_REPLACE, v1}; const SaImmAttrModificationT_2 *attrMods[] = {&attrMod, NULL}; safassert(saImmOmInitialize(&immOmHandle, NULL, &immVersion), SA_AIS_OK); safassert(saImmOmAdminOwnerInitialize(immOmHandle, adminOwnerName, SA_TRUE, &ownerHandle), SA_AIS_OK); safassert(saImmOmAdminOwnerSet(ownerHandle, objectNames, SA_IMM_SUBTREE), SA_AIS_OK); safassert(config_object_create(immOmHandle, ownerHandle, &rootObj), SA_AIS_OK); safassert(saImmOmAdminOwnerRelease(ownerHandle, objectNames, SA_IMM_SUBTREE), SA_AIS_OK); safassert(saImmOmCcbInitialize(ownerHandle, 0, &ccbHandle), SA_AIS_OK); rc = saImmOmCcbObjectModify_2(ccbHandle, &dnObj1, attrMods); safassert(saImmOmCcbFinalize(ccbHandle), SA_AIS_OK); safassert(saImmOmAdminOwnerSet(ownerHandle, objectNames, SA_IMM_SUBTREE), SA_AIS_OK); safassert(config_object_delete(immOmHandle, ownerHandle), SA_AIS_OK); safassert(saImmOmAdminOwnerFinalize(ownerHandle), SA_AIS_OK); safassert(saImmOmFinalize(immOmHandle), SA_AIS_OK); test_validate(rc, SA_AIS_ERR_BAD_OPERATION); }
static void generate_pop(range_obj_t* rootObj, SaImmCcbHandleT ccbHandle, const SaImmClassNameT className, SaImmAttrNameT rdnAttName, SaImmValueTypeT rdnAttType, SaImmAdminOwnerHandleT ownerHandle) { SaAisErrorT err = SA_AIS_OK; unsigned int ix; unsigned int rdn = rootObj->botRdn; SaNameT rdnAttrVal; unsigned int retries = 0; const SaNameT* objectNames[] = {&(rootObj->parentDn), NULL}; for (ix = 0; ix < 100 && rdn <= rootObj->topRdn; ++ix, ++rdn) { rdnAttrVal.length = snprintf((char *) rdnAttrVal.value, sizeof(rdnAttrVal.value), "%s=%u", rdnAttName, rdn); ccb_create_obj(&rootObj->parentDn, &rdnAttrVal, ccbHandle, className, rdnAttName, rdnAttType); } do { err = saImmOmCcbApply(ccbHandle); if(err == SA_AIS_ERR_TRY_AGAIN) { usleep(250 * 1000); } } while ((err == SA_AIS_ERR_TRY_AGAIN) && (retries < 15)); if (err != SA_AIS_OK) { fprintf(stderr, "error - Failed to apply ccb for parent:%s range %u<->%u, error:%s\n", (char *) rootObj->parentDn.value, rootObj->botRdn, rootObj->topRdn, saf_error(err)); exit(1); } VERBOSE_INFO("successfull Apply for parent %s range %u<->%u\n", (char *) rootObj->parentDn.value, rootObj->botRdn, rootObj->topRdn); for (ix = 0; ix < 100 && rootObj->sublevel[ix]; ++ix) { generate_pop(rootObj->sublevel[ix], ccbHandle, className, rdnAttName, rdnAttType, ownerHandle); } err = saImmOmAdminOwnerRelease(ownerHandle, objectNames, SA_IMM_ONE); if (err != SA_AIS_OK) { fprintf(stderr, "error - Failed to release admo - ignoring\n"); } }
void saImmOmCcbObjectDelete_03(void) { const SaImmAdminOwnerNameT adminOwnerName = (SaImmAdminOwnerNameT) __FUNCTION__; SaImmAdminOwnerHandleT ownerHandle; SaImmCcbHandleT ccbHandle; const SaNameT *objectNames[] = {&parentName, NULL}; safassert(saImmOmInitialize(&immOmHandle, &immOmCallbacks, &immVersion), SA_AIS_OK); safassert(saImmOmAdminOwnerInitialize(immOmHandle, adminOwnerName, SA_TRUE, &ownerHandle), SA_AIS_OK); safassert(saImmOmAdminOwnerSet(ownerHandle, objectNames, SA_IMM_ONE), SA_AIS_OK); safassert(config_class_create(immOmHandle), SA_AIS_OK); safassert(config_object_create(immOmHandle, ownerHandle, &parentName), SA_AIS_OK); safassert(saImmOmAdminOwnerRelease(ownerHandle, objectNames, SA_IMM_SUBTREE), SA_AIS_OK); safassert(saImmOmCcbInitialize(ownerHandle, 0, &ccbHandle), SA_AIS_OK); /* ** at least one of the targeted objects is not a configuration object that is owned by ** the administrative owner of the CCB */ if ((rc = saImmOmCcbObjectDelete(ccbHandle, &dnObj1)) != SA_AIS_ERR_BAD_OPERATION) { TRACE_ENTER(); goto done; } /* ** at least one of the targeted objects has some registered continuation identifiers */ /* ** the Object Implementer has rejected the deletion of at least one of the targeted ** objects. */ done: safassert(saImmOmAdminOwnerSet(ownerHandle, objectNames, SA_IMM_SUBTREE), SA_AIS_OK); safassert(config_object_delete(immOmHandle, ownerHandle), SA_AIS_OK); safassert(config_class_delete(immOmHandle), SA_AIS_OK); safassert(saImmOmAdminOwnerFinalize(ownerHandle), SA_AIS_OK); safassert(saImmOmFinalize(immOmHandle), SA_AIS_OK); test_validate(rc, SA_AIS_ERR_BAD_OPERATION); }
void saImmOmCcbApply_01(void) { const SaImmAdminOwnerNameT adminOwnerName = (SaImmAdminOwnerNameT) __FUNCTION__; SaImmAdminOwnerHandleT ownerHandle; SaImmCcbHandleT ccbHandle; SaNameT rdn = {strlen("Obj1"), "Obj1"}; SaNameT* nameValues[] = {&rdn}; SaImmAttrValuesT_2 v2 = {"rdn", SA_IMM_ATTR_SANAMET, 1, (void**)nameValues}; SaUint32T int1Value1 = 7; SaUint32T* int1Values[] = {&int1Value1}; SaImmAttrValuesT_2 v1 = {"attr1", SA_IMM_ATTR_SAUINT32T, 1, (void**)int1Values}; const SaImmAttrValuesT_2 * attrValues[] = {&v1, &v2, NULL}; const SaNameT parentName = {strlen("opensafImm=opensafImm,safApp=safImmService"), "opensafImm=opensafImm,safApp=safImmService"}; const SaNameT *objectNames[] = {&parentName, NULL}; const SaNameT objectName = {strlen("Obj1,opensafImm=opensafImm,safApp=safImmService"), "Obj1,opensafImm=opensafImm,safApp=safImmService"}; safassert(saImmOmInitialize(&immOmHandle, &immOmCallbacks, &immVersion), SA_AIS_OK); safassert(config_class_create(immOmHandle), SA_AIS_OK); safassert(saImmOmAdminOwnerInitialize(immOmHandle, adminOwnerName, /*SA_TRUE*/SA_FALSE, &ownerHandle), SA_AIS_OK); safassert(saImmOmAdminOwnerSet(ownerHandle, objectNames, SA_IMM_ONE), SA_AIS_OK); safassert(saImmOmCcbInitialize(ownerHandle, 0, &ccbHandle), SA_AIS_OK); safassert(saImmOmCcbObjectCreate_2(ccbHandle, configClassName, &parentName, attrValues), SA_AIS_OK); test_validate(saImmOmCcbApply(ccbHandle), SA_AIS_OK); safassert(saImmOmCcbObjectDelete(ccbHandle, &objectName), SA_AIS_OK); safassert(saImmOmCcbApply(ccbHandle), SA_AIS_OK); safassert(saImmOmCcbFinalize(ccbHandle), SA_AIS_OK); safassert(config_class_delete(immOmHandle), SA_AIS_OK); safassert(saImmOmAdminOwnerRelease(ownerHandle, objectNames, SA_IMM_ONE), SA_AIS_OK); safassert(saImmOmAdminOwnerFinalize(ownerHandle), SA_AIS_OK); safassert(saImmOmFinalize(immOmHandle), SA_AIS_OK); }
void saImmOmThreadInterference_01(void) { SaImmHandleT immHandle; SaImmOiHandleT immOiHandle; SaImmAdminOwnerHandleT ownerHandle; SaImmSearchHandleT searchHandle; SaImmCcbHandleT ccbHandle; pthread_t threadid1, threadid2; SaAisErrorT rc; SaImmAttrDefinitionT_2 attrDef = { "rdn", SA_IMM_ATTR_SASTRINGT, SA_IMM_ATTR_RDN | SA_IMM_ATTR_CONFIG, NULL }; const SaImmAttrDefinitionT_2 *attrDefs[2] = { &attrDef, NULL }; SaImmClassCategoryT classCategory; SaImmAttrDefinitionT_2 **attrDefinitions; SaImmAccessorHandleT accessorHandle; SaImmAttrNameT attributeNames[2] = { "SaImmAttrClassName", NULL}; SaImmAttrValuesT_2 **attributes; SaImmAttrValueT objNames[2] = { &objectName, NULL }; SaImmAttrValuesT_2 attrValue = { (SaImmAttrNameT)"rdn", SA_IMM_ATTR_SANAMET, 1, (SaImmAttrValueT *)objNames }; const SaImmAttrValuesT_2 *attrValues[2] = { &attrValue, NULL }; SaImmAttrValueT modAttrValue[2] = { "Test", NULL }; const SaImmAttrModificationT_2 attrMod = { SA_IMM_ATTR_VALUES_REPLACE, { "attr4", SA_IMM_ATTR_SASTRINGT, 1, modAttrValue } }; const SaImmAttrModificationT_2 *attrMods[] = { &attrMod, NULL }; objectName.length = strlen("Obj1"); strcpy((char *)objectName.value, "Obj1"); /* management */ safassert(saImmOmInitialize(&immHandle, NULL, &immVersion), SA_AIS_OK); safassert(saImmOmAdminOwnerInitialize(immHandle, adminOwnerName, SA_TRUE, &ownerHandle), SA_AIS_OK); /* create test object */ safassert(saImmOmCcbInitialize(ownerHandle, 0, &ccbHandle), SA_AIS_OK); safassert(saImmOmCcbObjectCreate_2(ccbHandle, configClassName, NULL, attrValues), SA_AIS_OK); safassert(saImmOmCcbApply(ccbHandle), SA_AIS_OK); safassert(saImmOmAdminOwnerSet(ownerHandle, objectNames, SA_IMM_ONE), SA_AIS_OK); /* implementer */ isReady = 0; isOiDone = 0; safassert(saImmOiInitialize_2(&immOiHandle, &immOiCallbacks, &immVersion), SA_AIS_OK); safassert(saImmOiImplementerSet(immOiHandle, implementerName), SA_AIS_OK); safassert(saImmOiObjectImplementerSet(immOiHandle, &objectName, SA_IMM_ONE), SA_AIS_OK); assert(!pthread_create(&threadid1, NULL, implementer_thread, &immOiHandle)); while(!isReady) usleep(100); /* "lock" IMM OM handle */ isReady = 0; isOmDone = 0; isAdminOperDone = 0; assert(!pthread_create(&threadid2, NULL, lockomhandle_thread, &ownerHandle)); while(!isReady) usleep(100); /* OM function tests */ if((rc = saImmOmFinalize(immHandle)) != SA_AIS_ERR_LIBRARY) goto done; if((rc = saImmOmClassCreate_2(immHandle, (const SaImmClassNameT)"TestClass", SA_IMM_CLASS_CONFIG, (const SaImmAttrDefinitionT_2 **)attrDefs)) != SA_AIS_ERR_LIBRARY) goto done; if((rc = saImmOmClassDescriptionGet_2(immHandle, (const SaImmClassNameT)"TestClass", &classCategory, &attrDefinitions)) != SA_AIS_ERR_LIBRARY) goto done; if((rc = saImmOmClassDelete(immHandle, (const SaImmClassNameT)"TestClass")) != SA_AIS_ERR_LIBRARY) goto done; if((rc = saImmOmSearchInitialize_2(immHandle, NULL, SA_IMM_SUBTREE, SA_IMM_SEARCH_ONE_ATTR | SA_IMM_SEARCH_GET_NO_ATTR, NULL, NULL, &searchHandle)) != SA_AIS_ERR_LIBRARY) goto done; safassert(saImmOmAccessorInitialize(immHandle, &accessorHandle), SA_AIS_OK); if((rc = saImmOmAccessorGet_2(accessorHandle, &objectName, attributeNames, &attributes)) != SA_AIS_ERR_LIBRARY) goto done; safassert(saImmOmAccessorFinalize(accessorHandle), SA_AIS_OK); if((rc = saImmOmCcbObjectModify_2(ccbHandle, &objectName, attrMods)) != SA_AIS_ERR_LIBRARY) goto done; if((rc = saImmOmCcbObjectDelete(ccbHandle, &objectName)) != SA_AIS_ERR_LIBRARY) goto done; done: isAdminOperDone = 1; while(!isOmDone) usleep(200); test_validate(rc, SA_AIS_ERR_LIBRARY); /* Finalize OI handle */ safassert(saImmOiObjectImplementerRelease(immOiHandle, &objectName, SA_IMM_ONE), SA_AIS_OK); safassert(saImmOiImplementerClear(immOiHandle), SA_AIS_OK); safassert(saImmOiFinalize(immOiHandle), SA_AIS_OK); /* Use pthread_detach() to remove pthread_create@@GLIBC leak from valgrind */ pthread_detach(threadid1); pthread_detach(threadid2); while(!isOiDone) usleep(200); /* Remove test object and test class */ safassert(saImmOmCcbObjectDelete(ccbHandle, &objectName), SA_AIS_OK); safassert(saImmOmCcbApply(ccbHandle), SA_AIS_OK); /* Finalize OM handles */ saImmOmCcbFinalize(ccbHandle); saImmOmAdminOwnerRelease(ownerHandle, objectNames, SA_IMM_ONE); saImmOmAdminOwnerFinalize(ownerHandle); saImmOmFinalize(immHandle); }