Code Examples. More...
Code Examples.
While the necessary blue-print is created during OpenClovis ASP initialization, COR object manipulation happens at run-time, and mainly through through three functions:
These three functions use transactions to perform the desired object related operation(s). After the MO class tree is created during COR initialization, you can create the MO/MSO, set an attribute of that MO/MSO or delete an MO/MSO using these Object manipulation functions.
The object creation, attribute-set and object deletion can be queued in one transaction. These operations when queued in the transaction are identified by a transaction ID. Each transaction ID can have multiple transaction jobs operating on an MO/MSO which can be identified by the object handle or moId and the attrPath (containment path). Once all COR object manipulations have been performed, the clCorTxnSessionCommit() function is called. The COR client packs the transaction jobs and makes an RMD to the server through the clCorTxnSessionCommit() function. The transaction jobs are packed in the network format.
At the server side, the information of the components (for which the transaction manager will initiate the transaction callbacks) is obtained from COR's route list. This is a list of stations that need to be visited. Also if the peer COR is up and running then it will also be a part of transaction. After adding all the transaction jobs for the transaction ID and its list of components, COR starts the transaction.
COR performs all the object-related operations in the commit phase of the transaction. For a given transaction ID, all the transaction jobs are walked and specific operations are performed. The clCorTxnJobWalk() function is called with a callback which performs the necessary operations based on the opType obtained from each transaction job.
Sample Code for the Object Create/Set/Delete using single as well as complex transaction.
COR Transaction APIs are used by components that participate in a transaction. A component participating in a transaction obtains a transaction handle ( txnHandle) through the callback functions for validate,commit and rollback which can be used in the COR transaction APIs to validate the transaction. A transaction can contain various COR operations related to one or more Managed Objects (MO). The operations related to an MO are considered as one transaction job. Within a transaction job there can be multiple COR operations which can be obtained by using the COR-Transaction APIs.
A transaction can consist of one or more object-create/set/delete operations or a combination of these operations as well. COR creates one COR-Transaction ID for a combination of MOID and attrpath. For a given COR-Transaction ID, COR creates one COR-Job ID for each attributeId. (that is being set for a particular MOID + attrPath). These jobs are linked together in the COR-job-list.
Following steps are performed to obtain COR-job-list and to perform a walk operation.
A sample validate function:
The COR bundle feature is used to perform get operation on multiple attributes in a single request to COR. The bundle-get can take list of attributes belonging to the same or different MO. These attributes can either be configuration or the runtime attributes. The user need to add all the get requests in the same bundle which will be send to COR server as a single request. There it will populate the value for configuration attributes and for the value of runtime attributes it will get it from the primary OI. After getting the response the OIs it will aggregates the information and send the response. Here is a sample code to demonstrate both the synchronous and asynchronous version of bundle get.
The clCorObjectCreateAndSet() is an additional function to the COR session capability. This API should be used to create the objects of the MO-Class which has intialized attributes modeled. The initialized attributes are key attribute which should be provided while creating an instance of the class. Inorder to create instance for this class, the API clCorObjectCreateAndSet() should be used which allows providing the attribute list and their values while creating the object. This API can be used to create an object without any key attributes as well. As this function is part of COR's session capability, so all the features of session are applicable to this API as well. Here is the sample code which shows the usage of this API.