OpenClovis Logo

Code Examples.

Code Examples.

The PM MSOs can be configured to be autocreated in IDE in which case COR server will create it when the node is coming up. Otherwise it can be created later by the user explicitly using COR Apis. Please refer COR section in this API reference guide for the usage examples.

The below code shows how to register the resources (or MOs) with the PM library so that the PM operation will be performed on those MOs.

ClRcT rc = CL_OK;
//Resource names on which PM operation has to be started.
ClCharT* resources[] = {
"\\Chassis:0\\CorFunTestL1:0\\corFunMOCommB1L3:0",
"\\Chassis:0\\CorFunTestL1:0\\corFunMOCommB1L3:2",
"\\Chassis:0\\CorFunTestL1:0\\corFunMOCommB1L3:3",
"\\Chassis:0\\CorFunTestL1:0\\corFunMOCommB1L3:4"
};
ClUint32T count = 4;
ClUint32T i = 0;
ClNameT moIdName = {0};
pMoIdList = (ClCorMOIdListPtrT) clHeapAllocate( sizeof(ClCorMOIdListT) + (count - 1) * sizeof(ClCorMOIdT));
//Populate pMoIdList to be registered with PM.
for (i=0 ; i<count; i++)
{
clNameSet(&moIdName, resources[i]);
//Get the MoId from the name.
rc = clCorMoIdNameToMoIdGet(&moIdName, &pMoIdList->moId[i]);
if (rc != CL_OK)
{
clLogError("APP", "INT", "Failed to get moId from moId name. rc [0x%x]", rc);
clHeapFree(pMoIdList);
return rc;
}
//Set the PM MSO service.
clCorMoIdServiceSet(&pMoIdList->moId[i], CL_COR_SVC_ID_PM_MANAGEMENT);
}
pMoIdList->moIdCnt = count;
//Start the PM operation.
rc = clPMStart(pMoIdList);
if (rc != CL_OK)
{
clLogError("APP", "INT", "Failed to start PM operation on the given Moid list. rc [0x%x]", rc);
clHeapFree(pMoIdList);
return rc;
}
ClUint32T ClRcT
Clovis return code type.
Definition: clCommon.h:168
void clNameSet(ClNameT *name, const char *str)
Load the ClNameT structure.
#define CL_OK
Every thing is OK.
Definition: clCommonErrors.h:68
ClRcT clCorMoIdNameToMoIdGet(CL_IN ClNameT *moIdName, CL_OUT ClCorMOIdT *moId)
Retrieves moId in ClCorMOIdT format, when moId is provided in ClNameT format.
ClRcT clCorMoIdServiceSet(CL_INOUT ClCorMOIdPtrT pMoId, CL_IN ClCorMOServiceIdT svc)
Sets the service ID.
ClCorMOIdListT * ClCorMOIdListPtrT
Pointer type to ClCorMOIdListT.
Definition: clCorNotifyApi.h:122
void clHeapFree(CL_IN ClPtrT pAddress)
Frees a pre-allocated memory.
ClPtrT clHeapAllocate(CL_IN ClUint32T size)
Allocates memory of the requested size.
ClRcT clPMStart(ClCorMOIdListPtrT pMoIdList)
Starts the PM operation on the list of MO Ids passed.
A name.
Definition: clCommon.h:197
The structure ClCorMOId contains MoId of the object, which is the address of the COR object.
Definition: clCorMetaData.h:918
Type to store the list of MoIds.
Definition: clCorNotifyApi.h:106

The below code shows the Primary OI implementation for PM Read

