When you modify objects in ASL scripts, the objects change as each modification occurs. Using transactions, you can commit many changes to the objects in a Domain Manager as a single change or choose to stop all of them. Use the following syntax to create a transaction:
<variable> = transaction();
You cannot assign a transaction to a global variable or to a statically scoped variable. After you assign the transaction to a variable, every change made to an object does not affect the object until you commit the transaction. If the you stop the transaction, any changes made will not affect the object. Use the following syntax to commit a transaction:
<variable>->commit()
Use the following syntax to stop a transaction:
<variable>->abort()
The changes made with a transaction are not visible outside of the ASL script until you commit the changes. Within a transaction, the same ASL script can see the proposed changes. Transactions also can control how other applications see objects before changes are committed or stoppeded by adding a single keyword. The syntax of a transaction with a keyword is:
<variable> = transaction([WRITE_LOCK|READ_LOCK|NO_LOCK]);
A keyword can be any one of those listed in Transaction keywords.
Keyword |
Description |
---|---|
WRITE_LOCK |
While the transaction is open, no other process can modify or access information in the repository. |
READ_LOCK |
Currently behaves as WRITE_LOCK. |
NO_LOCK |
This is the default behavior. No locks exist until the ASL commits the transaction. |
You can nest transactions. When you nest a transaction, you must commit or stop the nested transaction before you commit or stop the previous transaction.
ASL stops any open transactions when the START rule completes.
A maximum of 16 transactions may be open concurrently.
The following script deletes a card and its related ports. The script contains a default variable that specifies the card to delete. Using the ComposedOf relationship, the ASL script creates a list of port objects to delete. The script deletes the card and its related ports at the same time through a transaction.
ASL Script (deltrans_obj.asl): default delthis = "CARDX"; START do { delthisObj = object(delthis); relObj = delthisObj->ComposedOf?LOG,STOP; deltrans=transaction(); x = delthisObj->delete(); foreach mem (relObj) { mem->delete(); } deltrans->commit(); print("Deleted ".delthis." and related ports"); stop(); } Input: none Output: $ sm_adapter --server=JS1 -Ddelthis="CARD2" deltrans_obj.asl Deleted CARD2 and related ports $