update : just fixed a syntax error in the code snippet below. get_rollback_id seems to works also in a commit queue context !
We'd like to facilitate rollback action for persons operating action on the network handled by NSO. They may not have direct access to NSO to manually find a rollback file so we need to programmatically get the rollback ID.
We saw that this would be possible since NSO 5.4 so we've waited for it until we recently upgrade from NSO 5.2.8 to 5.7.4. It works as expected for basic transaction but we encounter an error when we try to use it along commit queue :
with ncs.maapi.Maapi() as m:
with ncs.maapi.Session(m, uinfo.username, 'system'):
with m.start_write_trans() as t:
root = ncs.maagic.get_root(t)
root.devices.device['DEVICE1'].config.port['4/2/5'].description = "test"
commit_params = ncs.maapi.CommitParams()
result = t.apply_params(params=commit_params)
cq_id = result["id"]
cq_id = None
self.log.info("Pas de commit queue ID")
status = result["status"]
if status != 'completed':
self.log.info("Error sending conf")
rollbackID = _ncs.maapi.get_rollback_id(t.maapi.msock,t.th)
output.result = "configuration OK, rollback ID : " + str(rollbackID)
Error: Python cb_action error. Bad protocol usage or unexpected retval (21): not allowed for attached transaction