cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
410
Views
0
Helpful
1
Replies

NSO Action Hidden Commit

MichaelEllis
Level 1
Level 1

I have been tasked with updating an action (python) I didn't design.  This action has no call to "transaction.apply".  I have proof that it is working and actually applying the changes made, but it never appears to actually make the commit itself and I have no idea how or why, or where to look (its possible that this flag is not in the python code itself, but I can't find it).

Generally speaking the code looks like this (specifics removed):

vars = ncs.template.Variables()
m = ncs.maapi.Maapi()
root = ncs.maagic.get_root()
if uinfo.actx_thandle != -1:
  # When invoked from the CLI we get a transaction
  # Note: unless we are in configure mode it will be read-only
  m.attach2(0, 0, uinfo.actx_thandle)
  trans = maapi.Transaction(m, uinfo.actx_thandle)
else:
  # Start write transaction and apply it at end
  trans = m.start_write_trans(usid=uinfo.usid)
  do_apply = True

template = ncs.template.Template(trans, "/")

#Do some logic with inputs

#apply the templates
vars.add('thingie', things[0])
template.apply('MyTemplate', vars)

#that's all folks, there's nothing after the template.apply


The question is this:  When is this transaction actually committed/Applied?

With followup questions of:  If I want to add the results of a dry run, but commit anyway, do I have to manually commit after running the dry run, otherwise this will NOT commit?

1 Reply 1

vleijon
Cisco Employee
Cisco Employee

Well, if it does attach to an existing transaction it will be committed when the transaction it attached to is committed. If you are in the CLI this will be when you do a successful commit.

 

And yes, commit dry-run only shows the output, it does not actually do it. You will have to do an actual commit afterwards.