void saPlmEntityGroupCreate_01(void)
{
    SaPlmCallbacksT plms_cbks; 
    plms_cbks.saPlmReadinessTrackCallback = &TrackCallbackT;
    safassert(saPlmInitialize(&plmHandle, &plms_cbks, &PlmVersion), SA_AIS_OK);
    rc = saPlmEntityGroupCreate(plmHandle,&entityGroupHandle);
    rc = saPlmEntityGroupCreate(plmHandle,&entityGroupHandle);
    test_validate(rc, SA_AIS_OK);
    safassert(saPlmFinalize(plmHandle), SA_AIS_OK);
}
void saPlmEntityGroupAdd_09(void)
{
    SaPlmCallbacksT plms_cbks; 
    plms_cbks.saPlmReadinessTrackCallback = &TrackCallbackT;
    safassert(saPlmInitialize(&plmHandle, &plms_cbks, &PlmVersion), SA_AIS_OK);
    safassert(saPlmEntityGroupCreate(plmHandle,&entityGroupHandle),SA_AIS_OK);
    rc=saPlmEntityGroupAdd(entityGroupHandle , &f120_slot_1_dn  , ""  ,SA_PLM_GROUP_SUBTREE_EES_ONLY);
    test_validate(rc, SA_AIS_ERR_INVALID_PARAM);
    safassert(saPlmFinalize(plmHandle), SA_AIS_OK);
}
void saPlmEntityGroupAdd_01(void)
{
    SaPlmCallbacksT plms_cbks; 
    plms_cbks.saPlmReadinessTrackCallback = &TrackCallbackT;
    safassert(saPlmInitialize(&plmHandle, NULL, &PlmVersion), SA_AIS_OK);
    safassert(saPlmEntityGroupCreate(plmHandle,&entityGroupHandle), SA_AIS_OK);
    rc=saPlmEntityGroupAdd(entityGroupHandle , &f120_slot_1_dn , entityNamesNumber,SA_PLM_GROUP_SINGLE_ENTITY);
    test_validate(rc, SA_AIS_OK);
    safassert(saPlmFinalize(plmHandle), SA_AIS_OK);
}
void saPlmEntityGroupAdd_10(void)
{
    SaPlmCallbacksT plms_cbks; 
    plms_cbks.saPlmReadinessTrackCallback = &TrackCallbackT;
    safassert(saPlmInitialize(&plmHandle, &plms_cbks, &PlmVersion), SA_AIS_OK);
    safassert(saPlmEntityGroupCreate(plmHandle,&entityGroupHandle),SA_AIS_OK);
    rc=saPlmEntityGroupAdd(entityGroupHandle , &f120_slot_1_dn , entityNamesNumber,-1);
    test_validate(rc, SA_AIS_ERR_INVALID_PARAM);
    safassert(saPlmFinalize(plmHandle), SA_AIS_OK);
}
void saPlmEntityGroupAdd_16(void)
{
    SaPlmCallbacksT plms_cbks; 
    plms_cbks.saPlmReadinessTrackCallback = &TrackCallbackT;
    safassert(saPlmInitialize(&plmHandle, &plms_cbks, &PlmVersion), SA_AIS_OK);
    safassert(saPlmEntityGroupCreate(plmHandle,&entityGroupHandle),SA_AIS_OK);
    rc=saPlmEntityGroupAdd(entityGroupHandle , &f120_slot_1_dn , entityNamesNumber,SA_PLM_GROUP_SUBTREE);
    rc=saPlmEntityGroupAdd(entityGroupHandle , &amc_slot_1_dn  , entityNamesNumber,SA_PLM_GROUP_SUBTREE);
    test_validate(rc, SA_AIS_ERR_EXIST);
    safassert(saPlmFinalize(plmHandle), SA_AIS_OK);
}
void saPlmEntityGroupAdd_13(void)
{
    SaPlmCallbacksT plms_cbks; 
    plms_cbks.saPlmReadinessTrackCallback = &TrackCallbackT;
    safassert(saPlmInitialize(&plmHandle, &plms_cbks, &PlmVersion), SA_AIS_OK);
    safassert(saPlmEntityGroupCreate(plmHandle,&entityGroupHandle),SA_AIS_OK);
    /* Nonexistent DN*/
    rc=saPlmEntityGroupAdd(entityGroupHandle , &f120_nonexistent , entityNamesNumber,SA_PLM_GROUP_SINGLE_ENTITY);
    test_validate(rc, SA_AIS_ERR_NOT_EXIST);
    safassert(saPlmFinalize(plmHandle), SA_AIS_OK);
}
예제 #7
0
SaAisErrorT clms_plm_init(CLMS_CB * cb)
{
	SaAisErrorT rc = SA_AIS_OK;
	SaVersionT plmVersion = { 'A', 0x01, 0x01 };
	SaNameT *entityNames = NULL;
	CLMS_CLUSTER_NODE *node = NULL;
	SaNameT nodename;
	SaUint32T i = 0, entityNamesNumber = ncs_patricia_tree_size(&clms_cb->ee_lookup);
	SaPlmReadinessTrackedEntitiesT *trackedEntities = NULL;

	TRACE_ENTER();

	rc = saPlmInitialize(&cb->plm_hdl, &callbacks, &plmVersion);
	if (rc != SA_AIS_OK) {
		LOG_ER("saPlmInitialize FAILED rc = %d", rc);
		return rc;
	}

	rc = saPlmSelectionObjectGet(cb->plm_hdl, &cb->plm_sel_obj);
	if (rc != SA_AIS_OK) {
		LOG_ER("saPlmSelectionObjectGet FAILED rc = %d", rc);
		return rc;
	}
	
	if (clms_cb->reg_with_plm == SA_TRUE){
	
		rc = saPlmEntityGroupCreate(cb->plm_hdl, &cb->ent_group_hdl);
		if (rc != SA_AIS_OK) {
			LOG_ER("saPlmEntityGroupCreate FAILED rc = %d", rc);
			return rc;
		}

		memset(&nodename, '\0', sizeof(SaNameT));
		entityNames = (SaNameT *)malloc(sizeof(SaNameT) * entityNamesNumber);

		if (!entityNames) {
			LOG_ER("Malloc failed for entityNames");
			assert(0);
		}

		TRACE("entityNamesNumber %d", entityNamesNumber);

		while ((node = clms_node_getnext_by_name(&nodename)) != NULL) {
			memcpy(&nodename, &node->node_name, sizeof(SaNameT));
			if (node->ee_name.length != 0){
				entityNames[i].length = node->ee_name.length;
				(void)memcpy(entityNames[i].value, node->ee_name.value, entityNames[i].length);
				i++;
			}
		}

		rc = saPlmEntityGroupAdd(cb->ent_group_hdl, entityNames, entityNamesNumber, SA_PLM_GROUP_SINGLE_ENTITY);

		if (rc != SA_AIS_OK) {
			LOG_ER("saPlmEntityGroupAdd FAILED rc = %d", rc);
			return rc;
		}

		trackedEntities = (SaPlmReadinessTrackedEntitiesT *)
			malloc(entityNamesNumber * sizeof(SaPlmReadinessTrackedEntitiesT));

		if(!trackedEntities) {
			LOG_ER("Malloc failed for trackedEntities");
			assert(0);
		}

		memset(trackedEntities, 0, (entityNamesNumber * sizeof(SaPlmReadinessTrackedEntitiesT)));

		rc = saPlmReadinessTrack(cb->ent_group_hdl, (SA_TRACK_CURRENT | SA_TRACK_CHANGES_ONLY | SA_TRACK_START_STEP | SA_TRACK_VALIDATE_STEP), 1, trackedEntities);	/* trackCookie TBD */

		if (rc != SA_AIS_OK) {
			LOG_ER("saPlmReadinessTrack FAILED rc = %d", rc);
			return rc;
		}

		TRACE("trackedEntities->numberOfEntities %d", trackedEntities->numberOfEntities);

		for (i = 0; i < trackedEntities->numberOfEntities; i++) {
			node = clms_node_get_by_eename(&trackedEntities->entities[i].entityName);
			if (node != NULL) {
				node->ee_red_state = trackedEntities->entities[i].currentReadinessStatus.readinessState;
				node->change = trackedEntities->entities[i].change;
				TRACE("node->ee_red_state %d", node->ee_red_state);
			}

		}
	}

	free(entityNames);
	free(trackedEntities);

	TRACE_LEAVE();

	return rc;
}