I was wondering if it is possible to trigger a transaction commit (maapi_apply_trans) in an action handler (for an action to which a transaction is associated of course, such as an action triggered from the CLI).
I gave it a try and couldn’t succeed to make it work. I tried two different methods.
Method one, I just used the maapi_apply_trans on the transaction I obtained from the confd_action_ctx (i.e the current transaction ongoing in the agent that triggered the action). To me, it makes sense that it does not work since that would place the transaction in a new state (START first and then READ) and therefore the agent that initiates the action would end up with a transaction in a new state without knowing it. Is-that the reason why it does not work?
Method two, I created a new transaction with maapi_start_trans (let’s call it T2) on the maapi socket attached to the action transaction (let’s call it T1). Then I copied T1 into T2 with maapi_copy. After that, I just call maapi_apply_trans and maapi_finish_trans. But that fails too. I don’t get why.
Thank you in advance for your help.