ClRcT clCompAppPMObjectRead(ClHandleT txnHandle, ClPMObjectDataPtrT pObjectData)
{
ClUint32T i = 0;
clLogNotice("APP", "READ", "***Invoking read callback function***");
clLogNotice("APP", "READ", "INFO : MoId :");
clCorMoIdShow(pObjectData->pMoId);
clLogNotice("APP", "READ", "Attr Count : [%u]", pObjectData->attrCount);
for (i=0; i<pObjectData->attrCount; i++)
{
clLogNotice("APP", "READ", "--------------------");
clLogNotice("APP", "READ", "Attr Id : [%d]", pObjectData->pAttrData[i].attrId);
clLogNotice("APP", "READ", "Attr Type : [%d]", pObjectData->pAttrData[i].attrType);
clLogNotice("APP", "READ", "Attr DataType : [%d]", pObjectData->pAttrData[i].attrDataType);
clLogNotice("APP", "READ", "Attr Size : [%u]", pObjectData->pAttrData[i].size);
clLogNotice("APP", "READ", "Attr Index : [%d]", pObjectData->pAttrData[i].index);
//This sample code assumes that all attributes read are of ClInt8T type.
clLogNotice("APP", "READ", "Return value [%d]", i);
*(ClInt8T *) pObjectData->pAttrData[i].pPMData = i;
clLogNotice("APP", "READ", "--------------------");
}
return CL_OK;
}
void clCorMoIdShow(CL_IN ClCorMOIdPtrT pMoId)
Displays the ClCorMOId handle.
ClCorTypeT attrDataType
This contains the actual datatype of the attribute.
Definition: clPMApi.h:94
ClCorAttrIdT attrId
Attribute Id of PM or PM reset attribute.
Definition: clPMApi.h:76
ClUint32T size
Size of the attribute.
Definition: clPMApi.h:107
ClCorAttrTypeT attrType
Type of the attribtute.
Definition: clPMApi.h:89
void * pPMData
This contains the PM reset attribute's value if it is reset from north-bound, or the Primary OI shoul...
Definition: clPMApi.h:102
ClInt32T index
Index of the attribute.
Definition: clPMApi.h:113
This is used to pass the PM object's values to the Primary OI.
Definition: clPMApi.h:134
ClPMAttrDataPtrT pAttrData
This either contains the PM attributes' info or PM reset attributes' info and value.
Definition: clPMApi.h:149
ClCorMOIdPtrT pMoId
The PM Object Identifier.
Definition: clPMApi.h:138
ClUint32T attrCount
This contains the no.
Definition: clPMApi.h:143

The below code shows how to access the PM reset value. The user is supposed to reset all the PM attributes depending on the PM reset value.

ClRcT clCompAppPMObjectReset(ClHandleT txnHandle, ClPMObjectDataPtrT pObjectData)
{
clLogNotice("APP", "RESET", "***Invoking RESET callback function***");
clLogNotice("APP", "RESET", "--------------------");
clLogNotice("APP", "RESET", "INFO : MoId :");
clCorMoIdShow(pObjectData->pMoId);
clLogNotice("APP", "RESET", "Attr Id : [%d]", pObjectData->pAttrData[0].attrId);
clLogNotice("APP", "RESET", "Attr Type : [%d]", pObjectData->pAttrData[0].attrType);
clLogNotice("APP", "RESET", "Attr DataType : [%d]", pObjectData->pAttrData[0].attrDataType);
clLogNotice("APP", "RESET", "Attr Size : [%u]", pObjectData->pAttrData[0].size);
clLogNotice("APP", "RESET", "Attr Index : [%d]", pObjectData->pAttrData[0].index);
clLogNotice("APP", "RESET", "Reset Value [%d]", *(ClInt8T *) pObjectData->pAttrData[0].pPMData);
clLogNotice("APP", "RESET", "--------------------");
return CL_OK;
}

The below code shows how to stop PM operation on a particular set of MoIds.

//Stop the PM operation on the first two resources in the above list.
pMoIdList->moIdCnt = 2;
rc = clPMStop(pMoIdList);
if (rc != CL_OK)
{
clLogError("APP", "RESET", "Failed to stop PM operation on the moId list. rc [0x%x]", rc);
clHeapFree(pMoIdList);
return rc;
}
ClRcT clPMStop(ClCorMOIdListPtrT pMoIdList)
Stops the PM operation on the list of MO Ids passed.

Generated on Tue Jan 10 10:29:15 PST 2012 for OpenClovis SDK using Doxygen